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
|
package nonclquable;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.JTextField;
import java.awt.Color;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
/**
* <p>Titre : </p>
*
* <p>Description : </p>
*
* <p>Copyright : Copyright (c) 2006</p>
*
* <p>Société : </p>
*
* @author non attribuable
* @version 1.0
*/
public class Cadre1 extends JFrame {
int x;
JPanel contentPane;
XYLayout xYLayout1 = new XYLayout();
JTextField jTextField1 = new JTextField();
JTextField jTextField2 = new JTextField();
public Cadre1() {
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* Initialisation du composant.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
contentPane = (JPanel) getContentPane();
contentPane.setLayout(xYLayout1);
setSize(new Dimension(400, 300));
setTitle("Titre du cadre");
jTextField1.setBackground(Color.red);
jTextField1.setText("jTextField1");
jTextField1.addMouseListener(new Cadre1_jTextField1_mouseAdapter(this));
jTextField2.setBackground(Color.orange);
jTextField2.setCaretColor(Color.white);
jTextField2.setText("jTextField2");
contentPane.add(jTextField1, new XYConstraints(117, 61, 61, 45));
contentPane.add(jTextField2, new XYConstraints(119, 162, 63, 50));
x=0;
}
public void jTextField1_mouseClicked(MouseEvent e) {
if (x==1){jTextField2.setBackground(Color.blue);}
if (x==0){jTextField2.setBackground(Color.green);}
jTextField1.setEnabled(false);
x++;
}
}
class Cadre1_jTextField1_mouseAdapter extends MouseAdapter {
private Cadre1 adaptee;
Cadre1_jTextField1_mouseAdapter(Cadre1 adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent e) {
adaptee.jTextField1_mouseClicked(e);
}
} |
Partager