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

AWT/Swing Java Discussion :

Petit soucis de focus et de dimensionnement


Sujet :

AWT/Swing Java

  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    327
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 327
    Par défaut Petit soucis de focus et de dimensionnement
    Bonsoir,

    Voila j'ai deux petits soucis:

    1) j'aimerai que lorsque je modifie la taille de ma JFrame avec la souris mes deux panels et ce qu'ils contiennent (c'est à dire deux JScrollPane contenant eux-même un JTextArea) soient proportionnelles à la nouvelle taille, c'est à dire disposer comme lors du premier lancement.

    2) j'aimerai aussi donner le focus à ma JTextArea du bas lors du lancement du programme mais ce que j'ai fais ne marche pas

    C'est pour faire une fenêtre de Tchat, donc si vous avez aussi d'autres idées, n'hésitez pas à me le dire Voici mon code:

    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
    package client;
     
    import java.awt.BorderLayout;
    import java.awt.event.KeyEvent;
     
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.ActionMap;
    import javax.swing.InputMap;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.KeyStroke;
     
    public class InterfaceGraphique extends JFrame {
    	private static final long serialVersionUID = -2040488316874518030L;
    	JPanel panel = new JPanel ();
    	JPanel result = new JPanel ();
    	JTextArea envoieTexte = new JTextArea (5, 55);
    	JTextArea receptionTexte = new JTextArea (20, 55);
    	JScrollPane scrollRecept = new JScrollPane ();
    	JScrollPane scrollEnvoi = new JScrollPane ();
     
    		public InterfaceGraphique () {
    			build (); //On initialise notre fenetre
    		}
     
    		private void build () {
    			InputMap inputMap = this.envoieTexte.getInputMap ();
    			ActionMap actionMap = this.envoieTexte.getActionMap ();
    			JMenuBar menuBar = new JMenuBar ();
    			JMenu menu1 = new JMenu ("Fichier");
    			JMenu menu2 = new JMenu ("?");
     
    			menuBar.add (menu1);
    			menuBar.add (menu2);
    			this.setJMenuBar (menuBar);
    			this.setTitle ("Tchat"); //On donne un titre a l'application
    			this.setSize (640, 480); //On donne une taille a notre fenetre
    			this.setLocationRelativeTo (null); //On centre la fenêtre sur l'écran
    			this.setResizable (true); //On autorise le redimensionnement de la fenetre
    			this.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); //On dit a l'application de se fermer lors du clic sur la croix
    			this.getContentPane ().add (this.buildResult (), BorderLayout.SOUTH);
    			this.getContentPane ().add (this.buildPanel (), BorderLayout.NORTH);
                            this.envoieTexte.requestFocusInWindow ();
    			inputMap.put (KeyStroke.getKeyStroke (KeyEvent.VK_ENTER, 0), "envoiTexte");
    			actionMap.put ("envoiTexte", new EnvoiAction (this));
    		}
     
    		private JPanel buildPanel () {
    			this.receptionTexte.setLineWrap (true);
    			this.receptionTexte.setEditable (false);
    			this.scrollRecept.setViewportView (this.receptionTexte);
    			this.panel.add (this.scrollRecept);
     
    			return this.panel;
    		}
     
    		private JPanel buildResult () {
    			this.envoieTexte.setLineWrap (true);
    			this.scrollEnvoi.setViewportView (this.envoieTexte);
    			this.result.add (this.scrollEnvoi);
     
    			return this.result;
    		}
     
    		public JTextArea getEnvoieTexte () {
    			return this.envoieTexte;
    		}
     
    		public JTextArea getReceptionTexte () {
    			return this.receptionTexte;
    		}
     
    }
    Merci d'avance à ceux qui voudront bien m'aider

  2. #2
    Membre éclairé
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    327
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 327
    Par défaut
    J'ai reussi à résoudre mon problème de redimensionnement mais pas celui du focus

  3. #3
    Membre Expert
    Avatar de visiwi
    Profil pro
    Inscrit en
    Février 2008
    Messages
    1 052
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 1 052
    Par défaut
    Tu peux créer une méthode qui attribut le focus au composant que tu souhaite et l'appeler après que tu es rendu la fenêtre visible.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    public void giveDefaultFocus() {
    	SwingUtilities.invokeLater(new Runnable() {
    		@Override
    		public void run() {
    			envoieTexte.requestFocus();
    		}
    	});
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    public static void main(String[] args) {
    	InterfaceGraphique fenetre = new InterfaceGraphique();
    	fenetre.setVisible(true);
    	fenetre.giveDefaultFocus();
    }

  4. #4
    Membre éclairé
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    327
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 327
    Par défaut
    C'est bon j'ai réussi à le résoudre mais d'une autre manière, mais merci beaucoup

    Sinon dans l'étape suivante de mon appli j'ai un autre problème qui survient et j'avoue que je ne comprend pas très bien Voici déjà l'erreur en question:

    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
    Exception occurred during event dispatching:
    java.lang.NullPointerException
    	at client.OkAction.actionPerformed(OkAction.java:25)
    	at javax.swing.SwingUtilities.notifyAction(Unknown Source)
    	at javax.swing.JComponent.processKeyBinding(Unknown Source)
    	at javax.swing.JComponent.processKeyBindings(Unknown Source)
    	at javax.swing.JComponent.processKeyEvent(Unknown Source)
    	at java.awt.Component.processEvent(Unknown Source)
    	at java.awt.Container.processEvent(Unknown Source)
    	at java.awt.Component.dispatchEventImpl(Unknown Source)
    	at java.awt.Container.dispatchEventImpl(Unknown Source)
    	at java.awt.Component.dispatchEvent(Unknown Source)
    	at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
    	at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
    	at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
    	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
    	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
    	at java.awt.Component.dispatchEventImpl(Unknown Source)
    	at java.awt.Container.dispatchEventImpl(Unknown Source)
    	at java.awt.Window.dispatchEventImpl(Unknown Source)
    	at java.awt.Component.dispatchEvent(Unknown Source)
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.Dialog$1.run(Unknown Source)
    	at java.awt.Dialog$3.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.awt.Dialog.show(Unknown Source)
    	at java.awt.Component.show(Unknown Source)
    	at java.awt.Component.setVisible(Unknown Source)
    	at java.awt.Window.setVisible(Unknown Source)
    	at java.awt.Dialog.setVisible(Unknown Source)
    	at client.InterfaceGraphique.buildDialog(InterfaceGraphique.java:75)
    	at client.InterfaceGraphique.<init>(InterfaceGraphique.java:42)
    	at client.TestInterface$1.run(TestInterface.java:10)
    	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.run(Unknown Source)
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    	at client.InterfaceGraphique.<init>(InterfaceGraphique.java:43)
    	at client.TestInterface$1.run(TestInterface.java:10)
    	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.run(Unknown Source)
    Et les 3 classes concernées:

    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
    package client;
     
    import java.awt.event.ActionEvent;
     
    import javax.swing.AbstractAction;
    import javax.swing.JOptionPane;
     
    public class OkAction extends AbstractAction {
    	private static final long serialVersionUID = -3401192543611768408L;
    	private InterfaceGraphique fenetre;
    	private Client client;
     
    		public OkAction (InterfaceGraphique fenetre, String texte){
    			super (texte);
    			this.fenetre = fenetre;
    		}
     
    		public void actionPerformed (final ActionEvent e) { 
    			String valServeur = this.fenetre.getServeur().getText ();
    			String valLogin = this.fenetre.getLogin ().getText ();
     
    			if (Client.isValidAddress (valServeur)) {
    				this.fenetre.setName (valLogin);
    				this.fenetre.getDialog ().dispose ();
    				client.setName (valLogin); //ici
    				client.setServeur (valServeur);
    			}
    			else {
    				JOptionPane.showMessageDialog (fenetre, "Le serveur n'existe pas ou n'est pas connecté");
    				this.fenetre.getServeur ().setText (null);
    				this.fenetre.getServeur ().requestFocusInWindow ();
    			}
    		} 
    }
    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
    package client;
     
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintWriter;
    import java.net.InetAddress;
    import java.net.Socket;
    import java.net.UnknownHostException;
     
    import javax.swing.JOptionPane;
     
    public class Client implements Runnable {
    	private Socket socket;
        private PrintWriter out;
        private BufferedReader in;
        private Thread t;
        private boolean deco = false;
        private String name;
        private String serveur;
        private InterfaceGraphique fenetre;
        private String texte;
     
        	public static boolean isValidAddress (String host) {
        		try {
        			return InetAddress.getByName (host).isReachable (10000);
        		}
        		catch (Exception e) {
        			return false;
        		}
        	}
     
        	public void connection () {
    	    	try {
    	    		this.socket = new Socket (this.serveur, 20000);
    	            this.out = new PrintWriter (socket.getOutputStream (), true);
    	            this.in = new BufferedReader (new InputStreamReader (socket.getInputStream ()));
    	            this.t = new Thread (this);
    	            this.t.start ();
    	            if (this.out != null) {
    		    		this.out.println (this.name);
    		    	}
    	        } 
    	    	catch (UnknownHostException e) {
    	    		JOptionPane.showMessageDialog (this.fenetre, "Impossible de trouver l'hote");
    	        } 
    	    	catch (IOException e) {
    	            JOptionPane.showMessageDialog (this.fenetre, "Soucis d'I/O avec l'hote");
    	        }
    	    	catch (NullPointerException e) {
    	    		JOptionPane.showMessageDialog (this.fenetre, "Pointeur null reçu");
    	    	}  
    	    }
     
    	    public void envoie () {
    	    	String fromUser = "";
     
    	    	//try {
    	    		while (true) {
    		    		// envoie
    	    			fromUser = this.getTexte ();
    	    			if (fromUser != null && fromUser.length () != 0) {
    			    		if (this.out != null) {
    			    			this.out.println (this.name + ":" + fromUser);
    			    		}
    			    		if (fromUser.equals ("deco") && this.deco) {
    			    			JOptionPane.showMessageDialog (this.fenetre, "Vous etes deja deconnecte du serveur");
    	    				}
    			    		if (fromUser.equals ("quitter")) {
    							break;
    					    }
    					    if (fromUser.equals ("connect")) {
    					    	if (this.deco) {
    					    		this.connection ();
    					    	}
    					    }
    		    		}
    				    fromUser = "";
    	    		}
    	    }
     
    	    public void setName (String name) {
    	    	this.name = name;
    	    }
     
    	    public void setServeur (String serveur) {
    	    	this.serveur = serveur;
    	    }
     
    	    public void setTexte (String texte) {
    	    	this.texte = texte;
    	    }
     
    	    public String getTexte () {
    	    	return this.texte;
    	    }
     
    	    public void run () {
    	    	String[] fromServer = null;
    	    	String tmp = null;
     
    		    try {
    			    while (true) {
    			    	// reception
    				    tmp = this.in.readLine ();
    				    if (tmp != null) {
    				    	fromServer = tmp.split (":");
    				    	if (fromServer[1].length () != 0) {
    					    	if (fromServer[1].equals ("quitter") || fromServer[1].equals ("deco")) {
    					    		break;
    							}
    							this.fenetre.getReceptionTexte ().setText (fromServer[0] + ": ");
    					    	for (int i=1;i<fromServer.length;i++) {
     
    					    			this.fenetre.getReceptionTexte ().setText (fromServer[i]);
    					    			if (i != fromServer.length - 1) {
     
    					    				this.fenetre.getReceptionTexte ().setText (" ");
    							    	}
    							}
    					    	this.fenetre.getReceptionTexte ().setText ("\n");
    						    fromServer = null;
    						    tmp = null;
    				    	}
    			    	}
    			    }
    	    	}
    	    	catch (IOException e) {
    	    		JOptionPane.showMessageDialog (this.fenetre, "Serveur en rade");
    			}
        		finally {
        			try {
        	    		this.deco = true;
            	    	this.out.close ();
            	    	this.in.close ();
            	    	this.socket.close ();
        			} 
        			catch (IOException e) {
        				JOptionPane.showMessageDialog (this.fenetre, "Erreur dans d'I/O dans la classe Client L.180");
        			}
        		}
    	    }
    }
    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
    package client;
     
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.event.KeyEvent;
     
    import javax.swing.BoxLayout;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.ActionMap;
    import javax.swing.InputMap;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.KeyStroke;
     
    public class InterfaceGraphique extends JFrame {
    	private static final long serialVersionUID = -2040488316874518030L;
    	private JPanel panel = new JPanel ();
    	private JPanel result = new JPanel ();
    	private JPanel panel2 = new JPanel ();
    	private JTextArea envoieTexte = new JTextArea (5, 55);
    	private JTextArea receptionTexte = new JTextArea (20, 55);
    	private JScrollPane scrollRecept = new JScrollPane ();
    	private JScrollPane scrollEnvoi = new JScrollPane ();
    	private JTextField serveur = new JTextField ();
    	private JTextField login = new JTextField ();
    	private JLabel label1 = new JLabel ("Entrez le nom ou l'adresse IP du serveur");
    	private JLabel label2 = new JLabel ("Entrez votre login");
    	JDialog dialog = new JDialog (this, "Connexion", true);
    	private String name;
    	private Client client;
     
    		public InterfaceGraphique () {
    			this.buildDialog ();
    			client.connection (); //ici
    			client.envoie ();
    			this.build (); //On initialise notre fenetre
    		}
     
    		private void buildDialog () {
    			JButton bouton = new JButton (new OkAction (this, "OK"));
    			InputMap inputMap = this.serveur.getInputMap ();
    			ActionMap actionMap = this.serveur.getActionMap ();
    			InputMap inputMap2 = this.login.getInputMap ();
    			ActionMap actionMap2 = this.login.getActionMap ();
     
    			this.panel2.setLayout (new BoxLayout (panel2, BoxLayout.Y_AXIS));
    			this.serveur.setAlignmentX (Component.CENTER_ALIGNMENT);
    			this.login.setAlignmentX (Component.CENTER_ALIGNMENT);
    			this.label1.setAlignmentX (Component.CENTER_ALIGNMENT);
    			this.label2.setAlignmentX (Component.CENTER_ALIGNMENT);
    			bouton.setAlignmentX (Component.CENTER_ALIGNMENT);
    			this.panel2.add (this.label1);
    			this.panel2.add (this.serveur);
    			this.panel2.add (this.label2);
    			this.panel2.add (this.login);
    			this.panel2.add (bouton);
    			this.dialog.setLocationRelativeTo (null);
    			this.dialog.setResizable (false);
    			this.dialog.add (this.panel2);
    			this.dialog.pack ();
    			inputMap.put (KeyStroke.getKeyStroke (KeyEvent.VK_ENTER, 0), "ok");
    			actionMap.put ("ok", new OkAction (this, "OK"));
    			inputMap2.put (KeyStroke.getKeyStroke (KeyEvent.VK_ENTER, 0), "ok");
    			actionMap2.put ("ok", new OkAction (this, "OK"));
    			this.dialog.setVisible (true); //ici
    		}
     
    		private void build () {
    			InputMap inputMap = this.envoieTexte.getInputMap ();
    			ActionMap actionMap = this.envoieTexte.getActionMap ();
    			JMenuBar menuBar = new JMenuBar ();
    			JMenu menu1 = new JMenu ("Fichier");
    			JMenuItem quitter = new JMenuItem (new QuitterAction (this, "Quitter"));
    			JMenu menu2 = new JMenu ("?");
    			JMenuItem aPropos = new JMenuItem (new AProposAction (this, "A propos"));
     
    		    menu1.add (quitter);
    			menuBar.add (menu1);
    			menu2.add (aPropos);
    			menuBar.add (menu2);
    			this.setJMenuBar (menuBar);
    			this.setTitle ("Tchat"); //On donne un titre a l'application
    			this.setLocationRelativeTo (null); //On centre la fenêtre sur l'écran
    			this.setResizable (true); //On autorise le redimensionnement de la fenetre
    			this.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); //On dit a l'application de se fermer lors du clic sur la croix
    			this.setMinimumSize (new Dimension (250, 250));
    			this.getContentPane ().add (this.buildPanel (), BorderLayout.CENTER);
    			this.getContentPane ().add (this.buildResult (), BorderLayout.SOUTH);
    			this.envoieTexte.requestFocusInWindow ();
    			this.pack ();
    			inputMap.put (KeyStroke.getKeyStroke (KeyEvent.VK_ENTER, 0), "envoiTexte");
    			actionMap.put ("envoiTexte", new EnvoiAction (this, this.name));
    			inputMap.put (KeyStroke.getKeyStroke (KeyEvent.VK_ESCAPE, 0), "quitter");
    			actionMap.put ("quitter", new QuitterAction (this, ""));
    		}
     
    		private JPanel buildPanel () {
    			this.panel.setLayout (new BorderLayout (5,5));
    			this.receptionTexte.setLineWrap (true);
    			this.receptionTexte.setEditable (false);
    			this.scrollRecept.setViewportView (this.receptionTexte);
    			this.panel.add (this.scrollRecept);
     
    			return this.panel;
    		}
     
    		private JPanel buildResult () {
    			this.result.setLayout (new BorderLayout (5, 5));
    			this.envoieTexte.setLineWrap (true);
    			this.scrollEnvoi.setViewportView (this.envoieTexte);
    			this.result.add (this.scrollEnvoi);
     
    			return this.result;
    		}
     
    		public JTextArea getEnvoieTexte () {
    			return this.envoieTexte;
    		}
     
    		public JTextArea getReceptionTexte () {
    			return this.receptionTexte;
    		}
     
    		public JTextField getServeur () {
    			return this.serveur;
    		}
     
    		public JTextField getLogin () {
    			return this.login;
    		}
     
    		public void setName (String name) {
    			this.name = name;
    		}
     
    		public JDialog getDialog () {
    			return this.dialog;
    		}
    }
    Merci d'avance

  5. #5
    Membre Expert
    Avatar de visiwi
    Profil pro
    Inscrit en
    Février 2008
    Messages
    1 052
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 1 052
    Par défaut
    Dans la méthode actionPerformed (OkAction) tu as un null à la ligne 25.

  6. #6
    Membre éclairé
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    327
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 327
    Par défaut
    Justement il n'y a aucune raison pour laquelle "valLogin" vaut null. Ou alors elle est modifié entre deux instructions mais je ne vois pas ou

  7. #7
    Membre éclairé
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    327
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 327
    Par défaut
    C'est bon j'ai trouvé, c'est normal que cela ne marche pas puisque je ne créé aucune instance pour mon objet Client... Désolé de vous avoir dérangé avec mon extrème bétise Et encore merci

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

Discussions similaires

  1. [Swing][Focus] petit soucis trés étrange
    Par estacado dans le forum AWT/Swing
    Réponses: 1
    Dernier message: 13/02/2006, 22h57
  2. petit soucy de fenetre cmd
    Par FeetloveR666 dans le forum Windows
    Réponses: 5
    Dernier message: 03/07/2004, 14h24
  3. petit soucis lors d'un LOAD DATA INFILE
    Par Jovial dans le forum SQL Procédural
    Réponses: 9
    Dernier message: 04/06/2004, 11h58
  4. Réponses: 6
    Dernier message: 21/01/2004, 13h25
  5. [DEBUTANT] petits soucis avec un prgm de chat
    Par LechucK dans le forum MFC
    Réponses: 8
    Dernier message: 19/01/2004, 16h52

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