All Questions

Tagged with
Filter by
Sorted by
Tagged with
2 votes
1 answer
10k views

Java: Can't apply Gridlayout to a Jscrollpane. Get Get java.lang.ClassCastException

I use a Gridlayout to place 4 elements in one Line. First I had a JPanel and everything worked fine. For the case that the number of lines get to big and I have to be able to scroll down, I changed it ...
Alika87's user avatar
  • 311
2 votes
1 answer
14k views

JFrame - Setting the Row and Column in a GridLayout

import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; public class GridLayoutTest { public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(...
J0nathan Lam's user avatar
2 votes
1 answer
11k views

Changing colors of GridLayout elements

Note: this question may look a bit like another I've posted a few weeks ago. Back then I was not working with adding the buttons as arrays, thats what makes it more difficult for me this time. I'm ...
Xantrax's user avatar
  • 219
2 votes
3 answers
706 views

Java Jframe centers my buttons ):<

Here is my code: public class Main { public static void main(String[] args){ JFrame frame = new JFrame("Vex Development Studio 2.0"); frame.pack(); frame.setVisible(true); frame....
user avatar
2 votes
1 answer
2k views

How to fix JPanel with Grid that occupies full width of frame?

I'm working on a layout for a simple login screen. I am using GridLayout in order to manipulate elements, but have came across an issue, It occupies full frame width like this: Where as I want it to ...
Ilja's user avatar
  • 45.2k
2 votes
1 answer
708 views

A Grid layout containing Card layouts - can it be done?

The goal is to display a table of cells, where all cells are independent of one another, and each cell has several optional displays (Imagine a Kakuro board, jeopardy board, ext.) It's my first ...
yonikes's user avatar
  • 67
2 votes
1 answer
1k views

How do I select specific cells into a Java grid GUI?

I'm developing a GUI grid and I need to select specific cells. I used JFrame. My goal is to fulfill the first column and the last row with numbers, like x-y axes. I have tried to declare an array of ...
Mike994's user avatar
  • 55
2 votes
1 answer
796 views

Text on JTextField doesn't appear until frame resize

When I click on a button a property frame appears. Each row has these 3 fields : JLabel name, JTextField value, JSlider slider. My problem is that when the frame shows, it displays the values ...
Pantaziu Cristian's user avatar
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 ...
Xantrax's user avatar
  • 219
1 vote
3 answers
17k views

Java grid layout and JPanel

I have a question. I have the following program and I'm having trouble with one thing. I have created a grid layout, and I'm using JPanel to enter buttons and text with in the grid, but everything ...
arled's user avatar
  • 2,622
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 ...
AnthonyH's user avatar
1 vote
1 answer
2k views

How to center align everything in JPanels having GridLayout

Recently,I had asked a question about how to make JPanels align from top to bottom in a JFrame. Users told me to use GridLayout(). I got everything working,but I forgot to mention that I wanted to ...
Spikatrix's user avatar
  • 20.3k
1 vote
2 answers
6k views

How to get components from a JFrame with a GridLayout?

I have a question about Java and JFrame in particular. Let's say I have a JFrame that I am using with a GridLayout. Supposing that I have added JButtons in the JFrame, how can I gain access to the one ...
NlightNFotis's user avatar
  • 9,649
1 vote
1 answer
96 views

how can I split a frame between two frames?

I am using grid layout in a frame and I want to put two panels in this frame in which one of them takes one third of the frame size and the other two third of the screen, how can I do that? I have ...
flashdisk's user avatar
  • 3,710
1 vote
1 answer
350 views

Can I use multiple grids?

I am trying to figure out the layout for this(the rest of the code is in the early stages) but for this block, I am trying to figure out the best(and doable) way to format it. I want it to be an 8x8 ...
rebekah.ann's user avatar
1 vote
1 answer
6k views

How to fit a JTable into a JPanel and make it auto resizeable?

i'm adding a JTable into a JPanel wich is using a GridLayout but i don't get the same behavior like when you add a JButton... I want to know how can i get the same auto resizing behavior with my ...
mrgamertag's user avatar
0 votes
2 answers
217 views

GridLayout only updates when window is manually resized

I have a panel using a 3x3 GridLayout, which I want to change to a 4x4 layout with the click of a radio button. This is the panel class where I set up my menu and needed buttons. Please keep in mind ...
Omar Sharaki's user avatar
0 votes
1 answer
17k views

how do you use Grid layout in panels in Java? [closed]

Im trying to create a JFrame with two panels. the top panel will contain a text field and the bottom panel will contain a grid of buttons. Ive used gridLayout to to arrange the buttons and added them ...
user2997509's user avatar
0 votes
1 answer
76 views

Cosmetics with GridLayout

I'm posting this question because I'm new to programming at the present time and I have a pet peeve that when I create the app I don't want the objects to go across the entire window. I use ...
Achi113s's user avatar
0 votes
1 answer
1k views

Grid in the center of BorderLayout

i have been trying to make a 2x2 grid in the dead center of this but i cant.either the grid will cover the rest or it will fit but i will be able to see only the last button.. import javax.swing.*; ...
user avatar
0 votes
1 answer
279 views

GridLayout is showing odd behavior

I am trying to create a grid comprised of 100 squares. My code below is extremely buggy and I am not sure why. import javax.swing.*; import javax.swing.border.Border; import java.awt.*; public class ...
someCoder21's user avatar
0 votes
2 answers
3k views

GUI Calculator using JFrames and layouts

I'm currently working on a calculator which should perform basic calculations such as addition, subtraction, multiplication, and division. To achieve the final outcome, I've to follow a certain design ...
J patel's user avatar
  • 165
0 votes
1 answer
46 views

JFrame layout helping/guide,

I am having trouble with the layout of my JFRAME the layout is extremely difficult to me because i have just started learning it. the layout I'm looking for is select data START DAY: "...
Vaughan D's user avatar
  • 149
0 votes
1 answer
65 views

Assistance with JFrame

I need some assistance with an assignment that deals with Jframes. The assignment says "For questions 27 to 31, consider the following class: import javax.swing.*; import java.awt.*; import java.awt....
user avatar
0 votes
1 answer
2k views

placing items into a panel with gridlayout

Hey everyone I am trying to draw a checkerboard in Java with GUI. I have created a square class for the squares of the game board. Square Class: import javax.swing.*; import java.awt.*; public ...
j.doe's user avatar
  • 23
0 votes
1 answer
135 views

GridLayout Squished Together in JFrame/JPanel

I am trying to create a TicTacToe Game'. Only one board is playable by the user and when the user clicks on a cell the cell will be filled with an X/O and the same cell(on a randomized spot of the ...
fzk's user avatar
  • 25
0 votes
1 answer
1k views

Why is this not showing buttons in gridlayout?

Im trying to create the so called "15 game" , which is like a slide puzzle with 16 buttons, 15 of them with numbers 1-15 and a empty one. Clicking on a button next to the empty one will switch ...
UserFuser's user avatar
  • 110
0 votes
3 answers
1k views

Components in GridLayout don't show properly

I create a GridLayout Frame with 2 rows and 3 column. I put 3 JLabel in the first row and each column. When I try to run, the third label is in the second row and the first column as show below Why ...
Dexter Moregan's user avatar
0 votes
1 answer
88 views

How do I update a Gridlayout after actionlistener is triggered

I am trying to build a grid containing a player (red square) that can move around the grid using the WASD keys. So far my actionlistener is registering key pressed, however when calling the repaint() ...
Cosmo's user avatar
  • 1
0 votes
1 answer
57 views

Buttons dont add to Jframe

I can't create a field with this code. I want to load a file and the field should add arrays for the specific size. The problem is that the buttons are not shown in the frame. Does anyone have an ...
Marcel Ge's user avatar
0 votes
0 answers
191 views

using JScrollPane with JFrame, JPanel and GridLayout [duplicate]

I have a GridLayout (of JTextFields : 57*57) in a JPanel in a JFrame (resolution 800*800) and the result is really small and that's why I would like to have a JScrollPane (that would have a 800*800 ...
Dark Brocoli's user avatar
0 votes
1 answer
255 views

Swing adding more lines in the GUI, and background not showing

I have created a GUI with the help of another thread to format it properly. Thing is now I want to add another line for a 'back button'. When I create the panel and add it it doesn't show unless I ...
TheCoder24's user avatar
0 votes
1 answer
130 views

Editing the height of a specific row in GridLayout Java

I want to edit the height of a single row in a JFrame with a GridLayout. Is there any way to do this or must the height of every row be constant?
Fraser Price's user avatar
-1 votes
1 answer
394 views

Problem with refreshing GridLayout on Java Swing

i have a problem with refreshing the values of my gridlayout. So, i have a JPanel in a JFrame and in that JPanel , once i entered two values(one for rows and one for columns) and then by clicking on ...
killuaZd's user avatar
-1 votes
3 answers
3k views

How to add or remove JButtons in a specific location in a gridlayout?

I want to remove a JButton of a gridLayout, using actionListener. I wanto to leave in blank the space of the JButton that has been removed and later fill that space with a JLabel or something. import ...
Mac's user avatar
  • 111
-1 votes
2 answers
1k views

GridLayout not displaying correctly

I'm attempting to create an array of buttons and add them to a GridLayout, but for some reason, the grid does not get drawn correctly if I make it larger than about 5 by 5. If it's between about 7 by ...
EyedJellyfish's user avatar
-3 votes
1 answer
1k views

Setting an icon image to top right and bottom left buttons [closed]

How would I go about creating a 4x4 grid of colored,clickable areas using swing? Ok, so I have the buttons I need. This is the updated code I have. I am now trying to to get a text field or jlabel ...
user2835532's user avatar