JFrame

i have created many JFrames in my program.on clicking a button i want to display a certain JFrame.is it possible to do it?what is the keyword to display the JFrame. ?
[173 byte] By [anya_aaa] at [2007-11-27 3:48:47]
# 1
Go back to basics. JFrames are too advanced for you.
-Kayaman-a at 2007-7-12 8:52:40 > top of Java-index,Java Essentials,Java Programming...
# 2
The closest you get to a keyword for showing a JFrame would be "new".1) Why didn't you post in the Swing section?2) Use setVisible()3) Learn to read the API docs and look at tutorials.
CeciNEstPasUnProgrammeura at 2007-7-12 8:52:40 > top of Java-index,Java Essentials,Java Programming...
# 3

Use the Window method setVisible(true).

http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html

http://java.sun.com/javase/6/docs/api/java/awt/Window.html#setVisible(boolean)

Note: There is a Swing forum (http://forum.java.sun.com/forum.jspa?forumID=57) which is the best place for questions related to Swing.

pbrockway2a at 2007-7-12 8:52:40 > top of Java-index,Java Essentials,Java Programming...
# 4
i used setVisible(), it is not working,i even then put toFront(); nothing is working
anya_aaa at 2007-7-12 8:52:40 > top of Java-index,Java Essentials,Java Programming...
# 5
What does "not working" mean and where is your short, formatted code example?
CeciNEstPasUnProgrammeura at 2007-7-12 8:52:40 > top of Java-index,Java Essentials,Java Programming...
# 6

the frame is not displaying.

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

memForm.setVisible(true);

// memForm.getRootPane();

memForm.toFront();

memForm is the object for memberForm(which is a frame )created thru netBeans.

anya_aaa at 2007-7-12 8:52:40 > top of Java-index,Java Essentials,Java Programming...
# 7
Is that code actually executed? Is memForm initialized?
CeciNEstPasUnProgrammeura at 2007-7-12 8:52:40 > top of Java-index,Java Essentials,Java Programming...
# 8

alright i fixed it.

but there is another problem

when i close the frame of Memberform,the whole application closses.

how do i fix this?

and another doubt

in member form i have a label which has to show the current date when this form is loaded ,it is not displaying.

public void todayDate()

{

Date now = new Date();

DateFormat df1 = DateFormat.getDateInstance(DateFormat.SHORT);

String s1 = df1.format(now);

mtodaydate_form.setText(s1);

}

anya_aaa at 2007-7-12 8:52:40 > top of Java-index,Java Essentials,Java Programming...
# 9

> when i close the frame of Memberform,the whole application closses.

Make sure the frame's default close operation is not set to EXIT_ON_CLOSE. The default behaviour is to simply hide the frame, so you must have changed that or be calling System.exit() somewhere. (If you are closing the frame programmatcally, you may be closing the wrong frame!)

> in member form i have a label which has to show the current date when this form is

> loaded ,it is not displaying.

As Ceci suggested for your event handler, this method may not be being invoked. Check this by adding - at the start of todayDate() -System.out.println("Ding!");

What is mtodaydate_form? If it is not a JLabel, check that whatever it is has a setText() method that sets the label's text. If it is a JLabel, check that it is the same one that is on the form.

pbrockway2a at 2007-7-12 8:52:40 > top of Java-index,Java Essentials,Java Programming...
# 10
mtodaydate_form is the name of the label and it is correct.the form is loading but the date is not.
anya_aaa at 2007-7-12 8:52:40 > top of Java-index,Java Essentials,Java Programming...