I add panel4
to scrollPane, but my application wasn't change. This is my code:
public class Bill extends JPanel {
//some Jlabels, JComboBox......
public Bill(){
JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayout(7,1,10,20));
//add some labels to panel
JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayout(7,4,10,10 ));
//add some components to panel
JPanel panel3=new JPanel(new GridLayout(4,1,10,10));
panel3.add(CRTA);
panel3.add(UKUPNO);
panel3.add(jbtView);
panel3.add(jbtCancel);
and finally panel4
JPanel panel4=new JPanel();
panel4.add(panel1, BorderLayout.WEST);
panel4.add(panel2, BorderLayout.CENTER);
JScrollPane scrollPane = new JScrollPane();
scrollPane.getViewport().add( panel4 );
add(scrollPane,BorderLayout.CENTER);
add(panel3, BorderLayout.SOUTH);
this is what I got
inside rectange is panel4( panel with numbers and comboboxes )
and this is when I change size
No scroll shows
Basically, you should add everything on panel4 (including panel3) and then add panel4 on JScrollPane
. After that, add that JScrollPane
on CENTER
of JTabbedPane
.
Also never call setXXXSize
methods on your JButton
's.
EDIT
I played a bit with your idea:
I hope this will help you about look of your UI. And again: Don't call setXXXSize
methods, let some other things to determine size of your component, like size of font in case of that JTextField
right to "Total" JLabel
or size of icons in these JButton
's in "Hot drinks" panel.