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
| public class Application extends JFrame {
public JPanel fenetre;
public JPanel scroll;
public JLabel lien1;
public JLabel lien2;
public JLabel lien3;
public JLabel lien4;
public JLabel lien5;
public JTextArea text1;
public JTextArea text2;
public JTextArea text3;
public JTextArea text4;
public JTextArea text5;
public SpringLayout spl;
EcouteurLabel listener = new EcouteurLabel();
private JScrollPane barre;
public void Init()
{
setSize(300,300);
spl = new SpringLayout();
fenetre = new JPanel();
fenetre.setLayout(new BorderLayout());
scroll = new JPanel();
//fenetre.setBounds(300,300,600,800);
text1 = new JTextArea(10,40);
text2 = new JTextArea(10,40);
text3 = new JTextArea(10,40);
text4 = new JTextArea(10,40);
text5 = new JTextArea(10,40);
text1.setVisible(false);
text2.setVisible(false);
text3.setVisible(false);
text4.setVisible(false);
text5.setVisible(false);
lien1 = new JLabel("<html><u> voir compte rendu </u></html>");
lien2 = new JLabel("<html><u> voir compte rendu 2 </u></html>");
lien3 = new JLabel("<html><u> voir compte rendu 3 </u></html>");
lien4 = new JLabel("<html><u> voir compte rendu 4 </u></html>");
lien5 = new JLabel("<html><u> voir compte rendu 5 </u></html>");
lien1.setForeground(Color.BLUE);
lien2.setForeground(Color.BLUE);
lien3.setForeground(Color.BLUE);
lien4.setForeground(Color.BLUE);
lien5.setForeground(Color.BLUE);
lien1.addMouseListener(listener);
lien2.addMouseListener(listener);
lien3.addMouseListener(listener);
lien4.addMouseListener(listener);
lien5.addMouseListener(listener);
/**
* Declaration des springLayout
*/
spl.putConstraint(SpringLayout.NORTH, lien1, 15, SpringLayout.NORTH, fenetre);
spl.putConstraint(SpringLayout.WEST, lien1, 30, SpringLayout.WEST, fenetre);
spl.putConstraint(SpringLayout.NORTH, text1, 5, SpringLayout.SOUTH, lien1);
spl.putConstraint(SpringLayout.WEST, text1, 30, SpringLayout.WEST, fenetre);
spl.putConstraint(SpringLayout.NORTH,lien2, 5, SpringLayout.SOUTH,lien1);
spl.putConstraint(SpringLayout.WEST,lien2, 30, SpringLayout.WEST,fenetre);
spl.putConstraint(SpringLayout.NORTH, text2, 5, SpringLayout.SOUTH, lien2);
spl.putConstraint(SpringLayout.WEST, text2, 30, SpringLayout.WEST, fenetre);
spl.putConstraint(SpringLayout.NORTH,lien3, 5, SpringLayout.SOUTH,lien2);
spl.putConstraint(SpringLayout.WEST,lien3, 30, SpringLayout.WEST,fenetre);
spl.putConstraint(SpringLayout.NORTH, text3, 5, SpringLayout.SOUTH, lien3);
spl.putConstraint(SpringLayout.WEST, text3, 30, SpringLayout.WEST, fenetre);
spl.putConstraint(SpringLayout.NORTH,lien4, 5, SpringLayout.SOUTH,lien3);
spl.putConstraint(SpringLayout.WEST,lien4, 30, SpringLayout.WEST,fenetre);
spl.putConstraint(SpringLayout.NORTH, text4, 5, SpringLayout.SOUTH, lien4);
spl.putConstraint(SpringLayout.WEST, text4, 30, SpringLayout.WEST, fenetre);
spl.putConstraint(SpringLayout.NORTH,lien5, 5, SpringLayout.SOUTH,lien4);
spl.putConstraint(SpringLayout.WEST,lien5, 30, SpringLayout.WEST,fenetre);
spl.putConstraint(SpringLayout.NORTH, text5, 5, SpringLayout.SOUTH, lien5);
spl.putConstraint(SpringLayout.WEST, text5, 30, SpringLayout.WEST, fenetre);
scroll.add(lien1);
scroll.add(lien2);
scroll.add(lien3);
scroll.add(lien4);
scroll.add(lien5);
scroll.add(text1);
scroll.add(text2);
scroll.add(text3);
scroll.add(text4);
scroll.add(text5);
scroll.setLayout(spl);
getContentPane().add(fenetre);
barre = new JScrollPane();
barre.getViewport().add(scroll);
fenetre.add(barre,BorderLayout.CENTER);
this.setVisible(true);
} |
Partager