Solved

Resize JFrame/JDeskTopPane

Posted on 2006-07-02
4
959 Views
Last Modified: 2008-01-16
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
Comment
Question by:sree032397
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
hiteshgupta1 earned 500 total points
ID: 17029618
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
 
LVL 8

Expert Comment

by:hiteshgupta1
ID: 17239178
Hi Venabili

No objection  from my side

Thanks
Hitesh
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sumDigits  challenge 7 75
Turning python script into an applet 12 106
Path to Python 9 110
Programatically extract date from website 8 68
A short article about problems I had with the new location API and permissions in Marshmallow
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now