How to open a new frame from an existing frame?

I had create a form of student data.It has Grade,submitt,exit.

Now I want when I click Grades there should be a new window that asks me what grade should be entered.

The new grades should be calculated and show inside the old window.

My problem is I am not getting how to open a new window when the grade button hasbeen clicked so,that new grades can be entered.

[387 byte] By [maggiemaggiea] at [2007-11-26 18:55:40]
# 1

Are you talking about Swing?

JFrame frame = new JFrame("Grades");

frame.setVisible(true);

Maybe I don't understand your question? Are you asking how to open a window or how to handle a button event?

http://java.sun.com/docs/books/tutorial/uiswing/events/index.html

zadoka at 2007-7-9 20:34:05 > top of Java-index,Java Essentials,New To Java...
# 2
First of all, this should have been posted in the Swing forum. Look into a JOptionPane.
CaptainMorgan08a at 2007-7-9 20:34:05 > top of Java-index,Java Essentials,New To Java...
# 3
My question is how to open a new window with the click of a button.Example when grades have been clicked a new frames pops up which asks "student id and all"By mistake I poste dis message in this forum.Next time I will make sure to post on to the forum.
maggiemaggiea at 2007-7-9 20:34:05 > top of Java-index,Java Essentials,New To Java...
# 4
> My question is how to open a new window with the> click of a button.> Example when grades have been clicked a new frames> pops up which asks "student id and all"See the event handling link in my first reply.
zadoka at 2007-7-9 20:34:05 > top of Java-index,Java Essentials,New To Java...
# 5
Thankyou I will check that .
maggiemaggiea at 2007-7-9 20:34:05 > top of Java-index,Java Essentials,New To Java...
# 6

you can have a series of JOptionPanes which ask you for each piece of data,

for example:

String studentID = JOptionPAne.showInputDialog(null, "enter student Id");

//more of the same until you have each piece of data you want

//do whatever you were going to do with the studentId string

thats the simplest way of doing!

boblettoj99a at 2007-7-9 20:34:05 > top of Java-index,Java Essentials,New To Java...
# 7

> thats the simplest way of doing!

No, that is the laziest way of doing it.

How annoyed would the user gets if a new dialog popped up for each field they had to enter?

Instead use a JDialog or something similar to present all the fields to the user at once. You can make it a modal dialog if you need it to be.

zadoka at 2007-7-9 20:34:05 > top of Java-index,Java Essentials,New To Java...
# 8
I am really new to Java.How to show the JDialog?
maggiemaggiea at 2007-7-9 20:34:06 > top of Java-index,Java Essentials,New To Java...
# 9
> I am really new to Java.> How to show the JDialog?Use the API ( http://java.sun.com/j2se/1.5.0/docs/api/) and I think you are going to need this: http://java.sun.com/docs/books/tutorial/uiswing/index.html
zadoka at 2007-7-9 20:34:06 > top of Java-index,Java Essentials,New To Java...
# 10
Thankyou I will try that.
maggiemaggiea at 2007-7-9 20:34:06 > top of Java-index,Java Essentials,New To Java...