netBean adding panel from other class to jframe [duplicate] - java

This question already has answers here:
adding components dynamically in a JPanel
(2 answers)
Dynamically Add Components to a JDialog
(3 answers)
Closed 4 years ago.
I just start learning java using netbean. I am now have one jFrame containing a jPanel1, and one jPanel2 class.
I want to add jPanel2 into jPanel1 in jFrame in certain condition. So i've tried
if(split){
jPanel2 = new jPanel2();
jPanel1.add(jPanel2);
Panel1.setVisible(true);
}
I have searched over the internet and found out sort of methods to do this is using GridLayout,CardLayout or something . But i still can not do it like those tutorial even i did the same thing.Thanks so much , please don't mind for asking stupid question.

Related

Java swing easy one but I don't know it [duplicate]

This question already has answers here:
Disable JButton focus border
(5 answers)
Closed 4 years ago.
i'm new there. My first issue:
When i start my GUI java swing application in Window Builder, first object is always selected
and when i click anything (button or anything) it's show like it's clicked and i don't want it to show. What command for this?
You should use this:
button.setFocusPainted(false);
java, swing, awt, remove focus from all objects

How to add a ActionListener to the close button [duplicate]

This question already has answers here:
How to capture a JFrame's close button click event?
(6 answers)
Closed 8 years ago.
How do you add a ActionListener to the close button (not a JButton the button on the top-right)?
See Closing an Application for a discussion on this topic and a couple of solutions.
Basically you need to do two things:
Use the setDefaultCloseOperation(...) of the frame.
Add a WindowListener to the frame

java changing JPanel on JFrame [duplicate]

This question already has answers here:
How do I change JPanel inside a JFrame on the fly?
(14 answers)
Clear components of JFrame and add new components
(2 answers)
Closed 8 years ago.
I am working on a 15 puzzle.
I need to change the JPanel in the JFrame for a new game.
The reason is that some games have 16 buttons while others have 9 or 25. Sometimes the buttons have a number, but sometimes they have pieces of a picture.
I would like to set up my JPanel, then set it into the JFrame.
The only way that I have been able to achieve this so far is to create a new JFrame, but that outputs a new window.
Is it possible to change the JPanel in the JFrame in java?

Disabling other action while a JFrame is open [duplicate]

This question already has answers here:
Disable JFrame when a new JFrame is opened
(2 answers)
Closed 10 years ago.
I was wondering if it was possible to disable all other action when a JFrame is opened in Java.
Just like this?
Is there easy code for this?
This has been asked many times and the answer is always the same: use a modal JDialog or JOptionPane (which is a version of a modal JDialog), not another JFrame.
For example, please check out mKorbel's answer here.

Inserting logo in the corner of JFrame [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to change JFrame Icon
I want to put Logo or some icon on the corner of window in my Java desktop application.
How to do that?
Use setIconImage(ImageIcon) for this.

Categories

Resources