contentpane

Java: How can I modify the size of a JPanel in runtime?

别来无恙 提交于 2020-03-05 09:29:12
问题 I want to modify the size of the JPanel while the program is running, for example with a menu item. How can I reach it? Or how should I modify my program to get acces to the live JPanel in the content pane? Edit: If I make a contentpane for a gamefield that's 400x400 in the start as default. But what if I want to ad an option in the menu to change the size to 500x500, but without losing all of the content already in progress by the player. JFrame class: package me.test; import javax.swing

What should I use instead of FlowLayout()?

不打扰是莪最后的温柔 提交于 2019-12-24 01:47:22
问题 So, my JFrame is not turning out the way I want it to, because of the FlowLayout() but I don't know what else to use to fix this. It just makes my JButton fill the entire JFrame . Is there a way I can get FlowLayout() to apply my custom sizes and location for the JFrame components, or is there an alternative that could easily replace it? Here is my code: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MTGSAMPServerReference extends JFrame implements

getComponentAt() not finding a component?

江枫思渺然 提交于 2019-12-23 02:58:12
问题 I am using a JFrame to set up a game of Solitaire, using Cards that extend JLabel so that they can be dragged around the screen. However, one of my requirements is that I be able to double click a card and it snaps up to the 4 stacks of aces. This is not a problem. what is causing problems is that I set this up in an array, so that the aces would go to the spot that corresponds with the suit of the ace, then I have the spots rearrange if a card is dragged up there. If it is double clicked,

Change content pane on button press

一曲冷凌霜 提交于 2019-12-12 03:03:27
问题 I want a button to change the contentPane in a frame. An admin panel and a user panel in two different JPanel classes that gets called in a MainWindow class with a frame. My code looks as follows: The method the button calls: public void ChangeContent() throws Exception{ MainWindow mw = new MainWindow(); AdminUI admin = new AdminUI (); mw.frame.getContentPane().removeAll(); mw.frame.setContentPane(admin); mw.frame.revalidate(); mw.frame.repaint(); } This is the method being called in my

Content Panes in Java

非 Y 不嫁゛ 提交于 2019-12-11 03:49:35
问题 I am new to programming and was just studying JFrame etc , here i read ContentPane Like this "Components go in the "content pane", not directly in the frame." when i did search COntentpane i read containment hierarch that is pretty confusing for me to understand , Can some one please clear me the concept of ContentPane and containment hierarchy of Gui Component 回答1: I think this diagram describes distinctly what you want: 来源: https://stackoverflow.com/questions/13553315/content-panes-in-java

JavaFX navigationbar and contentpane

馋奶兔 提交于 2019-12-11 00:13:54
问题 I want to use JavaFX in my new project and want something like in the screenshot below. On the left site I need a navigation bar and on the right my content. So, I would use a VBox on the left side and maybe an AnchorPane on the right side (or better a ScrollPane). And when I click on the Button "Security" it should load my "Security" Scene on the right side. But how can I manage that. Did not find any solution for this. Thanks a lot 回答1: This is an exemplary implementation of such navigation