Questions tagged [preferredsize]

167 questions
16
votes
6 answers

How to change JTable header height?

Title explains the question. How can I easily do that?
Sumudu
  • 5,705
  • 14
  • 49
  • 82
14
votes
1 answer

Enabling auto resize of JTable only if it fit viewport

I need to create a JTable inside JScrollPane with resizeable columns (when user increase column width - horizontal scrollbar appears). For this I have use table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);. Also, when viewport is wide enough to…
user2137020
  • 556
  • 7
  • 20
10
votes
3 answers

JDesktopPane preferred size set by content

I have been trying to tame JDesktopPane to work nicely with a resizable GUI & a scroll pane, but am having some troubles doing so. It seems that unless the drag mode is outline, the desktop pane will not resize as expected (when an internal frame…
Andrew Thompson
  • 163,965
  • 36
  • 203
  • 405
9
votes
1 answer

JEditorPane.getPreferredSize not always working in Java 9?

This question is about different behaviour of JEditorPane in Java 8 and Java 9. I’d like to know if others have experienced the same, whether it could be a bug in Java 9, and if possible have your input to how to handle it in Java 9. Context: In our…
Ole V.V.
  • 65,573
  • 11
  • 96
  • 117
9
votes
3 answers

Automatically adjust Jtable Column to fit content

I am trying to match the JTable column width depending on the data inside. My Code: for(int column = 0; column < gui.testsuiteInfoTable.getColumnCount(); column ++){ int width =0; for (int row = 0; row <…
Hans En
  • 846
  • 5
  • 14
  • 30
8
votes
5 answers

JFrame size is too small

i have created a JFrame in netbeans. But when i run the program, the Jframe size is too small. here is my code. import javax.swing.JFrame; public class Window { private static void demo() { JFrame frame =new JFrame(); …
Sam
  • 264
  • 2
  • 6
  • 16
7
votes
4 answers

UITextview is getting randomly clipped when using Autolayout and or preferredFontForTextStyle

Autolayout will randomly clip the text in my UITextView. It changes the size of the UITextContainerView when you rotate back and forth from landscape to portrait. It will work correctly several times but will randomly change the container and clip…
7
votes
3 answers

Creating a simple custom JComponent in Java?

I want to start building my own customized JComponent's for a project at work. I have a simple example below that should just create a ball on the screen. (I found most of it on the internet) but it does provide a decent starting point. My question…
user3376708
7
votes
2 answers

Swing: set a fixed window size for JDialog

I tried setPrefferedSize and setSize methods, but the dialog still opens at minimum size. private void method() { commandDialog.setPreferredSize(new Dimension(100,100)); - - - - - - //Components added to dialogPanel …
dev
  • 2,274
  • 7
  • 23
  • 46
7
votes
5 answers

Set Column Width of JTable by Percentage

I need to assign a fixed width to a few columns of a JTable and then an equal width to all the other columns. Suppose a JTable has 5 columns. The first column should have a width of 100 and the second one a width of 150. If the remaining width of…
Tom Tucker
  • 10,828
  • 19
  • 81
  • 129
6
votes
2 answers

java unreasonable jtextfield sizing issue

I have searched all problems like this but I couldn't find the solution. public class FormPanel extends JPanel { private JLabel namelabel; private JLabel occlabel; private JTextField nametext; private JTextField occtext; private…
Vivian Maya
  • 488
  • 1
  • 4
  • 11
6
votes
2 answers

Button size (Java)

I created a simple menu in Java, but I can't figure out how to change the size of a button. My menu looks like this: I want the last button to have same size like other buttons. tlacTisk.setSize(10,10); tlacTisk.setPreferredSize(10,10); doesn't…
Sk1X1
  • 1,216
  • 5
  • 18
  • 43
6
votes
1 answer

Preventing JList from auto resizing

I have a JList inside a JScrollPane that's placed in a JPanel (BorderLayout.CENTER) and putting that inside another JPanel's BorderLayout.EAST (this JPanel's CENTER contains another JPanel) and this whole JPanel is placed inside a JTabbedPane.…
ChaoSXDemon
  • 720
  • 7
  • 26
6
votes
1 answer

JFrame isResizable(false) sizing issue

I intended to make a JFrame with a ContentPanel of 600x600 and I wanted the JFrame to be not re-sizable. Inside this box, I Drew a 600x600 red-outlined rectangle to make sure that everything matched when i ran the program. Before restricting…
user1034846
  • 183
  • 1
  • 1
  • 6
6
votes
4 answers

Set size of JTable in JScrollPane and in JPanel with the size of the JFrame

I want the table with the same width as the frame and also when I resize the frame the table need to be resized too. I think setSize() of JTable doesn't work correctly. Can you help me? import java.awt.Color; import javax.swing.JFrame; import…
user1761818
  • 345
  • 1
  • 7
  • 13
1
2 3
11 12