我想在我的两个 JPane 之间存储变量 (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());
}
});
两个 JPanels 在同一个类中吗?如果是,您应该创建如下字段:public int idCategorie;
而且您可以在任何地方在课堂上使用它