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
| //Classe principale
public class EspFrame extends JFrame implements ChangeListener{
private JTabbedPane Onglets = null;
private int paintSelect = 1;
public EspFrame(){
super();
build();//On initialise notre fenêtre
}
private void build(){
setTitle("AT calcul"); //On donne un titre à l'application
setSize(650,700); //On donne une taille à notre fenêtre
setLocationRelativeTo(null); //On centre la fenêtre sur l'écran
setResizable(false); //On interdit la redimensionnement de la fenêtre
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //On dit à l'application de se fermer lors du clic sur la croix
setContentPane(getOnglets());
}
private JTabbedPane getOnglets()
{
if(Onglets== null)
{
try
{
Onglets = new JTabbedPane(JTabbedPane.TOP);
Onglets.addTab("Tole", null, getOngletTole(), null); //
Onglets.addTab("Lettres Découpées", null, getOngletLettre(), null); //
//Onglets.addTab("Onglet 3", null, getOnglet3(), null); //
Onglets.addChangeListener(this);
} catch (java.lang.Throwable e)
{
System.out.println(e);
// TODO: Something
}
}
return Onglets;
}
private JPanel getOngletLettre()
{
OngletLettre ongletL = new OngletLettre();
JPanel panel2 = ongletL.getPanel();
return panel2;
}
private JPanel getOngletTole(){
OngletTole ongletT = new OngletTole();
JPanel panel = ongletT.getPanel();
return panel;
}
public void stateChanged(ChangeEvent arg0) {
// TODO Auto-generated method stub
int index;
index = Onglets.getSelectedIndex();
String composant = new String("");
composant = Onglets.getTitleAt(index);
if(composant == "Tole")
{
paintSelect = 1;
repaint();
}
if(composant == "Lettres Découpées")
{
paintSelect = 2;
repaint();
}
}
public void paint(Graphics g) {
super.paint(g);
ATicon = new ImageIcon("C:\\Users\\publi auto\\Desktop\\Workspace\\ESP\\ESP\\ATCOULEUR.jpg");
ATlogo = ATicon.getImage();
g.drawImage(ATlogo, 500, 49, 125, 123, this);
if(paintSelect == 1)
{
g.drawRoundRect(21, 185, 150, 80, 5, 5);
g.drawRoundRect(222, 185, 360, 220, 5, 5);
g.drawRoundRect(42, 450, 325, 75, 5, 5);
g.drawRect(352, 275, 100, 50);
}
if(paintSelect == 2)
{
g.drawRect(150, 150, 150, 150);
}
}
}
//1ere sous classe
public class OngletTole extends EspFrame implements ActionListener, ItemListener, FocusListener {
public OngletTole()
{
}
public JPanel getPanel()
{
panel = new JPanel();
panel.setLayout(null);
super.repaint();
/* Tout plein de code */
}
}
//2eme sous classe
public class OngletLettre extends EspFrame implements ActionListener, ItemListener{
private JPanel panel;
private JLabel label;
private JTextField textFieldHauteurLettre;
public OngletLettre()
{
}
public JPanel getPanel()
{
panel = new JPanel();
//etc etc
}
} |
Partager