HiHo...
kann mir von euch bitte mal einer helfen? und zwar hab ich folgendes problem: ich will immer das layout haben, welches ich in der combobox auswähle...also wenn ich in der combobox metal auswähle soll metal das layout sein usw. ... kann mir da bitte einer mal helfen? code folgt gleich...is nen recht keines proggie, eigentlcih nur zum testen, den rest, bzw. es in das große einbetten werd ich schon alleine schaffenwas mir fehlt sind die zeilen wo die fragezeichen sind...also im itemlistener...
hier der code:
import java.awt.*;
import java.awt.event.*;
import java.awt.Component.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.util.*;
import javax.swing.LookAndFeel.*;
import javax.swing.plaf.metal.MetalLookAndFeel;
import com.sun.java.swing.plaf.motif.MotifLookAndFeel;
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel ;
public class GuiTest extends JFrame implements ItemListener
{
String[] choices = {"Metal", "Motiv", "Windows"};
JSplitPane jSplitPane1 = new JSplitPane();
JScrollPane jScrollPane1 = new JScrollPane();
JComboBox toolSelector = new JComboBox();
JPanel pane = new JPanel();
GridBagLayout innerLayout = new GridBagLayout();
GridBagLayout gridBagLayout1 = new GridBagLayout();
TitledBorder border = BorderFactory.createTitledBorder(choices[0]);
JRadioButton jRadioButton1 = new JRadioButton();
JCheckBox jCheckBox1 = new JCheckBox();
JMenuBar jMenuBar1 = new JMenuBar();
JComboBox jComboBox1 = new JComboBox();
JSlider jSlider1 = new JSlider();
public GuiTest()
{
super("GUI_Test");
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
private void jbInit() throws Exception
{
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPL IT);
jSplitPane1.setAlignmentX((float) 0.5);
jSplitPane1.setAlignmentY((float) 0.5);
jSplitPane1.setMinimumSize(new Dimension(81, 63));
jSplitPane1.setPreferredSize(new Dimension(361, 155));
jSplitPane1.setDividerSize(1);
pane.setLayout(innerLayout);
this.getContentPane().setLayout(gridBagLayout1);
this.setFont(new java.awt.Font("Dialog", 0, 12));
this.setResizable(false);
jScrollPane1.setBorder(border);
jScrollPane1.setMaximumSize(new Dimension(2147483647, 2147483647));
jScrollPane1.setMinimumSize(new Dimension(91, 63));
jScrollPane1.setPreferredSize(new Dimension(91, 63));
jScrollPane1.setToolTipText("");
jRadioButton1.setText("klick it");
jCheckBox1.setText("check this");
this.getContentPane().add(jSplitPane1, new GridBagConstraints(0, 3, 3, 1, 1.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 0, 0));
jSplitPane1.add(jScrollPane1, JSplitPane.BOTTOM);
jSplitPane1.add(toolSelector, JSplitPane.TOP);
jScrollPane1.getViewport().add(pane);
pane.add(jRadioButton1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
pane.add(jCheckBox1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
pane.add(jComboBox1, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
pane.add(jSlider1, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
toolSelector.addItemListener(this);
jComboBox1.addItem("nummer01");
jComboBox1.addItem("nummer02");
jComboBox1.addItem("nummer03");
jComboBox1.addItem("nummer04");
jComboBox1.addItem("nummer05");
//ComboBox
for (int i=0; i<choices.length; i++)
{
toolSelector.addItem(choices[i]);
}
}
//ItemListener
public void itemStateChanged(ItemEvent e)
{
String source = (String)e.getItem();
if (source.equals(new String("Metal")))
{
//???????????????????????????
}
if (source.equals(new String("Motif")))
{
//???????????????????????????
}
if (source.equals(new String("Windows")))
{
//???????????????????????????
}
jScrollPane1.repaint();
}
public static void main(String[] args)
{
GuiTest f= new GuiTest();
f.pack();
f.setVisible(true);
}
}


was mir fehlt sind die zeilen wo die fragezeichen sind...also im itemlistener...
Zitieren