JFrame

in my program i created many JFrames ,

in my main JFame there is a menu ,and inside are the submenus.when clicked on a particular submenu a certain JFrame should appear,is it possible and how?

privatevoid jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt){

memForm.setVisible(true);

// memForm.getRootPane();

memForm.toFront();

[532 byte] By [anya_aaa] at [2007-11-27 3:49:06]
# 1
If I get your point correctly, this should work...
MikePa at 2007-7-12 8:52:56 > top of Java-index,Desktop,Core GUI APIs...
# 2

well i fixed the error

and now for the buttons

i have different panels.when a particular panel is visible then according to that when the add button is clicked a certain form should appear.

private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {

if (isMemPanel )

{

memForm.setVisible(true);

memForm.toFront();

}

it is not working

anya_aaa at 2007-7-12 8:52:56 > top of Java-index,Desktop,Core GUI APIs...
# 3
isMemPanel initially is set to false
anya_aaa at 2007-7-12 8:52:56 > top of Java-index,Desktop,Core GUI APIs...
# 4
> isMemPanel initially is set to false Well then obviously it is not set to true before the method is called, so the panel is never showed... Look where you set the variable to true and check why this does not happen...
MikePa at 2007-7-12 8:52:56 > top of Java-index,Desktop,Core GUI APIs...
# 5

private boolean isMemPanel = false;////if this part i set everythingtrue then all forms appear all together when i press the add button

private boolean isEvePanel = false;

private boolean isActPanel = false;

private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {

if (isMemPanel )

{

isMemPanel = true;

memForm.setVisible(true);

memForm.toFront();

}

if (isEvePanel )

{

isEvePanel = true;

eveForm.setVisible(true);

eveForm.toFront();

}

if (isActPanel )

{

isActPanel = true;

actForm.setVisible(true);

actForm.toFront();

}

anya_aaa at 2007-7-12 8:52:56 > top of Java-index,Desktop,Core GUI APIs...
# 6

> if (isMemPanel )

> {

>isMemPanel = true;

> Form.setVisible(true);

>memForm.toFront();

> }

This is never going to work, since you only set isMemPanel to true if it is already true. First, this assignment is redundant (if isMemPanel is true, you don't need to set it again to true), and second, the if-block simply never gets executed, because you initialize isMemPanel to false.

Correct either the initial value of isMemPanel or the if contition, or the place where you update isMemPanel to true.

MikePa at 2007-7-12 8:52:56 > top of Java-index,Desktop,Core GUI APIs...
# 7

ok i did this now

private boolean isMemPanel = true;

private boolean isEvePanel = true;

private boolean isPosPanel = true;

if (isMemPanel )

{

memForm.setVisible(true);

memForm.toFront();

}

..........

all the frames open up together.

anya_aaa at 2007-7-12 8:52:56 > top of Java-index,Desktop,Core GUI APIs...