Newbie need help on JPanel graphics
hello gurus,
need your help. i'm so struggling on this program that i have to do. here's my scenario:
1) i have a frame that is divided by two JPanels, the left and right.
2) the right are subdivided by multiple jpanels and contains buttons and text.
when a button is pressed, it creates a text on the right panel.
3) the right works ok.
4) the left is "not" subdivided. it contains a couple of simple straight lines. and a clored background.
5) what i want to do is: to add additional lines to my left panel when a particular button is pressed from the right panel.
6) thats where im stuck. i'm played around with it but it either make my left drawings disappear or it makes a new panel. h
here's part of my code:
//this is in a different file.
public class LeftSide extends JPanel
{
public void paintComponent(Graphics g)
{
super.paintComponent(g);
setBackground(Color.GREEN);
}
public void paint(Graphics g)
{
super.paint(g);
g.drawLine(275, 50, 275, 500);
}
}
//this is also in a separate file.
private void createBodyGUIs()
{
setLayout(new BorderLayout());
biggerPanel.setLayout(new GridLayout(1,2));
add(biggerPanel, BorderLayout.CENTER);
LeftSide drawings = new LeftSide();
biggerPanel.add(drawings);
createRightColumnGUI(); //creates my goodies on the right side
}
thanks in advance!