我一直在开发一个Java Swing项目,需要获取创建面板的对象/实例,以便调用特定于该实例的简单保存方法。您有一个带有JTabbedPane的JFrame,其中的选项卡是通过实例化一个类来创建的,该类构建了一个JPanel并将其添加到JTabbedPane中,我需要从所选JPanel /选项卡中找到特定的实例,然后调用它的保存方法。 有什么想法吗?感谢您的时间!
public class frame extends JFrame implements ActionListener{
Builds a frame dubbed "frame" that is static.
Builds a static JTabbedPane dubbed "pane"and adds it to the frame.
Creates a button that creates a new instance of sheet.
public void actionPerformed(MAGIC!){
See if a button on the panel has been pressed and uses the currently selected tab to locate the correct instance of sheet to run it's save method.
}
}
public class sheet extends JPanel{
In constructor makes a JPanel and adds it to "pane"
Describes a save method that outputs a variable unique to the instance.
}