• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 993
  • Last Modified:

Resize JFrame/JDeskTopPane

I have added components like JLabel, JTextFiled etc. to a JFrame/JDesktopPane. When the JDesktopPane is resized I want all components to be resized accordingly

How can I achieve this.
0
sree032397
Asked:
sree032397
  • 2
1 Solution
 
hiteshgupta1Commented:
public static void main(String args[])

  {

    JFrame f = new JFrame();
    JLayeredPane layeredPane = new JLayeredPane();
    //layeredPane.setPreferredSize(new Dimension(50, 50));
    layeredPane.setBorder(BorderFactory.createTitledBorder(
                        "Move the Mouse to Move Duke"));


    JButton button = new JButton("test");
    //button.setBounds(120,120,120,120);
    layeredPane.setLayout(new BorderLayout());
    layeredPane.setLayer(button , JLayeredPane.DEFAULT_LAYER.intValue());
    layeredPane.add(button);
    f.getContentPane().add(layeredPane);

    f.pack();
    f.show();

}

The button resizes as the frame is resized

I think by default the layout for layeredpane is null
if you set the layout to layout manager you need
then it should behave just like
Layout manager is supposed to
0
 
hiteshgupta1Commented:
Hi Venabili

No objection  from my side

Thanks
Hitesh
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now