hi
my gui:
has:
1. toolbar
2. main panel divided into two panels (left and right)
depending on which button in toolbar is presed i would like to display diffrent panels in those two panels
i tried putting those diffrent panels into diffrent layers and then calling diffrent layers according to which button is presed
however it is not really working
i am posting my simplified code
any help would be appreciated
if there is better way to implement it please help
bbarbara okupna
public class mainClass extends JFrame implements ActionListener
{
JLayeredPane layeredPaneLeft;
JFrame frame;
JPanel leftPanelAddEdit;
public void createAndDisplayGui()
{
frame = new JFrame("HelloWorldSwing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1200,1000);
JPanel leftPanel = new JPanel();
leftPanel.setBorder(BorderFactory.createTitledBorder("sdsdsds"));
JToolBar toolBar = new JToolBar();
toolBar.add(Button("Add New"));
JPanel mainPanel = new JPanel();
leftPanelAddEdit = new JPanel();
leftPanelAddEdit.add(leftPanel);
layeredPaneLeft = new JLayeredPane();
layeredPaneLeft.add(leftPanelAddEdit, 1);
mainPanel.add(layeredPaneLeft);
frame.getContentPane().add(toolBar,BorderLayout.NORTH);
frame.getContentPane().add(layeredPaneLeft,BorderLayout.WEST);
frame.show();
}
public JButton Button(
String name)
{
JButton button = new JButton(name);
button.setActionCommand(name);
button.addActionListener(this);
return button;
}
public void actionPerformed(ActionEvent e) {
if ("Add New".equals(e.getActionCommand())) {
layeredPaneLeft.moveToFront(leftPanelAddEdit );
}
}
public static void main(String[] args)
{
mainClass f = new mainClass();
f.mainClassnn();
}
}