JTable 패널을 표시하는 데 문제가 있습니다. 여기 JTable을 표시 할 수 없습니다.
public class Item
{
String itemDesc = "";
float price = 0;
private itemType enmItemType;
Object[][] data = {{itemDesc, enmItemType , new Float(price)}};
.
.
.
.
}
이 테이블 클래스가 들어있는 JTable의 :
이
class Table extends JFrame
{
// Instance attributes used in this example
private JPanel topPanel;
private JTable table;
private JScrollPane scrollPane;
private JButton update_Button;
// Constructor of main frame
public Table()
{
// Set the frame characteristics
setTitle("Add new item");
setSize(300, 200);
setBackground(Color.gray);
// Create a panel to hold all other components
topPanel = new JPanel();
topPanel.setLayout(new BorderLayout());
getContentPane().add(topPanel);
// Create columns names
String columnNames[] = {"Item Description", "Item Type", "Item Price"};
// Create some data
Object dataValues[][] ;
Item itm = new Item();
dataValues = itm.data;
// Create a new table instance
table = new JTable(dataValues, columnNames);
////////////////////////////
JComboBox itemTypeCombobox = new JComboBox();
TableColumn column1 = table.getColumnModel().getColumn(1);
column1.setCellEditor(new DefaultCellEditor(itemTypeCombobox));
////////////////////////////
// Add the table to a scrolling pane
scrollPane = new JScrollPane(table);
topPanel.add(scrollPane, BorderLayout.CENTER);
JButton button = new JButton("Add Item");
topPanel.add(button, BorderLayout.SOUTH);
}
}
주요 프로그램은 다음과 같습니다
public static void main(String[] args)
{
Menu m = new Menu();
m.chooseMenu();
// Create an instance of the test application
Table mainFrame = new Table();
mainFrame.setVisible(true);
}
나는 어떤 오류가 표시되지 않는 나는 클래스와 객체 배열을 포함했다/경고하지만 여전히 테이블이 보이지 않습니다. 누군가가 문제의 원인을 직접 알려줄 수 있습니까?
감사합니다.
@Edan : 코드 서식을 향상 시키십시오. 'Blockquote (Ctrl + q) '대신'Code Sample (Ctrl + K)'를 사용하십시오. –
나는 다음에 ... – firestruq
내가 컴파일 오류를 가지고 있기 때문에 이번에는 .. 코드를 편집 할 수 있습니다. – bragboy