How to set a minimum size of a JFrame

hi freinds,
i have written a swing application which starts like this ,
public class workerclass extends JFrame implements ActionListener {
blah blah blah ..
now can you please tell me how to set a minimum size for this application once it starts so that user cant minimize it more than that minimum size.....
when i tried
setDefaultLookAndFeelDecorated(true);
it did my job by setting it to a particular size which wasnt minimizable, but this default look and feel looked ugly.
so i used system look and feel
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
but with this how do i set the minimum size..
please do help
and one thing more , like
in my main Method when i say
new workerclass().setSize(500,500); or say(100,100) or say(300,300)
new workerclass().setVisible(true);
the size (***,***) , doesnt reflect when my application starts, it always starts with some damn fixed size , what can be the issue .
waiting.........
Thanks

how do i set my Jrame to a minimum size so that
minimizing beyond that can be restrictedThis is what the code is all about
don't know your code but ..
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class workerclass extends JFrame implements
ActionListener,ComponentListener {
public void initcomponenet()
setJMenuBar();
pack();
addComponentListener(this);
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new myclass.setSize(500,500);
new myclass().setVisible(true);
public void componentShown(ComponentEvent e)
     public void componentResized(ComponentEvent e)
          if(getWidth()<200)//restrict width to minimum 200
               setSize(200,getHeight());
if(getHeight()<100)//restrict Height to minimum
um 100
               setSize(getWidth(),100);
     public void componentMoved(ComponentEvent e)
     public void componentHidden(ComponentEvent e)
Thanks kanad , your code is working ... you desere lot more than a duke dollar but for now i can only give that :-( , please accept it :-)

Similar Messages

  • How to set the minimum size of a JFrame.

    I can user JFrame.setMinimumSize() method with jdk1.6.0. But I can't find this method in jdk1.4.2. How can I do this with jdk1.4.2?

    Try google:
    http://www.google.com/search?q=jframe+minimum+size

  • How to set the minimum size of the JDialog.

    Hi Could any one tell me ,
    How to set the minimmum size of the JDailog.
    I am using the JDialog's setMinimumSize(...)
    But it is not working.....
    Regards -
    Vikas Kumar sahu

    That's pretty much all there is, although you could always add a componentlistener and manually not let the size go below your minimum.
    Or you could try overriding setSize...

  • How to set the cell size in a JFrame

    Hello. Is there any way of setting the cell size in a JFrame. The reason why I want to set the cell size is that I want to be sure of their location that when I am placing components on the JFrame. So is there any way of setting the cell size beforehand. Also for the following code.
    JFrame frame = new JFrame("Window");
    frame.setSize(100,100);is the size 100 by 100 is he size of the cell?

    smithbrian wrote:
    When I am placing a component on the grid I want to be sure the component is exactly where I place it. In order to do that I would need to know what is the size of the gird and how to change the size of the gird in the JFrame.What grid?? You're assuming that we know much more about your program than we actually do. We actually know zip. Please read this help site which will help you to avoid similar errors in posting questions here. It has helped me in the past: [smart questions|http://www.catb.org/~esr/faqs/smart-questions.html]

  • How to set the minimum size of app window?

    Hi JavaFX experts :)
    Is it possible to limit the minimum size of application window? What would be the JavaFX equivalent of the following SWING code?
            JFrame frame = new JFrame("Application Title");
            frame.setMinimumSize(new Dimension(320, 240));
            frame.setPreferredSize(new Dimension(640, 480));Preferred or initial size was easy (width/height), but what about the minimum size?
    Stage {
        title: "Application Title"
        width: 640
        height: 480
        scene: Scene {
            content: [
                // some content
    }Thanks!

    var stage: Stage;
    var stageWidth = stage.width on replace
        if (stageWidth < 640) stageWidth = 640;
    var stageHeight = stage.height on replace
        if (stageHeight < 400) stageHeight = 400;
    stage = Stage {
        title: "Application Title"
        width: bind stageWidth with inverse
        height: bind stageHeight with inverse
        scene: Scene {
            content: [
                // some content
    }It doesn't prevent resizing to smaller dimensions but it restores to minimal dimension if done.

  • How can I set the minimum size the location bar should automatically resize to

    I have moved all of my navigation buttons, location bar and tabs to be in line. This has been done to maximise the available space on screen.
    This works perfectly with two or three tabs open, but once more tabs are opened the location bar automatically shrinks to allow for more tabs and becomes unusable. I want to set the minimum size the location bar should shrink to but I do not know how to do this.
    [http://www.mediafire.com/imgbnc.php/eed5749531b3081c43186f59492500e5f089c498c0372fb6fa797b7d697826806g.jpg Screen shot displaying automatically resizing location bar]
    Any help would be appreciated.
    Thanks.

    FBZP seems to be the only way to do the minimum amout setting in standard SAP.
    You can check the BTE (Business transaction event) 00001820 for excluding the low amount items in F110. Please search SDn on how to use the BTEs.
    Regards,
    SDNer

  • How to set a minimum width and height for a stage or scene?

    Hello,
    Does anyone how to set a minimum width and height for a stage or scene?
    I tried listening for width/height property value changes and then adjust the width/height if necessary, but that causes unpleasant flickering of the window.
    In JavaFX 2.1 beta SDK for Mac OS, the Stage class has setMinWidth() and setMinHeight() functions which work very well.
    I'm wondering what's the equivalent way to do that when using the FX SDK for Windows.
    Any help is appreciated!
    Thanks.

    I was wondering how to enforce a minimum stage size with JavaFX 2.0.3.The same flickering way you are currently doing it. See: http://javafx-jira.kenai.com/browse/RT-15200 "Need a way to set the minimum size of a window"

  • Hi, I am using Indesign CS6, How to set the page size in Inches.

    Hi, I am using Indesign CS6, How to set the page size in Inches.

    All fields in InDesign can be entered in any measurement system. So, if you want to make an 8"x10" document and go to File>New Document and the window looks like this:
    …you can type either 8 in or 8" into the Width field like this:
    …and when you move to the next field, it will convert the eight inches into the equivalent number in the unit of measure that it is using at the moment, like this:
    … (203.2 milimeters is the same as 8 inches). You can also enter a different measurement unit into other fields once the file is created, such as the width or height of a frame, or the position of an object in the X and Y coordinates.
    If you would rather just work in inches instead of having to type the inches mark or abbreviation, go to InDesign>Preferences>General and select the Units & Increments tab. There you will see Ruler Units for Horizontal and Vertical at the top of the window. Set them to Inches and all of the fields will display in inches. If you do that to an open document, you will change the unit of measure for that document. If you do it while no documents are open, it will change the unit of measure for any new documents you create. To change the unit of measure for existing documents, you will have to open each and make the change.

  • How Do You Set the Maximum Size of a JFrame?

    Can someone show me a quick example? The JFrame can be empty, I just want to know how to set it's maximum size. I tried using setMaximumSize() and it doesn't work for some reason but setMinimumSize() works fine.
    I tried it using a BoxLayout and even using null as a layout manager and can't get it to work. I heard that the other layout managers don't allow you to set the maximum size of a JFrame so that is why I tried it with the layouts that I did.
    I tried the following code (imported the necessary classes), but it does not work...
    public class MyFrame extends JFrame
        public MyFrame()
            super("TestFrame");
            setLayout( new BoxLayout(getContentPane(), BoxLayout.X_AXIS)  );       
            setMaximumSize( new Dimension(400,200));
            setSize(300,150);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setVisible( true );                
    }// end class

    Reposted from
    {color:#0000ff}http://forum.java.sun.com/thread.jspa?threadID=5236259{color}
    @OP:
    When you repost a topic, please always provide a link to the previous post so people can check what suggestions were already offered (and didn't solve the problem).
    Better still, give a short summary of the advice you have already tried.
    I suggested setBackground(...) so you can see whether your MyFrame is actually occupying the entire real estate of the window. Looks as if trying it out (which I would have done for you if I'd been at home, where my JDK is) would have been too much effort for you.
    I'm pretty much a novice in Swing, but I can tell you this: setLayout controls the layout of components added to the JFrame, not the layout of the frame with respect to its parent container.
    Luck, Darryl

  • How to set the screen size with nested Iview screen

    Can someone show me how to set the screen size with nested IView  screen.
    at the moment i only try it with trial and error untill it looks somewhat close. Is there a property in VC to set the size for Height and width.
    The same question is for the form. the form elements inside the form is easy but the actual form is still a challenge.

    Hi,
    Yes you are correct ,Still the Form and iview are not able to change thier Layout Structure using a Propery.
    it is available with VC7.1
    Govindu

  • How to set the frame size?

    Hi,
    Can some one show me how to set the frame size in this program? History: I have created a window and added a button but its to small. So I want to increase the size of the frame to at least 600X400 pixel.
    private static void showGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("ButtonDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            Main newContentPane = new Main();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        }It would be nice if you could show me how to do it.
    Thank you very much for reading this.

    Challenger wrote:
    Simply adding
    frame.setSize(new Dimension(600,400));to the end of your code should work perfectly.Or, if you want to do it correctly, .setPreferredSize() on your frame before you .pack() it. The default layout manager for JFrame is BorderLayout, which uses the preferredSize of each component to calculate sizes during the .pack() call.

  • How to set the page size

    Hi,
    How to set the page size of a B tree node in berkeley db java edition?
    thanks.

    The two systems have different performance characteristics. If you are concerned with the performance characteristics, then the best way to tell is to benchmark them.
    By the way, both BDB and BDB JE are B-trees.

  • How to set the Font size of Label?????

    Hello everyone.
    I want to knoe how to set the Font size of the Label???
    Please help..
    Thanks a lot.
    Gloria

    Label myLabel = new Label("Hello World");
    //Font(String name, int style, int size)
    myLabel.setFont(new Font("Arial", Font.PLAIN, 12));

  • How to set the heap size of JVM

    please let me know that how to set the heap size of JVM

    C:\>java -X
        -Xmixed           mixed mode execution (default)
        -Xint             interpreted mode execution only
        -Xbootclasspath:<directories and zip/jar files separated by ;>
                          set search path for bootstrap classes and resources
        -Xbootclasspath/a:<directories and zip/jar files separated by ;>
                          append to end of bootstrap class path
        -Xbootclasspath/p:<directories and zip/jar files separated by ;>
                          prepend in front of bootstrap class path
        -Xnoclassgc       disable class garbage collection
        -Xincgc           enable incremental garbage collection
        -Xbatch           disable background compilation
        -Xms<size>        set initial Java heap size
        -Xmx<size>        set maximum Java heap size
        -Xss<size>        set java thread stack size
        -Xprof            output cpu profiling data
        -Xrunhprof[:help]|[:<option>=<value>, ...]
                          perform JVMPI heap, cpu, or monitor profiling
        -Xdebug           enable remote debugging
        -Xfuture          enable strictest checks, anticipating future default
        -Xrs              reduce use of OS signals by Java/VM (see documentation)look at the -Xm? lines
        -Xms<size>        set initial Java heap size
        -Xmx<size>        set maximum Java heap sizeThis can be used e.g. like this:java -Xms8M -Xmx32M MyProgwhich runs MyProg in a java VM with the initial heap size of 8 MB and a maximum heap size of 32 MB.
    - Marcus

  • How to set the fix size jframe window

    when I run the jframe ,the jframe window size is very small
    1)how to set the fix size jframe window??
    2)how to set the jframe cannot change the window size??
    thx~~

    1. You can set the size by calling JFrame's method setSize. There are two versions of this method: (1) setSize(int width, int height) and (2) setSize(Dimension d). Note, that when you use this method to set the frame size, you don't have to call JFrame's pack method.
    2. JFrame has a method called setResizable(boolean resizable) which you can call with the argument false.
    Without any ill intent, these questions are regarding something that is very easily answered by looking at the documentation for the JFrame class. I suggest to anyone working with swing to at least look briefly through the base classes they're extending before giving up. In my experience it is always more gratifying to figure things out on my own than asking someone. But please don't take this the wrong way, I respect people who seek out help in order to further their knowledge, instead of just giving up.

Maybe you are looking for

  • Why do I have items waiting to be downloaded when I already have those items?

    Every time I open iTunes I get alerted I have items to download but I already have those items in library. Now I have a lot of duplicates.   Why does it do this? How to fix?

  • How to copy/paste iWeb site

    Hi! 3 questions... 1) How do I copy and paste my existing iWeb websites pix and text and links and so forth into a newly created iWeb website? 2) How do I create new iWeb site name 3) How do I delete the old site?

  • Not seeing "allow third-party Flash content to store..." in Flash 10.0.45.2

    Hi, I just upgraded to Flash player 10.0.45.2. I would like to review and choose my privacy settings. When I go to the Settings manager through the online interface, I do not see the "Allow thrid-party Flash content to store..." as expected and as de

  • Why are my aliases larger than 4k ?

    I just set up a whole lot of image files in a special alias folder. I expected each alias to be 4k in size. About 10% are 4k, the rest are between 44k and 56k. The originals are all Photoshop JPEGs, created in Photoshop 2 and Photoshop 7. I thought a

  • J2ME and Wireless Internet

    Hello There... I just want to ask which protocol is used by J2ME to use Internet Connection? Urgent Reply is required... Thanx in advance