JFrame does not automatically resizes to JLabel's length

From: Viet Yen Nguyen (vietyen)
Date: 12/24/03

  • Next message: VisionSet: "Re: JFrame does not automatically resizes to JLabel's length"
    Date: Wed, 24 Dec 2003 20:59:14 +0100
    
    

    Hi,

    I am using three JLabel's on a row using the BorderLayout. The texts of the
    JLabel's varies by size, which depends on user input. Unfortunaly, when the
    JLabel in the center of the BorderLayout (BorderLayout.CENTER) gets too
    large, it gets truncated and appended by three dots (...).

    It seems that running pack on JFrame after every JLabel.setText() does solve
    the problem, however, it isn't a really clean way because in that case the
    JLabel must be aware of the JFrame, which shouldn't be necessary.

    So to make a long story short, I would like a way so that the JFrame gets
    automatically resized when there is a shortage of space for the components,
    without having to call pack().

    I have tried to invalidate the JLabel, but that doesn't seem to do it.
    Neither changing the LayoutManager, which gives bizarre results.

    Thanks in advance,

    Viet Yen Nguyen


  • Next message: VisionSet: "Re: JFrame does not automatically resizes to JLabel's length"

    Relevant Pages

    • Re: JFrame does not automatically resizes to JLabels length
      ... > I am using three JLabel's on a row using the BorderLayout. ... > JLabel must be aware of the JFrame, ... getPreferredSize() will be called which so long ...
      (comp.lang.java.gui)
    • Re: odd mouselistener issue
      ... I've got a JFrame with borderlayout. ... So all I can do is give you an example of how to add a MouseListener to a JPanel. ... Don't forget that BorderLayout will cause your component to expand to the size of your container. ... public static void main{ ...
      (comp.lang.java.programmer)
    • Havnig a problem resizing a JLabel with MouseMotionListener.
      ... I have a JTable embedded in a JLabel. ... My problem is that I wish to allow resizing of the JLabel ... The JFrame already has resizing functionality. ... my goal is to allow the user to resize the JTable. ...
      (comp.lang.java.gui)
    • Using GridBagLayout with JFrame
      ... gridbaglayout if possible) so that when the JFrame pops up, ... 'white space' between the JLabel and JButton. ... the JLabel and JButton are on top of one another. ...
      (comp.lang.java.programmer)
    • Re: Java Swings: Adding JButton to JFrame
      ... button to the CENTER of the borderlayout. ... It's worth noting that add and setLayout on JFrame and certain other classes don't do what they appear to. ... Yes, the BorderLayout will leave the first component alone, not changing its bounds at all. ... So if you show the frame and latter add the second component, then the first component will stay where it was when the second was added. ...
      (comp.lang.java.programmer)