Help coderanch get a
new server
by contributing to the fundraiser

Dhilshuk Reddy Jeeru

Greenhorn
+ Follow
since Sep 19, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Dhilshuk Reddy Jeeru

Hello Darya Akbari ,
You mean that title is more important than what content is.If that is the case some other people who are good at Framing words will fit than Romain and Chet.
Romain and Chet are excellent guys rather than concentrating much on title look for the content.
16 years ago
Juhan Voolaid ,
Here is the trick for your problem which I faced many many times.
step1:Have your contentPanel as a mainPanel to which added JScrollPane
JPanel contentPanel = new JPanel();

step2:Have seperate panel which holds your others components.
JPanel componentsPanel = new JPanel();
JLabel nameLabel = new JLabel("Name");
JTextField nameTextField = new JTextField(10);
componentsPanel.add(nameLabel);
componentsPanel.add(nameTextField );
step3:add that seperate panel to JScrollPane using setViewportView(JComponent jc) method of the JScrollPane.
JScrollPane contentScrollPane = new JScrollPane();
contentScrollPane.setViewportView(componentsPanel);
contentPanel.add(contentScrollPane);
JFrame frame = new JFrame();
frame.add(contentPanel);
frame.setSize(300,300);
frame.setVisible(true);


Each time you create new components mantain all that components in JPanel and again call the setViewportView(JComponent) method.
supoose I create new Panel componentsPanel2 during runtime add to contentPanel:
code below:
JPanel componentsPanel2 = new JPanel();
JLabel passwordLabel = new JLabel("Password");
JTextField passwordTextField = new JTextField(10);
componentsPanel2.add(passwordLabel);
componentsPanel2.add(passwordTextField);
contentScrollPane.setViewportView(componentsPanel2);

This make your components visible without any resize of your JFrame.

Try with this if you don't get it I will post to you the entire sample code of small demo.
Please let me know.
regards,
Dhilshuk Reddy.
16 years ago