0

我有JInternalFrame包含JTable. 如何刷新JInternalFrameJTable单击时JButton ---> update

4

2 回答 2

2

当你更新你的TableModelJTable应该会自动刷新。如果不是,您TableModel应该更正,例如.

于 2012-09-23T13:04:17.257 回答
0

最简单的方法是调用.repaint()actionlistener。例如:

public class RefreshingButton extends JButton implements ActionListener{
    private static final long serialVersionUID = 1L;
    private final JComponent componentToRefsesh;

    public RefreshingButton(JComponent toRefresh) {
        super("Refresh JTable");
        this.componentToRefsesh = toRefresh;
        this.addActionListener(this);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        componentToRefsesh.repaint();
    }
}

最好的方法是使用模型-视图-控制器设计模式。http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller

于 2012-09-23T12:36:27.897 回答