i have a menu bar, when i run the code the first time everything is fine. If i click on the screen i print a Circle or a Square, store the shape in an arraylist and repaint the frame. When the frame repaints the menuBar gets painted again under the orignal.
Any ideas?
[code=JAVA]
public class X2Frame extends JFrame {
private JMenuBar menuBar = new JMenuBar();
private JMenu menuTool = new JMenu();
private JMenuItem menuToolSquare = new JMenuItem();
private JMenuItem menuToolCircle = new JMenuItem();
private BorderLayout borderLayout1 = new BorderLayout();
private CanvasPanel canvasPanel = new CanvasPanel();
public X2Frame() {
try {
jbInit();
} catch (Exception e) {
e.printStackTra ce();
}
}
private void jbInit() throws Exception {
this.setJMenuBa r( menuBar );
this.getContent Pane().setLayou t(borderLayout1 );
this.setSize( new Dimension(400, 300) );
menuTool.setTex t("Tool");
menuTool.setMne monic('T');
menuToolSquare. setText("Square ");
menuToolSquare. setMnemonic('S' );
menuToolSquare. addActionListen er( new ActionListener( ) { public void actionPerformed ( ActionEvent e ) {
menuToolSquare_ ActionPerformed (e);
} } );
menuToolCircle. setText("Circle ");
menuToolCircle. setMnemonic('C' );
menuToolCircle. addActionListen er(new ActionListener( ) {
public void actionPerformed (ActionEvent e) {
menuToolCircle_ actionPerformed (e);
}
});
menuTool.add( menuToolSquare );
menuTool.add(me nuToolCircle);
menuBar.add(men uTool);
this.getContent Pane().add(canv asPanel, BorderLayout.CE NTER);
}
[/code]
Any ideas?
[code=JAVA]
public class X2Frame extends JFrame {
private JMenuBar menuBar = new JMenuBar();
private JMenu menuTool = new JMenu();
private JMenuItem menuToolSquare = new JMenuItem();
private JMenuItem menuToolCircle = new JMenuItem();
private BorderLayout borderLayout1 = new BorderLayout();
private CanvasPanel canvasPanel = new CanvasPanel();
public X2Frame() {
try {
jbInit();
} catch (Exception e) {
e.printStackTra ce();
}
}
private void jbInit() throws Exception {
this.setJMenuBa r( menuBar );
this.getContent Pane().setLayou t(borderLayout1 );
this.setSize( new Dimension(400, 300) );
menuTool.setTex t("Tool");
menuTool.setMne monic('T');
menuToolSquare. setText("Square ");
menuToolSquare. setMnemonic('S' );
menuToolSquare. addActionListen er( new ActionListener( ) { public void actionPerformed ( ActionEvent e ) {
menuToolSquare_ ActionPerformed (e);
} } );
menuToolCircle. setText("Circle ");
menuToolCircle. setMnemonic('C' );
menuToolCircle. addActionListen er(new ActionListener( ) {
public void actionPerformed (ActionEvent e) {
menuToolCircle_ actionPerformed (e);
}
});
menuTool.add( menuToolSquare );
menuTool.add(me nuToolCircle);
menuBar.add(men uTool);
this.getContent Pane().add(canv asPanel, BorderLayout.CE NTER);
}
[/code]
Comment