Følgende kode er en JFrame indeholdende nogle værdier, jeg vil gerne ha'
indsat et JScrollPane. Jeg har fået det til at virke på en anden JFrame, men
af en eller anden grund vil det ikke virke på denne klasse:
public class DispersionPopUp extends JFrame
{
....
private JPanel mainPane;
private JPanel pane;
private JPanel confirmPanel;
private JPanel dispersionPanel1;
private JPanel dispersionPanel2;
private JPanel dispersionPanel3;
public DispersionPopUp(String coreName, Network network)
{
super("Insert rps and network dispersion");
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
.....
dispersionPanel1 = new JPanel();
GridLayout dispersionPanelLayout1 = new
GridLayout(network.getNodes().length+1,1,5,5);
dispersionPanel1.setLayout(dispersionPanelLayout1);
dispersionPanel2 = new JPanel();
GridLayout dispersionPanelLayout2 = new
GridLayout(network.getNodes().length+1,1,5,5);
dispersionPanel2.setLayout(dispersionPanelLayout2);
dispersionPanel3 = new JPanel();
GridLayout dispersionPanelLayout3 = new
GridLayout(network.getNodes().length+1,1,5,5);
dispersionPanel3.setLayout(dispersionPanelLayout3);
JScrollPane scrollPanel = new JScrollPane(pane,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
dispersionPanel1.add(nodeNameLabel);
dispersionPanel2.add(requestLabel);
dispersionPanel3.add(rpsLabel);
int j =0;
for (int i=0;i<network.getNodes().length;i++)
{
if (coreName.equals(network.getNode(i).getName()))
{
}
else
{
nodeNamesLabel[j] = new JLabel(network.getNode(i).getName());
dispersionPanel1.add(nodeNamesLabel[j]);
networkDispersionLabel[j] = new JLabel("Request dispersion in %:");
dispersionPanel2.add(networkDispersionLabel[j]);
networkDispersion[j] = new JTextField("0",3);
dispersionPanel3.add(networkDispersion[j++]);
}
}
okButton = new JButton("OK");
cancelButton = new JButton("CANCEL");
okButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
setDispersionValues();
System.out.println("TESTING");
}
});
cancelButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.out.println("CLOSE THIS SHIT!");
}
});
confirmPanel.add(okButton);
confirmPanel.add(cancelButton);
pane.add("West", dispersionPanel1);
pane.add("Center", dispersionPanel2);
pane.add("East", dispersionPanel3);
pane.add("South", confirmPanel);
mainPane.add("Center", scrollPanel);
scrollPanel.add(pane);
setContentPane(pane);
}
Jeg håber at I kan hjælpe, jeg er ved at blive sindsyg!
Mvh. Fihnn
|