値を持つ列挙型を含むクラスがあります。(名前)他のクラスでは、これらの列挙値を使用するJComboboxのセルタイプをテーブル内に入力したいと思います。私の問題は、文字列値と列挙型を組み合わせることにあります。たとえば、列挙型クラス:
列挙型item_Type{メインディッシュ、メインディッシュ、デザート、ドリンク}
たとえば、テーブルクラス:setTitle( "Add new item"); setSize(300、80); setBackground(Color.gray);
// Create a panel to hold all other components
topPanel = new JPanel();
topPanel.setLayout( new BorderLayout() );
getContentPane().add( topPanel );
//new JComboBox(item_Type.values());
JComboBox aaa = new JComboBox();
aaa = new JComboBox(item_Type.values());
TableColumn sportColumn = table.getColumnModel().getColumn(2);
// Create columns names
String columnNames[] = {"Item Description", "Item Type", "Item Price"};
// Create some data
String dataValues[][] = {{ "0", aaa, "0" }};
// Create a new table instance
table = new JTable( dataValues, columnNames );
// Add the table to a scrolling pane
scrollPane = new JScrollPane( table );
topPanel.add( scrollPane, BorderLayout.CENTER );
dataValues配列では、aaa(列挙型jcombobox)を使用できないことを知っています。どうやってやるの?
前もって感謝します。