Java 按钮赢了';我没有出现

Java 按钮赢了';我没有出现,java,button,Java,Button,为什么我的按钮没有出现?我想尽了一切办法。谁能看出我做错了什么 JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Object rowData[][] = {{"Row1-Column1", "Row1-Column2", "Row1-Column3"}, {"Row2-Column1", "Row2-Column2", "Row2-Column3"}}; Ob

为什么我的按钮没有出现?我想尽了一切办法。谁能看出我做错了什么

JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Object rowData[][] = {{"Row1-Column1", "Row1-Column2", "Row1-Column3"},
          {"Row2-Column1", "Row2-Column2", "Row2-Column3"}};
Object columnNames[] = {"Column One", "Column Two", "Column Three"};
JTable table = new JTable(buildTableModel(rs));

JButton quitButton = new JButton("Quit");
quitButton.setBounds(50, 60, 80, 30);
add(quitButton);
table.setEnabled(false);
table.setBounds(0, 100, 100, 100);

table.setAlignmentY(BOTTOM_ALIGNMENT);
JScrollPane scrollPane = new JScrollPane(table);
frame.add(scrollPane, BorderLayout.CENTER);
frame.setSize(600, 600);
frame.setVisible(true);
frame.setLocation(400, 100);

我想您忘了将按钮添加到内容窗格。

您根本没有将按钮添加到
JFrame
。您只需调用
add(quitButton)
,这意味着您在包含此方法的任何对象上调用它,而不是在框架上。

假定您使用的IDE对java.swing有特定的支持。*与netbeans或其他类似,您可以使用其内置工具来使用它,这防止了此类错误。

您是否在JTable中添加了按钮?谢谢您的回答,但您能否告诉我为什么我不能更改表格在框架中的位置,因为它总是占用所有空间。我试过:table.setBounds(0,100100100);-不工作| |表。getMaximumSize();-出于某种原因,我不能使用它。以上就是答案。当然可以再详细一点。