Swing Problem

Discussion in 'Java' started by Eryk, Mar 21, 2007.

  1. Eryk

    Eryk Guest

    When I create a new JFrame using the Swing library the window is
    always the smallest it can possibly be. It even hides some of the
    title if it deems it necessary. I've tried solutions like custom
    setting the size using setSize, but it disregards my settings there.
    I'm not really sure what to do to get the window to behave what I
    would call normally. Any help is much appreciated, thank you.
     
    Eryk, Mar 21, 2007
    #1
    1. Advertising

  2. Eryk

    Phi Guest

    Eryk wrote:
    > When I create a new JFrame using the Swing library the window is
    > always the smallest it can possibly be. It even hides some of the
    > title if it deems it necessary. I've tried solutions like custom
    > setting the size using setSize, but it disregards my settings there.
    > I'm not really sure what to do to get the window to behave what I
    > would call normally. Any help is much appreciated, thank you.
    >


    Hello Eryk

    Try the following code. Even if it is not the best way to resize the
    JFrame after the "setVisible()" command it would also work (I just
    tested this on linux).

    If the following code does not work as expected (draw a frame with
    300x300 pixel size), I don't have a solution for your problem.
    If the following code works, but your code still does not, please
    provide your code to analyze.

    greets

    -------------------------------------------

    import javax.swing.JFrame;

    public class SizeFrame {
    public SizeFrame() {
    JFrame jf = new JFrame("My Frame Title");
    jf.setSize(300, 300);
    jf.setVisible(true);
    }

    public static void main(String[] args) {
    new SizeFrame();
    }
    }
     
    Phi, Mar 21, 2007
    #2
    1. Advertising

  3. On Mar 21, 4:00 pm, Phi <> wrote:
    > Eryk wrote:
    > > When I create a new JFrame using the Swing library the window is
    > > always the smallest it can possibly be.


    Did you remember to put anything in it?

    Andrew T.
     
    Andrew Thompson, Mar 21, 2007
    #3
  4. Eryk

    Oliver Wong Guest

    "Eryk" <> wrote in message
    news:...
    > When I create a new JFrame using the Swing library the window is
    > always the smallest it can possibly be. It even hides some of the
    > title if it deems it necessary. I've tried solutions like custom
    > setting the size using setSize, but it disregards my settings there.
    > I'm not really sure what to do to get the window to behave what I
    > would call normally. Any help is much appreciated, thank you.
    >


    Google for "LayoutManager", "setPreferredSize" and "setMinimumSize".

    - Oliver
     
    Oliver Wong, Mar 21, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Big Daddy

    Java 1.2 Swing vs. Java 1.5 Swing

    Big Daddy, Apr 15, 2005, in forum: Java
    Replies:
    2
    Views:
    523
    Pete Barrett
    Apr 16, 2005
  2. mkrause
    Replies:
    0
    Views:
    701
    mkrause
    May 6, 2005
  3. lizard
    Replies:
    0
    Views:
    1,802
    lizard
    Jan 30, 2006
  4. S.T
    Replies:
    2
    Views:
    607
  5. Knute Johnson

    Swing is dead! Long live Swing.

    Knute Johnson, Feb 16, 2012, in forum: Java
    Replies:
    32
    Views:
    3,881
    Daniel Pitts
    Feb 29, 2012
Loading...

Share This Page