Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

jPanel clearing with a button, but then removing its border = no good

809868Nov 3 2010 — edited Nov 4 2010
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 2 2010
Added on Nov 3 2010
6 comments
637 views