layout-manager

Adding JPanel to JScrollPane

谁说胖子不能爱 提交于 2019-12-31 04:02:34
问题 I have a gui which has a Panel that contains a sequence of labels and TextFields and uses a spring layout(this is the mainPanel) and another Panel that just contains a button(buttonPanel). I am trying to make my mainPanel to have a vertical scrollbar as well. I would like to implement my GUI such that within the JFrame I have 2 panels. The mainPanel appears on the top of the frame and the buttonPanel appears below the mainPanel. My problem is I am not able to make the Panels appear such that

Alternative solution to null layout manager when absolute positioning is needed

不羁岁月 提交于 2019-12-31 01:44:12
问题 Few months ago i read this Swing tutorial http://zetcode.com/tutorials/javaswingtutorial/resizablecomponent/ for understanding how implementing resizable components inside Swing. The tutorial tells about using a null LayoutManager in order to have the possibility of absolute positioning child components. In a discussion relative to another subject @Andrew Thompson pointed out that using null layout is a bad idea. This article http://download.oracle.com/javase/tutorial/uiswing/layout/none.html

Removing space around buttons in GridBagLayout

落爺英雄遲暮 提交于 2019-12-30 18:29:28
问题 I have this vexing source written to demonstrate a layout for a game screen mentioned on another question. It puts buttons (or labels, choosable at start-up) into a GridBagLayout . If you choose to not use buttons when prompted (before the GUI appears) the entire GUI is nice and compact with no gaps. But if you choose to use buttons it will (if your set up is like mine) look something like this.. Note the red horizontal lines. That is the BG color of the panel showing through. Those lines are

constraint must be a string (or null)

▼魔方 西西 提交于 2019-12-30 07:46:08
问题 I can not find the error to save my life. The error is "constraint must be a string (or null)" I dont know why it is giving me this error, I have to be missing something simple. I tried adding for example: dataPane = new JPanel(new GridBagLayout()); to all my panels and nothing. I am trying to add a panel (2) to the extended panel. here is my code: public class SearchFlight extends JPanel { //giving names to the components\\\ private JRadioButton oneWay; private JRadioButton roundTrip;

CardLayout, switch between JPanels by ButtonClick

泪湿孤枕 提交于 2019-12-30 07:10:27
问题 I want to switch between JPanels by clicking buttons on the JPanels. For example: I have a JPanel sim with a JButton simknop and a JPanel help with JButton helpknop I want to switch between these 2 JPanels by clicking the buttons. When I click JButton simknop JPanel help should appear and when I click JButton help JPanel sim should appear. Below you can find the different classes: main.java public class main extends JFrame { JPanel cards; sim sim; help help; public main() { this.setSize(1024

How to use Java Swing layout manager to make this GUI?

拥有回忆 提交于 2019-12-29 07:56:31
问题 I am trying to figure out what layouts should be used on the JFrame to get this layout accomplished. I am trying to code the GUI rather than use visual GUI-making tools. So far I was only able to get it to look like this: This is the source code for the GUI above: http://pastebin.com/s06pareG /** * Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.setBounds(100, 100, 450, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //frame

How to use MigLayout? [closed]

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-29 03:34:48
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I read some information about Java layout managers and the recommendation was MigLayout. My problem is, that I didn't found any tutorial or easy step-by-step documentation. So I want to know how this all works, but I don't know how. Hope, it's not to trivial. Thanks in advance, guerda 回答1: Bombe is right... and

Working with layout managers

别来无恙 提交于 2019-12-25 18:33:49
问题 I'm trying to make a kitchen display system using a FlowLayout and I'm trying to figure out a way to add another panel on the 2nd row when the first row is already full. The width of the GUI will change according to user preference. When wider, it should show more of the components per row. 回答1: Approach - Variable width with WrapLayout The GridLayout solution presumes the GUI requires 6 components per row. For as many cols as needed to fill the width, & then show the components in as many

Working with layout managers

假如想象 提交于 2019-12-25 18:33:37
问题 I'm trying to make a kitchen display system using a FlowLayout and I'm trying to figure out a way to add another panel on the 2nd row when the first row is already full. The width of the GUI will change according to user preference. When wider, it should show more of the components per row. 回答1: Approach - Variable width with WrapLayout The GridLayout solution presumes the GUI requires 6 components per row. For as many cols as needed to fill the width, & then show the components in as many

GridBagLayout fix space set by weight x/y

三世轮回 提交于 2019-12-25 16:59:39
问题 I have a frame with the following layout of 3 JPanels. ---------------------------- | | | | l | | | e | //toppanel | | f | | | t |----------------------| | p | | | n | //bottompanel | | l | | | | | ---------------------------- I achieved this with the use of GridBagLayout This is the code for that layout public class UITests extends JFrame{ public UITests(){ setLayout(new GridBagLayout()); //the three main panels JPanel leftPanel = new JPanel(); JPanel topPanel = new JPanel(); JPanel