Skip to main content

All Questions

Tagged with
0 votes
1 answer
481 views

How to add auto-resize components?

I'm wondering how I can add (what LayoutManager should I use) to make the app automatically adjust the components to the current size when full screen mode is enabled or even when the frame is ...
JJJokers223's user avatar
2 votes
1 answer
1k views

Java - How to center components horizontally, and stack them vertically?

I am writing a application that will take user information such as the name, email, password. To get the user information I am using JTextFields. I would like to have all the components in the center ...
IssiahB's user avatar
  • 52
0 votes
2 answers
362 views

How to leave MouseListener on ChildComponent but correctly keep track of mouse enter and exit on parent?

I have a JPanel with a CardLayout and two cards. I want the layout to flip the cards each time the mouse enters or exits the panel. This works fine unless one of the cards is a component that listens ...
T_01's user avatar
  • 1,381
1 vote
1 answer
655 views

Adding Multiple Components In Seperate Classes to JFrame In Another Class

I have ran into a problem. The problem lies with adding multiple components to a JFrame, all within separate classes. I have to add the two components DrawBoard and QuestionBox into the JPanel 'panel' ...
HyperBlue's user avatar
0 votes
2 answers
55 views

How to have components centered within a certain area of the panel

I would like to position some buttons so that they are centered, but on the right side of the panel (where the pale boxes are). The background re-sizes when the window is re-sized, therefore I would ...
BRJG's user avatar
  • 1
0 votes
1 answer
101 views

Centering Swing Components

How do I make my textfields and button centered? Edit: Updated my post with SSCE. Hopefully that helps. By the way, I want the left image to look like the right. package pkg; import java.awt....
user3130731's user avatar
0 votes
2 answers
3k views

Jframe. Cant get multiple components to display

I am having trouble getting two different components to display at the same time. public class BandViewer { public static void main(String[] args) { JFrame frame = new JFrame(); ...
Justin Walker's user avatar
4 votes
1 answer
116 views

BorderLayout.NORTH behaving unexpecedly

I have a JFrame-descendant window a with a JMenuBar and two components stored in a JPanel. One is a JTabbedPane, which occupies the majority of the screen, and the other is small JPanel that in turn ...
ApproachingDarknessFish's user avatar
2 votes
2 answers
829 views

Which is the fastest way to insert component in Java Swing between other components?

I'm making a kind of editor which have a blocks (JPanel's) instead of words (with text-like flow and cursor - blinking JPanel). I need a fast way to add a Swing component (new block) between existing ...
Piotr Müller's user avatar
2 votes
2 answers
5k views

Calculate sizes of Components of JDialog with total Size set before making visible

I have a JDialog and I want to have it a certain, given size: JDialog dialog = new JDialog(); dialog.setSize(800, 600); dialog.setResizable(false); Then I add a component: JLabel label = new JLabel("...
NoDataDumpNoContribution's user avatar
0 votes
2 answers
182 views

Where is the place to setSize of subcomponents

I have class extended from JPanel. This class contains several other JComponents and a lot of painting. What I did and I know it isn't correct is, I overrided the paintComponent for the paintings, so ...
Christian's user avatar
31 votes
1 answer
23k views

Removing the CENTER element from a JPanel using BorderLayout

Is there any way of removing the Component added to the CENTER of a JPanel with a BorderLayout, without having to reference the Component itself?
Evan Fosmark's user avatar