Questions tagged [boxlayout]

BoxLayout is a Java Swing layout manager that allows multiple components to be laid out either vertically or horizontally.

BoxLayout is a layout manager that allows multiple components to be laid out either vertically or horizontally. The components will not wrap so, for example, a vertical arrangement of components will stay vertically arranged when the frame is resized.

enter image description here

Nesting multiple panels with different combinations of horizontal and vertical gives an effect similar to GridBagLayout, without the complexity. The diagram shows two panels arranged horizontally, each of which contains 3 components arranged vertically.

For examples and more details refer to How to Use BoxLayout tutorial.

347 questions
-1
votes
2 answers

How to set layout in java GUI swing?

I am trying to create a register form for my application(school project), I wanted to set the layout to BoxLayout but the Jtextfields and combo box is having issue as you can see below, does this issue relates to setSize() or is it something I am…
Asaranow
  • 19
  • 5
-1
votes
1 answer

How to set position to JComponent in BoxLayout?

I want to use 2 JPanel as panel and panel_1. I want to add image automatically to panel using JLabel and also add JButton to panel_1. How can I resize button according to the image which is above the button? public class Testing extends JFrame { …
Metin Bulak
  • 537
  • 4
  • 8
  • 30
-1
votes
2 answers

JFrame not showing after isVisible() called, no errors

I am creating a simple Calculator for my CS class, I have finished all of the math and I'm trying to format my JFrame, I made a background panel, added a BoxLayout to it and then added my 3 other panels and then added the background panel to the…
CeilingSystems
  • 167
  • 1
  • 9
-1
votes
1 answer

The added JPanel only shows up when added from a different method?

I am trying to create a program which first adds rows of JPanel. After a JPanel has been added, you can then add squares by clicking "Add Horizontal" and specifying the row index (from 0) to which a square should be added. I'm trying to add my…
libby
  • 585
  • 4
  • 15
-1
votes
1 answer

Align to the limit Components in a JPanel Swing

I need to totally align components to the JTextArea components, I am currently using a BoxLayout and I already used the setAlignmentX and setHorizontalAlignment to LEFT but it's not working. Here I upload an image to make clearer what I mean. For…
Marc43
  • 491
  • 2
  • 6
  • 15
-1
votes
2 answers

Avoid blank space between cells when resize

I couldn't find anything that would apply to my problem, neither the solution I tested worked. So, I'm developing a UI for a course and when I resize the window there's a huge blank space that's created in between the cells, instead of the end as…
Tocchetto
  • 166
  • 1
  • 12
-1
votes
1 answer

Why is the vertical gap of GridLayout keeping on increasing?

I'm new to JAVA and GUI. I'm making a GUI screen for my project. I made a GridLayout with 2 rows. First row has a FlowLayout and 2nd row has a BoxLayout. The panel with the FlowLayout will be constant throughout the program, whereas the panel with…
Arindam
  • 163
  • 1
  • 13
-1
votes
1 answer

Trouble Formatting BoxLayout

I want to layout 6 components, vertically aligned in one column. In addition, I want a blank space of 200 pixels before the first component in the column. I have the following code: public class MongoMusicApplet extends JApplet{ //*****main…
user50210
  • 93
  • 2
  • 10
-1
votes
1 answer

adding JPanels left to right AND keyboard input

1. I am having trouble adding my JPanels in sequence. Essentially, the user will select between 1 and 4 "drone" objects to run simultaneously. If they select two, the layout should add the 2 "drones" panels to the JFrame left to right. the current…
fox'
  • 13
  • 4
-1
votes
1 answer

Creating a space for Graphics2D drawings

I want to draw a simple board made of Graphics2D rectangles but I also want to have one JButton under this board. I know the exact dimensions of this board in pixels and I was trying to deal with getContentPane() method and BoxLayout, like…
Android developer
  • 1,272
  • 1
  • 12
  • 17
-1
votes
1 answer

Are there any constants in Swing to indicate a big enough(or ignored) size of dimension(height or width)?

I'm new to java, and here's a question I can't find the answer in Java doc and Google. In my case, I want wanna restrict the height(just height) of a panel(which nested in a panel with BoxLayout), so I add codes like below: p2.setMaximumSize(new…
user1918908
-1
votes
2 answers

Swing : BoxLayout fill the entire JPanel

I am adding list of JTree items inside JPanel. I want the parent JPanel to have BoxLayout so that the tree can be added vertically one after another. The parent JPanel is initialized using : holder.setLayout(new BoxLayout(holder,…
ayush
  • 14,350
  • 11
  • 53
  • 100
-1
votes
3 answers

Nested layouts - FlowLayout inside BoxLayout

I have a controlPanel (BoxLayout): controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.Y_AXIS)); Now I build two FlowLayout and add them to the contolPanel panel: JPanel fromDatePanel = new JPanel(new FlowLayout()); JPanel untilDatePanel =…
Maroun
  • 94,125
  • 30
  • 188
  • 241
-2
votes
1 answer

JButtons are not appearing at the West side of the application

When I tried to run my program, it is always an error. The 5 JButtons are not appearing at the west (left) of the MainFrame. I used the BoxLayout for the JButtons so that it can be displayed from top to bottom and called the FirstPanel class to the…
-2
votes
1 answer

Using BoxLayout to resize JPanels in GUI

I currently have this code I am working with: this.getContentPane().add(wwjPanel, BorderLayout.EAST); if (includeLayerPanel) { this.controlPanel = new JPanel(); controlPanel.setLayout(new…
MuffinMan1042
  • 75
  • 1
  • 11
1 2 3
23
24