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?
Related
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.
This question already has answers here:
Remove default JFrame icon
(4 answers)
Closed 8 years ago.
How would I set the icon of a JFrame to be translucent/blank? I just don't want an icon.
JFrame frame = new JFrame();
frame.setIcon();
Set the opacity of jframe
JFrame testFrame=new JFrame ();
testFrame.setUndecorated(true); // Frame is required to set undecorated for changing shape and transparency
testFrame.setOpacity(0.3f);
Details in http://java-swings.blogspot.com/2014/09/java-swings-working-with-jframe.html
This question already has answers here:
How to make JTextArea Stick to the window
(2 answers)
Closed 8 years ago.
I am designing a frame in java swing, which has 2 buttons on the end as I resize the window the gap between buttons are spread and they go far.
Please provide me solution as i want buttons to be in the bottom corner and the frame is resized the spaces should not increase.
Put the buttons in a right aligned flow layout, then add the flow layout (the panel) to the page end of a border layout.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Making a JPanel manually resizable
I am doing a chat program with javaswing and I would like to create a separator that can adjust the dimension of 2 pannels "
The black line could reduce the height of the top panel and increase the bottom one.
How this is possiblle ? What layout sould I use ? Thank you very much.
Regards.
Try JSplitPane.
How to use SplitPanes?
Examples of JSplitPane
This question already has an answer here:
Closed 11 years ago.
Possible Duplicate:
How to add scrollbar to panel ?
I'm trying to draw some shapes on a jPanel, once the shapes reach the panel size, the rest of shapes are not visibles.
can I add a scrollbar to the panel in order to see the rest of the shapes?
Sure: wrap your JPanel into a JScrollPane (it takes any Component in its constructor)