Tengo mi Contenedor:
private JPanel getJContentPane() throws IOException{
if (jContentPane == null) {
jLabel = new JLabel();
jLabel.setFont(new Font("Cambria", Font.BOLD | Font.ITALIC, 36));
jLabel.setForeground(Color.white);
jLabel.setText("HISTORIA");
jLabel.setHorizontalTextPosition(JLabel.CENTER);
jLabel.setBounds(new Rectangle(311, 2, 158, 44));
jLabel.setVerticalTextPosition(JLabel.CENTER);
//paneles[0].add(jLabel);
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJPanel(), null);
jContentPane.add(getJPanel1(), null);
}
return jContentPane;
}
Tengo mi Panel Menu:
private JPanel getJPanel() throws IOException {
if (jPanel == null) {
jLabel1 = new JLabel();
jLabel1.setText("");
jLabel1.setBounds(new Rectangle(42, 356, 167, 121));
jLabel1.setIcon( new ImageIcon( "imagenes/gaucho2.png" ) );
jLabel7 = new JLabel();
jLabel7.setBounds(new Rectangle(30, 331, 127, 31));
jLabel7.setForeground(new Color(102, 51, 0));
jLabel7.setFont(new Font("Segoe Script", Font.BOLD | Font.ITALIC, 11));
jLabel7.setText("FACTURACION");
jLabel6 = new JLabel();
jLabel6.setBounds(new Rectangle(28, 269, 106, 29));
jLabel6.setForeground(new Color(102, 51, 0));
jLabel6.setFont(new Font("Segoe Script", Font.BOLD | Font.ITALIC, 12));
jLabel6.setText("PLATILLOS");
jLabel5 = new JLabel();
jLabel5.setBounds(new Rectangle(28, 91, 106, 31));
jLabel5.setForeground(new Color(102, 51, 0));
jLabel5.setFont(new Font("Segoe Script", Font.BOLD | Font.ITALIC, 12));
jLabel5.setText("COCINEROS");
jLabel5.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
//jPanel2.setVisible(true);
JOptionPane.showMessageDialog(null,"n Cuando doy click" +
"n Cambie el JPanel y quite el Actual");
Index2 view = new Index2();
JPanel mainWindow = null;
try {
//mainWindow = view.getJPanel2();
view.getJPanel1().setVisible(false);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mainWindow.setVisible(true);
}
});
jLabel4 = new JLabel();
jLabel4.setBounds(new Rectangle(28, 151, 105, 30));
jLabel4.setForeground(new Color(102, 51, 0));
jLabel4.setFont(new Font("Segoe Script", Font.BOLD | Font.ITALIC, 12));
jLabel4.setText("PEDIDOS");
jLabel3 = new JLabel();
jLabel3.setBounds(new Rectangle(28, 212, 149, 30));
jLabel3.setForeground(new Color(102, 51, 0));
jLabel3.setFont(new Font("Segoe Script", Font.BOLD | Font.ITALIC, 11));
jLabel3.setText("RESERVACIONES");
jLabel2 = new JLabel();
jLabel2.setBounds(new Rectangle(27, 30, 107, 31));
jLabel2.setForeground(new Color(102, 51, 0));
jLabel2.setFont(new Font("Segoe Script", Font.BOLD | Font.ITALIC, 12));
jLabel2.setText("HOME");
jPanel = new JPanel();
jPanel.setLayout(null);
jPanel.setBounds(new Rectangle(0, 0, 153, 479));
//jPanel.setBorder(BorderFactory.createLineBorder(new Color(102, 51, 0), 2));
jPanel.add(jLabel2, null);
jPanel.add(jLabel3, null);
jPanel.add(jLabel4, null);
jPanel.add(jLabel5, null);
jPanel.add(jLabel6, null);
jPanel.add(jLabel7, null);
}
File f=new File("imagenes/fondo2.png");
BufferedImage tmp= ImageIO.read(f);
Bordes fondo= new Bordes(tmp);
this.jPanel.setBorder(fondo);
jPanel.add(jLabel1, null);
return jPanel;
}
Y tengo el Panel del Label Home:
private JPanel getJPanel1() throws IOException {
if (jPanel1 == null) {
jPanel1 = new JPanel();
jPanel1.setLayout(null);
jPanel1.setBounds(new Rectangle(153, 0, 505, 479));
jPanel1.add(getJScrollPane(), null);
jPanel1.add(jLabel, null);
}
File f=new File("imagenes/fondo_restaurante.jpg");
BufferedImage tmp= ImageIO.read(f);
Bordes fondo= new Bordes(tmp);
this.jPanel1.setBorder(fondo);
jPanel1.add(getJPanel21(), null);
jPanel1.add(getJPanel31(), null);
return jPanel1;
}
Como hacer que cuando clickeo otro label aparesca otro panel y quiere el del Home?