我想在我的两个JPanel之间存储变量(id_Category),因为我需要在第二个Jpanel上处理它的值 这是第一个JPanel
public class PreparerTest extends JPanel
int idCategorie;
public void mouseClicked(MouseEvent e) {
idCategorie = categories.get(table.getSelectedRow()).getId();
第二个JPanel
public class PreparerTestManuelle extends JPanel {
JButton btnAfficher = new JButton("Afficher");
btnAfficher.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
questions=GestionTestDelegate.doPrepareManuallyTest(the id is supposed to be here, nombreQuestion.getText());
}
});
答案 0 :(得分:0)
两个JPanel都属于同一个类吗?如果是,您应该创建如下字段:public int idCategorie;
而且你可以在任何你想要的地方使用它