czy ktoś mógłby mi powiedzieć, dlaczego po przekompilowaniu poniższego kodu lista, mimo że ma 3 elementy jest strasznie mocno rozwijana??
wklejam kod:
[code]import javax.swing.;
import java.awt.;
import java.awt.event.*;
public class CDialog
{
public static void DodajNaPanel(Container pane)
{
JList lista;
ListSelectionModel listSelectionModel;
JButton przycisk;
JLabel label;
JTextField poletextowe;
pane.setLayout(new GridBagLayout());
GridBagConstraints ogrn = new GridBagConstraints();
ogrn.fill=GridBagConstraints.NONE;
label = new JLabel("JButton1");
ogrn.weightx=0.5; //przerwa miedzy przyciskiem
ogrn.gridx = 0; //umiesc w x = 0
ogrn.gridy = 0; //umiesc w y = 0
pane.add(label,ogrn);
poletextowe = new JTextField(20);
ogrn.gridx = 1;
ogrn.gridy = 0;
pane.add(poletextowe,ogrn);
label = new JLabel("JButton2");
ogrn.weightx=0.5; //przerwa miedzy przyciskiem
ogrn.gridx = 0; //umiesc w x = 0
ogrn.gridy = 1; //umiesc w y = 0
pane.add(label,ogrn);
poletextowe = new JTextField(20);
ogrn.gridx = 1;
ogrn.gridy = 1;
pane.add(poletextowe,ogrn);
label = new JLabel("JButton3");
ogrn.weightx=0.5; //przerwa miedzy przyciskiem
ogrn.gridx = 0; //umiesc w x = 0
ogrn.gridy = 2; //umiesc w y = 0
pane.add(label,ogrn);
poletextowe = new JTextField(20);
ogrn.gridx = 1;
ogrn.gridy = 2;
pane.add(poletextowe,ogrn);
label = new JLabel("JButton4");
ogrn.weightx=0.5; //przerwa miedzy przyciskiem
ogrn.gridx = 0; //umiesc w x = 0
ogrn.gridy = 3; //umiesc w y = 0
pane.add(label,ogrn);
poletextowe = new JTextField(20);
ogrn.gridx = 1;
ogrn.gridy = 3;
pane.add(poletextowe,ogrn);
label = new JLabel("JButton5");
ogrn.weightx=0.5; //przerwa miedzy przyciskiem
ogrn.gridx = 0; //umiesc w x = 0
ogrn.gridy = 4; //umiesc w y = 0
pane.add(label,ogrn);
poletextowe = new JTextField(20);
ogrn.gridx = 1;
ogrn.gridy = 4;
pane.add(poletextowe,ogrn);
label = new JLabel("JButton6");
ogrn.weightx=0.5; //przerwa miedzy przyciskiem
ogrn.gridx = 0; //umiesc w x = 0
ogrn.gridy = 5; //umiesc w y = 0
pane.add(label,ogrn);
poletextowe = new JTextField(20);
ogrn.gridx = 1;
ogrn.gridy = 5;
pane.add(poletextowe,ogrn);
przycisk = new JButton("OK");
ogrn.weightx=0.5; //przerwa miedzy przyciskiem
ogrn.gridx = 1; //umiesc w x = 0
ogrn.gridy = 6; //umiesc w y = 0
pane.add(przycisk,ogrn);
label = new JLabel(" ");
ogrn.weightx=0.5; //przerwa miedzy przyciskiem
ogrn.gridx = 2; //umiesc w x = 0
ogrn.gridy = 2; //umiesc w y = 0
ogrn.insets = new Insets (0,10,0,0);
pane.add(label,ogrn);
String[] kolorki = {"Czerwony", "Zielony", "Niebieski"};
lista = new JList(kolorki);
listSelectionModel = lista.getSelectionModel();
listSelectionModel.setSelectionMode(
ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
JScrollPane listPane = new JScrollPane(lista,ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
ogrn.gridx = 3;
ogrn.gridy = 0;
ogrn.gridheight = 7;
pane.add(listPane,ogrn);
}
private static void pokazOkno()
{
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame okno = new JFrame("worki");
okno.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
DodajNaPanel(okno.getContentPane());
okno.pack();
okno.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
pokazOkno();
}
});
}
}
[/code]
chodzi mi o to, zeby to bylo wyswietlone tak: