IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Agents de placement/Fenêtres Java Discussion :

JFrame problème d'affichage


Sujet :

Agents de placement/Fenêtres Java

  1. #1
    Membre à l'essai
    Homme Profil pro
    Licence RGI
    Inscrit en
    Septembre 2016
    Messages
    39
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 30
    Localisation : France, Oise (Picardie)

    Informations professionnelles :
    Activité : Licence RGI

    Informations forums :
    Inscription : Septembre 2016
    Messages : 39
    Points : 14
    Points
    14
    Par défaut JFrame problème d'affichage
    Bonjour messieurs
    Je viens vous demander de l'aide concernant un problème d'affichage sur mes programmes ayant des JFrame.
    Je m'explique, lorsque je souhaite faire apparaître une JFrame avec une JTextArea contenant du texte elle apparaîssent totalement grise comme sur l'image ci-dessous .
    Nom : Base.png
Affichages : 230
Taille : 20,5 Ko

    Pour que le contenu soit visible je dois absolument redimensionner ma JFrame. Soit en cliquant sur affichage plein écran soit en réajustant manuellement comme ci-dessous.
    Nom : Redimensionne.png
Affichages : 239
Taille : 20,2 Ko
    J'ai trouvé bon nombre de sujet concernant le même problême mais aucunes des solutions proposés n'a pu m'aider.
    Avez vous des pistes ?
    Je vous poste la méthode concernant l'affichage des JFrame + mon "main" si ça peut vous aider.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    public static void PopUpSave(){
    	    	JFrame win = new JFrame();
    			win.setSize(400, 100);
     
    			win.setVisible(true);
     
    			JPanel content = new JPanel();
     
    			win.setContentPane(content);
    			win.setTitle("Step 1");
    			win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
     
    			JTextArea jta;
    			jta = new JTextArea();
    			jta.setText("Please select the folder to save the file");
     
    			JScrollPane scrollingArea = new JScrollPane(jta);
    			content.setLayout(new BorderLayout());
    			content.add(scrollingArea, BorderLayout.CENTER);
     
    		}
    	    public static void PopUpFile(){
    	    	JFrame win = new JFrame();
    			win.setSize(400, 100);
     
    			win.setTitle("Step 2");
    			win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    			win.setVisible(true);
     
    			JPanel content = new JPanel();
    			win.setContentPane(content);
     
    			JTextArea jta;
    			jta = new JTextArea();
    			jta.setText("Now, please select the file");
     
    			JScrollPane scrollingArea = new JScrollPane(jta);
     
    			content.setLayout(new BorderLayout());
    			content.add(scrollingArea, BorderLayout.CENTER);
     
    		}
    Je vous poste aussi l'intégralité du code si jamais vous souhaitez faire le test du programme chez vous ca permettra aussi de savoir si le pb concerne mon eclipse au passage.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.awt.BorderLayout;
    import java.awt.TextArea;
    import java.io.File;
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    import java.util.ArrayList;
    import java.util.Scanner;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
     
    public class ExtractData {		
    		static String fichier;
     
    		public static void main(String[] args) throws FileNotFoundException,IOException{	
     
    			String goodOut = null;			
     
    			goodOut = sauvegardeExplo();
    			ALL(fichier, goodOut+"DataExtraction.csv");
     
    		}												
     
     
     
    		@SuppressWarnings("unused")
    		public static ArrayList<Process> findIdsFromFile(String filePath)throws FileNotFoundException{
     
    	        Scanner scanner = new Scanner(new File(fichier));
     
                ArrayList<Process> processList = new ArrayList<Process>();
    	        ArrayList<String> idsList = new ArrayList<String>();
     
    	        int i=0;
    	        while (scanner.hasNextLine()){                  
                    String ch=scanner.nextLine();
     
                    if(ch.contains("<")){   
     
                    	Matcher matcher  = Pattern.compile("(<ns3:ProcessID>([a-zA-Z0-9]*)</ns3:ProcessID>)").matcher(ch);
                    	Matcher matcher1 = Pattern.compile("(<ns3:AssemblyLine>([a-zA-Z0-9]*)</ns3:AssemblyLine>)").matcher(ch);
                    	Matcher matcher2 = Pattern.compile("(<ns3:DayOfYear>([a-zA-Z0-9]*)</ns3:DayOfYear>)").matcher(ch);
                    	Matcher matcher3 = Pattern.compile("(<ns3:SequenceOfDay>([a-zA-Z0-9]*)</ns3:SequenceOfDay>)").matcher(ch);
     
    	                String id  = "";
    	                String id1 = "";
                        String id2 = "";
                        String id3 = "";
     
                        while (matcher.find() & matcher1.find() & matcher2.find() & matcher3.find()){  
     
                        	try{   
                        		id  = matcher.group(2);
                        		id1 = matcher1.group(2);
                        		id2 = matcher2.group(2);
                        		id3 = matcher3.group(2);
     
                        	}catch(Exception e){
     
                        		System.out.println(e);
                        	 }
     
                        	Process p=new Process(id.trim(),id1.trim(),id2.trim(),id3.trim());   
     
                        	idsList.add(id.trim());
                        	idsList.add(id1.trim());
                        	idsList.add(id2.trim());
                        	idsList.add(id3.trim());
     
                        	System.out.println(p);
                        	processList.add(p);}
     
                        i++;                   
                    }
    	        }  scanner.close();
    	        return processList;	        
    		}
     
     
    		public static ArrayList<Process> findProcessFromFile(String FilePath)throws FileNotFoundException{
     
    	        Scanner scanner = new Scanner(new File(FilePath));
     
    	        StringBuilder sb  = new StringBuilder();
    	        StringBuilder sb1 = new StringBuilder();
    	        StringBuilder sb2 = new StringBuilder();
    	        StringBuilder sb3 = new StringBuilder();
     
    	        while (scanner.hasNextLine()){	        	
    	            sb.append(scanner.nextLine());
    	            sb1.append(scanner.nextLine());
    	            sb2.append(scanner.nextLine());
    	            sb3.append(scanner.nextLine());	        	
    	        }
     
    	        ArrayList<Process> processList = new ArrayList<Process>();
    	        ArrayList<String> idsList = new ArrayList<String>();
     
    	        Matcher matcher  = Pattern.compile("(<ns3:ProcessID>([a-zA-Z0-9]*)</ns3:ProcessID>)").matcher(sb.toString());
    	        Matcher matcher1 = Pattern.compile("(<ns3:AssemblyLine>([a-zA-Z0-9]*)</ns3:AssemblyLine>)").matcher(sb1.toString());
    	        Matcher matcher2 = Pattern.compile("(<ns3:DayOfYear>([a-zA-Z0-9]*)</ns3:DayOfYear>)").matcher(sb2.toString());
    	        Matcher matcher3 = Pattern.compile("(<ns3:SequenceOfDay>([a-zA-Z0-9]*)</ns3:SequenceOfDay>)").matcher(sb3.toString());
     
    	        while (matcher.find() & matcher1.find() & matcher2.find() & matcher3.find()){
     
                    String id  = matcher.group(2);
    	            String id1 = matcher1.group(2);
    	            String id2 = matcher2.group(2);
    	            String id3 = matcher3.group(2);	            
     
                    Process p=new Process(id.trim(),id1.trim(),id2.trim(),id3.trim());    
    	            idsList.add(id.trim());
    	            idsList.add(id1.trim());
    	            idsList.add(id2.trim());
    	            idsList.add(id3.trim());
    	            processList.add(p);
    	        }   scanner.close();    
    	        return processList;   
    	    }
     
    	 	public static void ouvertureExplo(){ 
     
    			JFileChooser explorateur = new JFileChooser(new File("C:/Users/1cambien/Desktop"));
    			PopUpFile();
    			if (explorateur.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { // si l'instruction showOpenDialog renvoie APPROVE_OPTION 
    				fichier = explorateur.getSelectedFile().toString();
    				System.out.println(fichier);						
    			}
    		}
     
    	 	public static String sauvegardeExplo(){ 
    	 		String outPath = null;
    	 		String goodOut = null;
    			PopUpSave();
     
    	 		JFileChooser explorateur = new JFileChooser(new File("C:/Users/1cambien/Desktop"));
    			explorateur.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
     
    			if (explorateur.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { // si l'instruction showSaveDialog renvoie APPROVE_OPTION 
     
    				fichier = explorateur.getCurrentDirectory().toString();
     
    				outPath = explorateur.getSelectedFile().toString();	
    				System.out.println(outPath);
    				goodOut = outPath.replace("\\","/");
    				System.out.println(goodOut);
    			}			
    			return goodOut+"/";
    		}
     
    	    public static void ALL(String fichier, String outPath) throws FileNotFoundException, IOException{
     
    	    	ouvertureExplo();
     
    	    	ArrayList<Process> listeProcess = findIdsFromFile(fichier);	        
    	    	PrintWriter out = new PrintWriter(outPath);	        
     
                out.append("sep=,\n");
     
            	out.append("ProcessID,AssemblyLine,Day_of_the_year,Sequence_of_Day\n"); 
     
    	        for (Process p : listeProcess){	        	
    	        	out.append(p.ProcessID+","+p.AssemblyLine+","+p.Day_of_the_year+","+p.Sequence_of_Day+"\n");  
    	        }
     
    	        out.flush();
    	        out.close();
    	    }
    	    public static void PopUpSave(){
    	    	JFrame win = new JFrame();
    			win.setSize(400, 100);
     
    			win.setVisible(true);
     
    			JPanel content = new JPanel();
     
     
     
    			win.setContentPane(content);
    			win.setTitle("Step 1");
    			win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
     
    			JTextArea jta;
    			jta = new JTextArea();
    			jta.setText("Please select the folder to save the file");
     
    			JScrollPane scrollingArea = new JScrollPane(jta);
    			content.setLayout(new BorderLayout());
    			content.add(scrollingArea, BorderLayout.CENTER);
     
    		}
    	    public static void PopUpFile(){
    	    	JFrame win = new JFrame();
    			win.setSize(400, 100);
     
    			win.setTitle("Step 2");
    			win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    			win.setVisible(true);
     
    			JPanel content = new JPanel();
    			win.setContentPane(content);
     
     
     
    			JTextArea jta;
    			jta = new JTextArea();
    			jta.setText("Now, please select the file");
     
    			JScrollPane scrollingArea = new JScrollPane(jta);
     
    			content.setLayout(new BorderLayout());
    			content.add(scrollingArea, BorderLayout.CENTER);
     
    		}
    }

  2. #2
    Modérateur
    Avatar de wax78
    Homme Profil pro
    Chef programmeur
    Inscrit en
    Août 2006
    Messages
    4 073
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Chef programmeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2006
    Messages : 4 073
    Points : 7 978
    Points
    7 978
    Par défaut
    win.setVisible(true); est mal placé.

    Mets le à la fin de ta méthode.
    (Les "ça ne marche pas", même écrits sans faute(s), vous porteront discrédit ad vitam æternam et malheur pendant 7 ans)

    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  3. #3
    Membre à l'essai
    Homme Profil pro
    Licence RGI
    Inscrit en
    Septembre 2016
    Messages
    39
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 30
    Localisation : France, Oise (Picardie)

    Informations professionnelles :
    Activité : Licence RGI

    Informations forums :
    Inscription : Septembre 2016
    Messages : 39
    Points : 14
    Points
    14
    Par défaut
    Voila j'avais pas respecté scrupuleusement les consignes.. ^^
    C'etait simplement ça, un GRAND merci Wax!

  4. #4
    Modérateur
    Avatar de wax78
    Homme Profil pro
    Chef programmeur
    Inscrit en
    Août 2006
    Messages
    4 073
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Chef programmeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2006
    Messages : 4 073
    Points : 7 978
    Points
    7 978
    Par défaut
    De rien, une autre option aurait été aussi de faire JFrame.invalidate(); sans rien toucher au code original, mais c'est a mon avis une mauvaise idée.
    (Les "ça ne marche pas", même écrits sans faute(s), vous porteront discrédit ad vitam æternam et malheur pendant 7 ans)

    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème d'affichage dans une JFrame
    Par farwest dans le forum Agents de placement/Fenêtres
    Réponses: 2
    Dernier message: 06/01/2009, 18h52
  2. Problèmes d'affichage JFrame
    Par womannosky dans le forum Agents de placement/Fenêtres
    Réponses: 2
    Dernier message: 04/07/2008, 16h16
  3. Problème d'affichage de 2 JFrame
    Par youmdingding dans le forum Agents de placement/Fenêtres
    Réponses: 7
    Dernier message: 28/08/2007, 08h57
  4. [JFrame] Problème affichage
    Par goddet dans le forum Agents de placement/Fenêtres
    Réponses: 10
    Dernier message: 21/11/2006, 08h53
  5. Réponses: 3
    Dernier message: 29/04/2006, 22h06

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo