Hey guys. I have a program that has a jPanel, in which a graph will be drawn after taking some input via some textfields. I then have a reset button which clears the jPanel ready for another drawing to be done. After i hit reset it clears the bevled borded on the jPanel which it has, i would like this to stay there and only clear the contents in the jPanel, can this be done?
i previously used a jpanel.updateUI and a .removeAll but this doesnt fix the problem either.
This is the code for the reset button
private JButton getJButton_Reset() {
if (jButton_Reset == null) {
jButton_Reset = new JButton();
jButton_Reset.setBounds(new Rectangle(300, 525, 136, 31));
jButton_Reset.setText("RESET");
jButton_Reset.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
// Clear drawing area
((myJPanel) jPanel_drawingArea).clear(jPanel_drawingArea.getGraphics());
}
});
}
return jButton_Reset;
}
And this is the code for the jPanel, im not sure if its a problem within the 2 blocks so let me know wat i can do
private myJPanel getJPanel_drawingArea() {
if (jPanel_drawingArea == null) {
jPanel_drawingArea = new myJPanel();
jPanel_drawingArea.setLayout(null);
jPanel_drawingArea.setBounds(new Rectangle(330, 74, 301, 334));
jPanel_drawingArea.setBackground(new Color(238, 238, 238));
jPanel_drawingArea.setEnabled(false);
jPanel_drawingArea.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
jPanel_drawingArea.setPreferredSize(new Dimension(281, 155));
}
return jPanel_drawingArea;
}
Edited by: 806865 on 3/11/2010 16:37