All Questions
Tagged with grid-layout layout-manager
196
questions
16
votes
1
answer
30k
views
Java Swing GridLayout "Cell span"?
Is there a way to make a single element in a Grid layout take up more than 1 location in a grid. Example: I want to create a textbox that takes up an entire grid row, is there some way to do this?
13
votes
1
answer
83k
views
Create a Chess board with JPanel [duplicate]
I have a simple Chess board in a JPanel with GridLayout(8,8) as layout manager.
I am trying to add panels for the fields' column name and row number.
Right now I've created another panel with ...
10
votes
3
answers
31k
views
Is there any way to force GridLayout to leave empty cells?
I have a JTabbedPane with 2 JPanels set to GridLayout(13, 11). The first JPanel has enough of the cells filled out that it leaves the empty cells.
The second JPanel has significantly fewer cells ...
6
votes
5
answers
8k
views
How to fill a GridLayout top-to-bottom and then left-to-right?
The default behavior of a GridLayout is that the components are filled row by row, and from left to right. I wonder if I can use it so that the components are filled by columns (from left to right)? ...
6
votes
1
answer
4k
views
Dynamic GridLayout with fixed size
Guidance required..
Would like to achieve something like the image below whereby the child panel stays the same size but contains up to 4 components. I realize I can achieve this by changing the ...
5
votes
1
answer
5k
views
Swing doesn't respect my GridLayout Rows x Columns definition. How to fix?
I have been trying to resolve this without success.
How to make JPanel p respect the defined GridLayout?
All I get is the first row containing 3 panels but not 4 as I've told Java to perform.
What's ...
5
votes
2
answers
363
views
Remove huge gaps between check boxes on panel
Its pretty basic UI, but I cannot setup the JCheckBox buttons so that they are placed immediately after one another (vertically) without any spacing. How would I reduce the spacing seen below?
...
5
votes
1
answer
3k
views
Creating a contact list program
I am coding a contact list application in eclipse using Java Swing.
How can I get a simple table layout that contains just columns and rows?
I don't want row or column labels.
Something like this:
...
4
votes
3
answers
4k
views
GridLayout not honoring the number of rows I want per column
I have the following,
GridLayout layout = new GridLayout(4, 0);
In the event that I have 5 items, this will create 2 columns, where the first contains 3 rows and the second contains 2 rows. This is ...
4
votes
3
answers
4k
views
How to use GridBagLayout and GridLayout for optimum alignment?
I wanted to try out GridBagLayout in my program but sadly I don't clearly understand it, I tried implementing GridLayout also but both give me different problems. Let me show you the code and the ...
4
votes
1
answer
4k
views
How to vertically fill a JPanel with GridLayout or GridBagLayout?
I want to fill a JPanel whose layout is GridLayout, if it's not possible using GridLayout i would like to know if using GridBagLayout is possible and how?
Here's the code:
public class ...
4
votes
3
answers
708
views
How to reduce the space between the 3 swing checkboxes?
I want to reduce the size between the components with in the Formatting group (left side on the image). How to do this?
JPanel formattingGroup = createGroupWithName("Formatting");
...
3
votes
5
answers
594
views
Java Layout Manager
I use a grid layout of 2 rows and 6 column. the first column is a label and second is combo. My problem is
according to the size of the label the combo box size also increases.
i want a stable ...
3
votes
4
answers
9k
views
Best Swing Layout for 2-dimensional grid of buttons?
I'm trying to create a JDialog like the Symbol dialog in Microsoft Word that you get by choosing Symbol... from the Insert menu. Basically, it's an n x m (n and m are not known until runtime) grid of ...
3
votes
1
answer
10k
views
JLabel in GridLayout
How to add JLabel out of the GridLayout? I have an 8x8 grid layout.
Container content = getContentPane();
content.setLayout(new GridLayout(8, 8,2,2));
for (int f = 0; f < btnArr.length; f++){
...
3
votes
2
answers
2k
views
ExpandBar works incorrectly with GridLayout
I'm creating an application in Java and SWT and I have a problem. I want to put ExpandBar into GridLayout. Everything is ok while I don't collapse the expand bar. When I do it, it collpases normally, ...
3
votes
1
answer
6k
views
Button is filling up the entire cell in GridLayout, Java
I'm a beginner and doing my homework. My button is filling up the whole cell in the gridLayout. I've read about GridBagLayout but my book doesn't mention anything about it so I think there's just an ...
3
votes
1
answer
3k
views
Forcing JPanel with GridLayout to update / resize
I have a frame with a BorderLayout. In the BorderLayout's center there is a JPanel with a GridLayout. Sometimes I have to change this inner JPanel's GridLayout from 9x9 to 4x4 (or 16x16). But ...
3
votes
1
answer
487
views
Border Layout Conflicting with Grid Layout
I have 3 JPanel components. Panel 1 is set to BorderLayout.NORTH, panel 2 is set to BorderLayout.CENTER and panel 3 is set to BorderLayout.SOUTH.
Now panel 1 has a GridLayout(1,2) and panel 2 also ...
2
votes
2
answers
419
views
Specify the number of grids in a GridBagLayout
GridLayout creates a grid matrix whose dimension (no of rows and columns) is customizable using two int parameters that is takes as part of its constructor.
Why don't we have such a similar option ...
2
votes
2
answers
12k
views
Using GridLayout - how to set JPanel size?
I'm using GridLayout and all my panels have the same size, how can I change their size?
I tried all functions getPreferred/Minimum/MaximumSize which makes that, and nothing.
I still want to stay with ...
2
votes
1
answer
3k
views
How do you stretch a JPanel within a JPanel?
Here is an image of what I'm working with:
And Here is what I would like to acheive:
As you can see, I have an JPanel Outer with a GridLayout of (3, 1)...i.e. 3 row and 1 column
I added 3 JPanels ...
2
votes
2
answers
1k
views
How can I implement Flowlayout in java to make it so that my GridLayout can have a different sized button?
I programmed a calculator in java using a GridLayout method. I did not consider the fact that it would not make it possible to set different sized buttons. Therefore I am trying to find a work around ...
2
votes
2
answers
1k
views
Issues with GridLayout not working
I am trying to create a 2x2 grid out of 4 buttons for a membership program I am developing. The issue I'm having is that regardless of what I do, it just shows up as a 1x4 grid. Code is as follows.
...
2
votes
3
answers
13k
views
Java: Centering a component inside GridLayout
I have the following java code that creates a basic window:
JPanel panelCampos, panelBoton;
JLabel labelIdCedula, labelContrasena;
JTextField textFieldIdCedula, textFieldContrasena;
JButton ...
2
votes
1
answer
5k
views
Resizing the panels on gridlayout
I'm trying to make a simple ui game with Java swing. Here is my target layout design: (all panels have same width, excuse my drawing)
I need 3 small height panel and 1 large panel
I used GridLayout ...
2
votes
1
answer
1k
views
Adding a JLabel above a GridLayout [closed]
I'm having a hard time with containing a GridLayout so that adding a JLabel above it won't throw off anything. I've tried a few different things but still cant seem to get it aligned right.
It's a ...
2
votes
2
answers
596
views
Offsetting GUI grid of gifs in java?
so I'm trying to make a battleship game, and I implemented a 10x10 grid containing gifs of some pixelated water. Now, what I'm trying to do is offset the grid one cell down and to the right so I can ...
2
votes
2
answers
4k
views
Java Swing Gridlayout: Accessing Specific Coordinate
I'm creating a Java swing GUI and I have formatted a JPanel to use a GridLayout. I need to access a specific "box" (i.e. specific coordinate) of the grid, but I cannot see a way to do so.
How can I ...
2
votes
1
answer
3k
views
How do I use GridLayout and multiple Panels?
How do I use multiple JPanel containers to make this code look like this?
This is the image of what my code is supposed to be like but I cant figure it out.
I can only use GridLayout, BorderLayout ...
2
votes
2
answers
2k
views
GridLayout throws illegal component position
By default GridLayout(5,3) would add the components in this way:
A B C
D E F
G H I
J K L
M N O
To have the components disposed in the following positions:
A F K
B G L
C H M
D I N
E J O
I have ...
2
votes
5
answers
15k
views
how to make my textfield bigger for GUI in java
i have a text field like emailid, city and address,
i want to make the address textfield should be bigger as shown in image!
i use BorderLayout as default and GridLayout for the selected panel
top....
2
votes
1
answer
3k
views
setVgap(0), setHgap(0) not working in gridlayout?
I am trying to build an app that has some components such as buttons, labels, text fields, a menu bar and a picture (I didn't tackle the image problem yet so there is no code for that).
So I made a ...
2
votes
2
answers
738
views
Resizing panels in a GridLayout
I want this:
My frame is a GridLayout (3,2), and all I can have is this:
I put the button in a panel, I think it's easier. But how can I change the size of the grid?
2
votes
1
answer
159
views
How to move a button after action performed?
I'm working on a program using GridLayout. I have a problem when i try to move a button to another position after action performed. Basically, i have an empty space in the panel with the size of a ...
2
votes
3
answers
212
views
JTextField not appearing in grid layout
I'm using a grid layout for one of my programs and when i try to add JTextFields to the grid It doesn't show at all. If i try adding JButtons instead of JTextFields in the same method it works ...
2
votes
1
answer
46
views
GridLayout Displaying 2 rows for `new GridLayout(22,1)`
I am trying to create a scorePanel for a game (Yahtzee). The scorepanel must consists of 22 rows and 1 column for each player but the following code i am writing displays 12 rows and 2 columns for ...
2
votes
3
answers
3k
views
How can I stop a JTextArea and JTextField from stretching?
This has probably been answered here, but my searches drew up a blank, perhaps I am looking for the wrong thing.
How can I stop a JTextArea and a JTextField from stretching? Does swing provide a ...
1
vote
4
answers
7k
views
How to work with a specific element in GridLayout?
I have a problem adding an icon to a spesific element(grid?) in gridlayout. My gridlayout contains 64 "bricks" which is intended to work as a chessboard.
My gridcode looks like this:
ChessBoard
...
1
vote
1
answer
2k
views
Java creating a type of form with GridLayout?
I am trying to make a Pythagoras theorem calculator. Right now, I am trying to make a form using GridLayout. You enter the values of side A, B or C and check the radio button on the side that is ...
1
vote
1
answer
219
views
How do i force GridLayout to always have 7 columns
(This is on Java Swing)
I created a gridLayout(6,7), however it looks like it prefers to comply the Vertical requirement with higher priority than the horizontal.
I mean, it will always have 6 rows, ...
1
vote
2
answers
13k
views
Gap between JPanels in GridLayout
The code below produces nine individual JPanels in which are 9 buttons. The nine JPanels are arranged onto a base JPanel using GridLayout. This base JPanel is then placed onto the ContentPane using ...
1
vote
2
answers
67
views
Numberpad Not Displaying Correctly
I have a Java GUI project where I am creating an ATM. I have everything setup, but for some reason my number pad on the left is not displaying properly. It should appear as a 4x3 grid of numbers, but ...
1
vote
2
answers
398
views
Grid layout not working?
I am trying to make a 2x2 grid layout that has a JLabel on the top left, and three buttons on the other three spaces. When I do this, I get the unexpected result of one big button (filling up the ...
1
vote
1
answer
425
views
GridLayout not working in JPanel
I'm trying to add a JButton to my JPanel multiple times using a GridLayout. For some reason though, every time I run the program it only shows 1 button.
Here's the code:
jPLeft = new JPanel();
...
1
vote
1
answer
307
views
GridLayout null margins
I put several JPanels, each containing a JLabel + JTextField in a GridLayout (as shown below).
I am trying to reduce the spaces between the cells as much as possible.
I did the following :
GridLayout ...
1
vote
2
answers
234
views
JButton and its Location methods acting very weird
my problem is, that when I create a JButton, whithin its constructor, I set its location to some relative coordinates, say x = 5, and y = 6, using the following code:
this.setLocation(new Point(x, y))...
1
vote
3
answers
1k
views
Problems with my GridLayout
I have a GridLayout 2 rows by 5 columns, and I want to make the height of the first row to something like 50, and the second row to 200. I know GridLayout creates equally-sized cells, so this didn't ...
1
vote
1
answer
509
views
Java Swing GridLayout not looking like I expect it to
I have a GUI that is a grid layout with 6 rows and 4 columns, the order should go:
Label - RadioButton - RadioButton - ComboBox
This is successful for the first row. However each row afterwards is ...
1
vote
1
answer
128
views
Layout problems with Java Swing Tools
I am trying to make a simple GUI registration code window, that has a text to enter the code, and a button to verify if the code entered is right or wrong. Exactly like this image :
So I tried to do ...