我想创建一个新窗口,其中包含JTable
按 a 的结果JMenuItem
,我尝试在动作侦听器中创建一个新类,但不确定它有多正确。反正不管用,求指教。
...
help.add(currencyTable);
...
//action listener for the currency table JMenuItem button
currencyTable.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e)
{
class currencyJTableClass extends JFrame
{
JTable currencyTable;
public currencyJTableClass()
{
setLayout(new FlowLayout());
String[] headLine = {"x","y","z"} ;
String [][] currencyData =
{
{
"a","b","c"
},
{
"d","e","f"
},
};
currencyJTable = new JTable(currencyData,headLine);
}
}