Hello,

I've created a Button in one form. I've to make it work like, if I click on that button it should open another JFrame Form or JPanel form which I've created as addStock.java..

I don't know how to trigger this action..


Anyone can help me?

Regards,
Rahul.

Add this in the method you want to launch your JFrame in.

JFrame frame = new JFrame("Title");
frame.setDefaultClose(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.add(new JLabel("new window!"));

^ What if I've some JFrame created in separate .java files.


E.g. I've a file (Which is JPanel) called MainScreen.java, I've created a button on it. When a user clicks on that button, it should open a JFrame present in other .java file i.e. addStock.java

How to implement such situation?

i have the same problem can somebody help

satdude, this thread is over a year old. if you have a problem, please start your own thread and be a bit more specific.
in a lot of "I have the same problem" posts, it turns out that even though it "seems" related, it's not.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.