Questions tagged [null-layout-manager]

236 questions
245
votes
11 answers

How to add JTable in JPanel with null layout?

I want to add JTable into JPanel whose layout is null. JPanel contains other components. I have to add JTable at proper position.
Sagar
  • 2,475
  • 2
  • 15
  • 3
16
votes
4 answers

Why is it frowned upon to use a null layout in Swing?

Recently, I started creating a program for the company I work for. Just as background info, I'm still a student and a beginner programmer, so my solution is probably not recommended and I didn't know how to do it otherwise, but it works and I'm not…
Jumbala
  • 4,764
  • 9
  • 45
  • 65
16
votes
4 answers

How to set fix size of jlabel?

I am trying to make a java desktop application where I am using multiple JLabel I want to set fix height and width of JLabel. How can I achieve this? Here is my code public class Second extends JFrame { JPanel panel1,panel2; JLabel…
user3506824
  • 205
  • 1
  • 3
  • 7
11
votes
6 answers

Placing a JLabel at a specific x,y coordinate on a JPanel

I'm trying to place a series of JLabels at specific X and Y coordinates on a JPanel (and set its height and width, too). No matter what I do, each label winds up immediately to the right of the previous label and has the exact same size as all of…
AndroidDev
  • 20,466
  • 42
  • 148
  • 239
7
votes
4 answers

suitable LayoutManager for resizable components

sometime ago I read this article that shows a way to implement mouse resizable components in Swing. The author uses a null LayoutManager in order to allow absolute component positioning. I know that a null layout should never be used, so my question…
Heisenbug
  • 38,762
  • 28
  • 132
  • 190
5
votes
2 answers

JPanel.setSize() not working

Check out this code friends don't know why i am not able to set the size of JPanel... . import java.io.*; import java.util.*; import java.sql.*; //import java.applet.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; /*
user528050
  • 157
  • 2
  • 4
  • 21
5
votes
3 answers

Use a absolute layout inside a JScrollPane

I need to use a JScrollPane with absolute layoute. I know that the use of setLayout(null) is not recommendable at all. I've been reading that if you want to use the absolute layout with a JScrollPane it is necessary to set the preferred size…
Jonás
  • 1,459
  • 4
  • 27
  • 43
4
votes
2 answers

Why isn't my JScrollPane with a JTextArea visible when using null LayoutManager?

I'm trying to display a JTextArea within a JScrollPane, but I just get an empty frame when I run my (simplified) program: import java.awt.Container; import java.awt.Dimension; import java.awt.event.WindowAdapter; import…
Ellen Spertus
  • 6,576
  • 9
  • 50
  • 101
4
votes
1 answer

Resizing The GUI?

my question is simple but I can not find exact solution for this. I try to write a program with Java GUI, I use absolute layout for my program and I set frame bounds(100, 100, 450, 300) . When I run the program and make it full screen, components…
3
votes
4 answers

JButton() only working when mouse hovers

import java.awt.*; import java.awt.image.*; import java.awt.event.*; import javax.imageio.*; import java.lang.*; import java.io.*; import javax.swing.*; public class MainClass extends Component{ private Image…
H S
  • 179
  • 4
  • 12
3
votes
1 answer

Alternative solution to null layout manager when absolute positioning is needed

Few months ago i read this Swing tutorial http://zetcode.com/tutorials/javaswingtutorial/resizablecomponent/ for understanding how implementing resizable components inside Swing. The tutorial tells about using a null LayoutManager in order to have…
Heisenbug
  • 38,762
  • 28
  • 132
  • 190
3
votes
3 answers

Adjust layout for 3 columns of common components with other components above/below

I am building a simple GUI for a course assignment, but I am not getting the most out of it. So this is my objective: And I am getting this (it lacks of some elements like the button): So the thing is, how do I code my layout to be tighter like in…
fant0me
  • 201
  • 1
  • 3
  • 15
3
votes
1 answer

How to change JLabel's size when the font size is changed?

I've a JLabel. The code for JLabel is as follows. panelmain = new JPanel(); panelmain.setLayout(null); panelmain.setPreferredSize(new java.awt.Dimension(800, 600)); panelmain.addComponentListener(listen); panelmain.setBorder(null); titlebar = new…
Girish
  • 213
  • 2
  • 13
3
votes
1 answer

JPanel disappearing when changing the text of a JButton added to it

I add a JButton to my JPanel subclass Quiz, and if I change either the text or the font of the button, the Quiz object disappears, showing only the panel underneath it. However, if I change the text or font before adding the button, everything works…
3
votes
2 answers

Why I lost visual when I add setLayout(null)?

I am trying to build a small monopoly game. Here you can see the part of the code that I am having trouble with. public class Board extends JPanel { private ImageIcon image; private JLabel label; static Player p1; static Player p2; …
Mehr
  • 170
  • 1
  • 1
  • 8
1
2 3
15 16