当我点击一个按钮时,我需要将一个类的JFrame实现到另一个类中。
这是我的代码:
public class Test6 extends JFrame implements Runnable {
private static final String DB_PATH = "C:/testtest";
private static GraphDatabaseService graphDb;
Graph graph;
Viewer viewer;
View view;
public JPanel contentPane1;
public void run() {
Transaction tx = graphDb.beginTx();
try
{
contentPane1 = new JPanel();
contentPane1.setBackground(Color.DARK_GRAY);
contentPane1.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane1.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane1);
JPanel panelSettings = new JPanel();
panelSettings.setBorder(new EmptyBorder(0, 8, 0, 8));
panelSettings.setBackground(SystemColor.activeCaption);
panelSettings.setLayout(new BorderLayout(0, 0));
contentPane1.add(panelSettings, BorderLayout.WEST);
viewer.enableAutoLayout();
view = viewer.addDefaultView(false);
contentPane1.add(view);
setSize(800, 600);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
,其他类代码是:
public class GraphTest2 extends JFrame implements ActionListener
{
public GraphTest2()
{
Init();
}
public void Init()
{
contentPane = new JPanel();
contentPane.setBackground(Color.DARK_GRAY);
contentPane.setBorder(new EmptyBorder(0,0,0,0));
contentPane.setLayout(new BorderLayout(8,0));
setContentPane(contentPane);
JPanel panelSettings = new JPanel();
panelSettings.setLayout(new GridLayout(20,1,0,0));
panelSettings.add(b1);
public void actionPerformed(ActionEvent e) {
if(e.getSource()==b1){
}
我试图使用内部框架,但我不知道如何在我的代码中实现它。 感谢您的时间和帮助。