setSize « Layout « Java Swing Q&A





1. Java: Difference between the setPreferredSize() and setSize() methods in components    stackoverflow.com

Ok, I read the Java Documentation and I just can't figure out what is the main difference between those two methods. Sometimes I used setSize(), sometimes setPreferredSize(), sometimes one does what ...

2. Java Dimension for JFrame. setSize(new Dimension(x,y));    stackoverflow.com

I have a question. When I'm setting the size of a JFrame and I add a new dimension. Is that number millimeter or pixels? I want to set the size to ...

3. Where is the place to setSize of subcomponents    stackoverflow.com

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 ...

4. JPanel.setSize() not working    stackoverflow.com

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.*;
/*<applet code="k" height=400 width=400></applet>*/
public class k extends ...

5. How to setSize of image using RescaleOp    stackoverflow.com

I am writing a test app. To set Alpha for image I use paintComponent method. Watch next snippet...

    public class TestImage extends JLabel{

      ...

6. setSize of JPanel after intialisation    stackoverflow.com

I am bringing in a ResulSet to show the contents of my table. thing is that though the results are showing i have been trying to resize the height of the ...

7. setting size of JFrame using Dimension.setSize    stackoverflow.com

I have a gui app where I need to set the size of the main JFrame to 80% of screen width and 90% of screen height.I tried this

public class JFrameDemo extends JFrame{
 ...

8. Why does the JFrame setSize() method not set the size correctly?    stackoverflow.com

So I've been programming in java for a semester or so, and I've had this problem a few times and finally got around to asking. If I make a JFrame and then ...

9. java JFrame setSize    stackoverflow.com

I am loading a JFrame showing the company logo and credits etc before starting the main application. I am having some problems. Fist of all, the size of my new JFrame ...





10. setSize() for Panel has no effect    coderanch.com

I am using two panels in my code. One to show some data, and another one with labels at the bottom of the applet to approximate a JTabbedPane with AWT. When I check the size of the data panel, it shows the size that I have set. However when I run the applet, the panel is only of size 10x10... What ...

11. Newbie JFrame setSize() question    coderanch.com

12. setSize()    coderanch.com

Thanks Bill. I'm kinda going back to my original question about JList. I want to display a box that contains nothing but could contain a rapidly increasing list of strings. I want the box to look something like the thing I'm typing into now but I have no idea how to get the thing to display unless I add a vector ...

13. JFrame.setSize() calls ignored until after JFrame.show()    coderanch.com

import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class TestFrame extends JFrame { public TestFrame() { super("Test Frame"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton b = new JButton("Resize Me"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (getWidth() == 800) { setSize(300, 200); validate(); //Make the button fit the window } else { setSize(800, 600); validate(); //Make the button fit the window } } }); ...

14. setSize and setMinimumSize don't seem to have any effect    coderanch.com

if the container for your dice object/s uses a layout manager (not null), setPreferredSize(new Dimension(int,int)); should fix the problem class Dice extends JPanel { public Dice() { ... setPreferredSize(new Dimension(25,25)); ... } } class MainFrame extends JFrame { public MainFrame() { ... JPanel panel = new JPanel();//<------------------ panel.add(new Dice()); panel.add(new Dice()); ... } } in the example, 'panel' uses a FlowLayout() ...

15. panel.setSize() Not Working    coderanch.com

I have a Frame of Size 300 X 300. In this frame i have two panels, one of size 300 x 100 and other of 300 x 200. The first panel has a Button in the Center while the other panel has 9 buttons arranged in a Grid. For doing this, i am creating a frame with size 300 x 300 ...





17. SWT Text - setSize ignored in GridLayout    coderanch.com

Hey guys, I am trying to set the width of a Text object to a fixed size (it's a zip code field so there aren't more than 5 characters going in) but for some reason the call to setSize is ignored. Whats also odd is that when the text field is initialized and empty it has space to take 9 characters. ...

18. swing components ( difference between setSize() and setPreferredSize() )    forums.oracle.com

I believe what is most important is what the current layout thinks is important. If the layout manager uses the preferred size, then changing this will change the size. If the manager uses the size however, the converse is true. So the key here is to get to understand the layout managers as well as possible.

19. JPanel setSize hides fillRect    forums.oracle.com

I have a class that inherits from JPanel. When a button is pressed, I resize the object (using setSize) then draw various rectangles, lines, and images on it. I found that I had to press the button twice to see anything, because the setSize is wiping out the subsequent graphics operations. Here is a simpler example which has the same problem: ...