Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
56 views

JFrame size affecting JButton size but only vertically?

I am confused about how JFrame extends the JButton vertically to match JFrame min size but not horizontally. I would like for it to not extend in either direction and know why it extends or doesn't. ...
KGajjala's user avatar
-4 votes
1 answer
232 views

How to get container components according to layout?

I'm having two different issues during working with GUI. The first one is: how can i get container components? I want to get 5 components from BorderLayout (and prefer to get them with knowledge of ...
Eitanos30's user avatar
  • 1,429
0 votes
1 answer
97 views

Drawing graphics on a panel

I am trying to draw graphics on panels, but I am not sure how I would go about doing that. I have tried creating a class that extends the JPanel and overrided paintComponent, and some other methods, ...
o6707448's user avatar
0 votes
1 answer
34 views

How to make this layout using JFrame

I'd like to make this layout using JFrame, is it possible ? Thank you
user3503112's user avatar
0 votes
1 answer
301 views

How to remove blank space between image and text inside the JPanel?

I'm trying to develop a little application for my Java class. I'm using jsoup to get information from an URL. I finally got everything, but I don't know how to remove this huge blank between the ...
David_helo's user avatar
0 votes
1 answer
57 views

How to fill JFrame window with a JPanel?

I am trying to set a JPanel fill the whole window of a JFrame. The layout of JPanel is GridBagLayout. If i change it to BorderLayout it works. But i need the GridBagLayout and in this way the JPanel ...
Thomas Athanasiou's user avatar
0 votes
1 answer
180 views

How to stack text fields vertically on a Panel?

I am working on the little GUI GPA calculation program. I set up my button so that once it's clicked some text fields and comboboxes will be added to a panel, but everytime when it's clicked, all the ...
HL1701's user avatar
  • 65
0 votes
1 answer
6k views

Java GUI Best way to create a table of JTables?

[UPDATE!!!!] This is the finish product: : ) So I am working on a program that helps me organize and print seatings for dinner. I have a student class with instance variables of their FirstName, ...
Ptolemorphism's user avatar
0 votes
1 answer
1k views

How to keep JPanel from inheriting the size of its container JFrame

I've create a JFrame named homeWindowFrame and set its size to (600, 500) and then I added a JPanel named mainContainerPanel to the JFrame. I set a new size to JPanel but it's not working. JPanel size ...
Himel Mazumder's user avatar
0 votes
1 answer
56 views

Put component inside the smaller one

I wanna get Frame(640x640) with DrawCanvas(960x960) inside like this: So the part of DrawCanvas must be hidden and frame centered. What layout should I choose? Now I put DrawCanvas inside the frame ...
Russiancold's user avatar
  • 1,291
-2 votes
3 answers
1k views

How can I display multiple JPanel's from different classes onto my JFrame?

I will have a menu bar in which I can select multiple choices, in which will display a different JPanel for me onto my JFrame. Whenever I choose another option from my menu bar, a different JPanel ...
juiceb0xk's user avatar
  • 969
-1 votes
1 answer
158 views

What are Java resizable Layout Managers please?

I would like to resize my JFrame layout manager (actually Border Layout) so I used setPreferredSize but nothing happens ? And some people told me to use another Layout Manager, so what Layout Manager ...
Henley n's user avatar
  • 3,785
-2 votes
1 answer
92 views

Java - Switching between JPanels with their own JPanels and resizing these inner JPanels and components depending on JFrame size

I am making program in Java where I have some JPanels with different layouts and I want to switch between them. On these JPanels I have another JPanels with other components (like JButtons and JLabels)...
Spook's user avatar
  • 363
0 votes
0 answers
54 views

How to define the position that I want to my JButton on top of a background image?

I have a small frame that I created and I wanted to give it an image as a background, but when I did that I tried to work with boxlayout to define the positons of the buttons. But it was a disaster ...
user avatar
1 vote
1 answer
391 views

Placing JLabel, JButton etc. in JFrame

at the begginning i want to say im Polish guy, so sorry if my english will be bad... and my code have polish names. I am doing calculator in active window, but i have many issues and i can not solve ...
sonongo's user avatar
  • 11
1 vote
2 answers
55 views

How can I add two components so they are both independent of each other?

So I am creating a screen with balls that bounce around the screen. I want to place text in the center of the screen without disrupting the physics of the bouncing balls. My solution was to have two ...
SputnicK's user avatar
  • 153
-1 votes
1 answer
72 views

PaintComponent not working with JButtons - FIXED

EDIT: Thank you everyone, you really helped me out here. The final thing I needed to do was make the panels layout null, so the JButtons could move. Thank you! My paintComponents content doesn't show ...
user1766089's user avatar
0 votes
1 answer
63 views

