[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Resize JFrame/JDeskTopPane

Posted on 2006-07-02
4
Medium Priority
?
982 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
hiteshgupta1 earned 2000 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn different types of Android Layout and some basics of an Android App.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Progress

656 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