some simple questions

If I declare setBounds in mainprogram class I get the correct window but the submenu's are Blocked

(isnt displayed - the submens' work fine if I remove setbounds line but then JFrame is very small again)

I've tryed to enter setBounds() into the XXX class but that has no effect on the size of the window.

What am I doing wrong ?

class mainprogram

{

static XXX window;

public static void main(String args[])

{

window = new XXX("Program");

window.setBounds(40, 40, 400, 400);

}

}

class XXX extends JFrame implements ActionListener

{

public XXX(String Title)

{

//setBounds(40, 40, 400, 400);

setTitle(Title);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

// do menu stuff...

pack();

setVisible(true);

}

public void actionPerformed(ActionEvent e)

{

// code

}

// declare menu variables

}

And another thing, I've made an aboutdlg class that looks something like this :

import javax.swing.*;

import javax.swing.event.*;

import java.awt.event.*;

import java.awt.*;

class AboutDialog extends JFrame implements ActionListener

{

public AboutDialog(Frame parent, String title, String message)

{

super(parent, title, true);

// more code...

}

public void actionPerformed(ActionEvent e)

{

//code

}

}

but I get a 'cannot resolve symbol' error message. If I only do super(title); the program compiles ok. Please help me out here.

[1643 byte] By [laasunde] at [2008-2-11]
# 1
look at the api for pack() ( http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Window.html#pack() ) and you will understand why ypu should not call it after setBounds. As for the AboutDialog class, you are extending JFrame and not JDialog!
mavroprovato at 2007-6-29 > top of java,Security,Event Handling...
# 2
Thanks for the help.Another question, If I wanted to draw some 2d lines\circles inside the my XXX class (extends from JFrame) what component should I use to draw the lines and circles on ?
laasunde at 2007-6-29 > top of java,Security,Event Handling...
# 3
Use a JPanel and override paintComponent(). Look here for the details: http://java.sun.com/docs/books/tutorial/uiswing/14painting/index.htmlor here if you want to get more "fancy": http://java.sun.com/docs/books/tutorial/2d/index.html
mavroprovato at 2007-6-29 > top of java,Security,Event Handling...