Missing Jbutton row inside Jpanel

Can anyone tell me why the JFrame is missing a row of buttons? I'm trying to make a memory card game where you click on the button and it's replaced by an image but some buttons aren't showing up? I ...
D_Wagner's user avatar
0 votes
2 answers
1k views

Java JLabel and JTextField Positioning

Right now I have a 'login' JFrame setup. there are 2 labels and 2 fields for username and password. They are centered and appear as so: username: |text field| password: |text field| JPanel ...
TheDetailer's user avatar
1 vote
1 answer
247 views

JPanel doesn't show up completely until I resize JFrame

I am making a board game and need two panels on a JFrame. I added them and they look good enough but one of them, the big grid to play the game, doesn't show all the way, I only see a little, I have ...
Paw's user avatar
  • 15
0 votes
0 answers
658 views

Java Swing GUI Adding a Frame Container to another JFrame

I´ve got a class which extends JFrame. An Object of this class should contain another object from another class which also extends from JFrame. If I want do add the object from the secound class to ...
user avatar
1 vote
1 answer
54 views

Problems with JPanel layouting

My GUI looks like this: my gui and should look like this: solution and this is my code for layout: public void initComponents(){ setTitle("GUI-Design"); setSize(800, 600); ...
Ams1's user avatar
  • 135
0 votes
1 answer
469 views

Drawing a line at a specific point in JFrame

So here is my code, which displays a 9x9 grid: import javax.swing.*; import java.awt.*; public class SudokuGrid extends JFrame { private static final int ROWS = 9; private static final int COLUMNS =...
Lushmoney's user avatar
  • 462
0 votes
1 answer
62 views

Java: JFrame Layout for Only Drawing?

I'm wanting to draw my components on a JFrame based on coordinates. I don't want a layout to rearrange the components. My project isn't a GUI, it's a game where the images being drawn don't need to be ...
j76goatboy's user avatar
1 vote
1 answer
46 views

Want to know difference in JFrames (BorderLayout)

I want to know what is the difference between: window.getContentPane().setLayout(new BorderLayout()); and window.setLayout(new BorderLayout()); (window is a JFrame Object). Thank's for ure ...
Tinou's user avatar
  • 13
0 votes
2 answers
68 views

How do I set my label to be visible even when the Layout is null? Also, JFrame size still defaults to the minimum

This is what my code looks like at the moment: public TestFrame(){ setSize(x1, y1); /*where these are already defined*/ setLayout(new FlowLayout()); JLabel label = new JLabel("text"); ...
Rodney Johnson's user avatar
0 votes
1 answer
69 views

How to make a Frame with Multiple Panels Like this

I tried this Layout but Its shows only one panel. I need leftpanel (Panel 1) a bit smaller than the second Panel. It is currently showing the menu and Panel 1 in center. I tried all of the every ...
Dcoder's user avatar
  • 29
0 votes
3 answers
76 views

How can i organize my frame like this?

I want my frame to have 3 panels that will look like that I'm a total newbie at JPanel and i cant organize it, so if someone can help i'd appreciate it
noam's user avatar
  • 25
0 votes
1 answer
217 views

How the pack() function behave when we explicitly set the location of the container?

Here is the minimal example what problem I am facing in my main GUI design import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JButton; import javax.swing.BoxLayout; class ...
OldSchool's user avatar
  • 2,183
0 votes
2 answers
154 views

Java Layout Manager tips [closed]

I created a small program which is shown in the link. And I used absolute layout. But I want to try other layouts. Are there any alternative layouts to use apart from absolute layout ? Here is the ...
Latif's user avatar
  • 125
-1 votes
1 answer
531 views

why does my Jframe open an empty window?

I'm trying to make a game for school, like Puralax. This is my first year of Java. Currently I'm testing through 'viewTest' and the 'DitMoetWerken.java' class to make my complete JFrame. My guess ...
Tom Dirinck's user avatar
0 votes
0 answers
67 views

Java adding 2 objects in a JFrame but only 1 is showing

I know this question is asked often in stackoverflow. And i know there is a page on oracle about LayoutManagers but i dont understand how to use it? Can someone help me with my code? Im trying to make ...
Mert Karakas's user avatar
0 votes
1 answer
1k views

Gephi graph layout

I am trying to find the optimum (best looking) layout for my graph using following Jframe source code: package org.gephi.toolkit.demos; import java.awt.BorderLayout; import java.awt.Color; import ...
user4045430's user avatar
0 votes
1 answer
2k views

JPanel/JButtons disappear after JFrame addition of background image

Java newbie here... I am trying to add an image to the background of my JFrame. I already had buttons added to the panel, on that JFrame. When I added the image to the JFrame, my buttons disappeared. ...
L. Morrell's user avatar
1 vote
1 answer
624 views

JFrame getLayout method does not return set cardLayout

I am setting a CardLayout as the a JFrame's layout but when I call the getLayout method a border layout is returned. import java.awt.CardLayout; import javax.swing.JFrame; public class SSCCE { ...
WVrock's user avatar
  • 1,755
0 votes
1 answer
55 views

JLabel not showing on top orientation

I have been working on a menu for my program, but I'm having some problems with JLabels because I'm not very experienced with them. I have a JFrame set up and the layout of the buttons and the ...
Meeesh's user avatar
  • 1,042
0 votes
2 answers
1k views

How to add 3 rectangles to Jpanel in java?

I'm trying to add three rectangles to the center of BorderLayout and I'm completely lost. My finished program needs to increase the height of the rectangle as the sliders move but I'm trying to figure ...
user3242607's user avatar
1 vote
3 answers
2k views

Adding JPanels to JFrame one after another vertically, each touches the border horizontally

I want to add JPanels to JFrame one after another vertically. Each panel should cover the whole width of jframe. These panels should cover the width even if the frame is re sized. I want to have this ...
Hanzallah Afgan's user avatar
3 votes
1 answer
2k views

Why is my java application blurry? [duplicate]

This is what I wish to make This is what is being showed when I run my java application. (see the text on my button and the text in text box is java) I am using Eclipse Luna on Windows 7. PS: My ...
hoder's user avatar
  • 257
-2 votes
2 answers
432 views

How can I set the components of my JFrame to be organized neatly instead of jammed together?

My credit card program uses JFrames and all the Panel/Text/Label stuff and I am having trouble with understanding Layouts. How can I modify the components of my Jframe/label to make them look ...
SoloSpirit's user avatar
1 vote
1 answer
170 views

JFrame buttons close to eachother

I am creating a virtual piano using JFrame, using buttons to represent keys. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); ...
clem's user avatar
  • 61
1 vote
1 answer
61 views

Java Components Not Displaying + Layout Questions

I've a few questions: First, and most importantly, why can you run a GUI program with a frame, a couple panels, buttons, etc. several times - without changing anything - and half the time components ...
user3397788's user avatar
-2 votes
1 answer
351 views

Add an existing JPanel to an existing JFrame

i've got a problem adding a jpanel to a jframe, i don't know why it doesn't appear with other layout that is not flowLayout; i don't use FlowLayout because all my swing components can't positioned. ...
Jonathan Solorzano's user avatar
-1 votes
2 answers
1k views

How to arrange the labels in a JFrame?

I am facing problem in arranging my labels in the frame; I just want someone to guide me in the right direction. What i want to do is to create a JButton and place it the left half of the frame, while ...
mazin's user avatar
  • 242
1 vote
1 answer
3k views

How to add multiple JPanels to JFrame with different sizes

I tried to do this from stackoverflow: adding multiple jPanels to jFrame But that didn't seem to work out like in the example, could anyone tell me what im doing wrong? Im trying to add multiple ...
Nick Audenaerde's user avatar
0 votes
3 answers
210 views

JButton covers other buttons

I have been stuck in this for a while. The problem is that I want to shift my button to the right side of my screen, but when I use borderlayout.east it removes the other button that I created. Can ...
logger's user avatar
  • 2,043
0 votes
1 answer
1k views

Java Panel overlapping Menu

I am new to Java, so this question might be obvious. I have this Initialization code: frame = new JFrame(); frame.setTitle("Test"); frame.setBounds(100, 100, 512, 468); frame....
Icemanind's user avatar
  • 48.6k
3 votes
2 answers
6k views

How to set a JFrame location beside another JFrame?

In Java, how could I set a JFrame to automatically go beside another JFrame? So, say I have two JFrame objects, frameA and frameB, and when the program runs, it sets frameAs location to be in the ...
hhaslam11's user avatar
  • 231
1 vote
1 answer
307 views

How do I get thet components that are in a particular layout location in JFrame

I have a JFrame that uses the BorderLayout. How do I get all the components that are in the left or the right or in any other location of this JFrame?
Yanki Twizzy's user avatar
  • 7,991
2 votes
1 answer
88 views

JFrame Layout with JPanels

I am having a problem trying to layout my JFrame. I'm trying to add the ToolBar top, then Info below that, then colour below that to the right, then Copies in the center, then Print button to left and ...
user3058734's user avatar