ich habe folgenden programmcode und möchte ein Jscrollpane zu einer Jlist hinzufügen.Leider klappt das nicht ganz so wie ich will, denn wenn ich es zur JList „unusedItemDevProp“ hinzufüge wird sie ausgeblendet
Hier mein CODE
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JPanel;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.Toolkit;
import java.awt.Color;
import javax.swing.JList;
import javax.swing.ListSelectionModel;
public class Window implements ActionListener {
static JFrame frmFigurePatchCreator;
static JFileChooser fc = new JFileChooser();
private JList unusedItemDevProp;
/\*\*
\* Launch the application.
\*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Window window = new Window();
frmFigurePatchCreator.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public static void FileChooser() {
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"Figure Thor Files", "bass", "lead");
Window.fc.setFileFilter(filter);
}
/\*\*
\* Create the application.
\*/
public Window() {
initialize();
}
/\*\*
\* Initialize the contents of the frame.
\*/
private void initialize() {
frmFigurePatchCreator = new JFrame();
frmFigurePatchCreator.getContentPane().setBackground(Color.GRAY);
frmFigurePatchCreator.setBackground(Color.DARK\_GRAY);
frmFigurePatchCreator
.setIconImage(Toolkit
.getDefaultToolkit()
.getImage(
"C:\\Users\\cweiss\\Desktop\\SRC\\tool\\figure\_icon.gif"));
frmFigurePatchCreator.setTitle("Figure Patch Creator");
frmFigurePatchCreator.setBounds(100, 100, 574, 637);
frmFigurePatchCreator.setDefaultCloseOperation(JFrame.EXIT\_ON\_CLOSE);
// Tabs
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
tabbedPane.setBackground(Color.GRAY);
frmFigurePatchCreator.getContentPane().add(tabbedPane);
// Dev Propreties
JPanel DevPropPanel = new JPanel();
DevPropPanel.setBackground(Color.DARK\_GRAY);
tabbedPane.addTab("Device Properties", DevPropPanel);
DevPropPanel.setLayout(null);
unusedItemDevProp = new JList(new String []{"1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1",});
unusedItemDevProp.setLayoutOrientation(JList.VERTICAL);
unusedItemDevProp.setValueIsAdjusting(true);
unusedItemDevProp.setSelectionMode(ListSelectionModel.SINGLE\_SELECTION);
unusedItemDevProp.setBounds(59, 42, 156, 228);
//JScrollPane scrollPane = new JScrollPane(unusedItemDevProp);
//scrollPane.add(unusedItemDevProp);
//DevPropPanel.add(scrollPane);
DevPropPanel.add(unusedItemDevProp);
}
// action Performed
public void actionPerformed(ActionEvent e) {
}
}
MOD: Pre-Tag eingefügt