Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用JBUtton打开Jung Frame类_Java_Swing_Jframe_Jbutton_Jung2 - Fatal编程技术网

Java 如何使用JBUtton打开Jung Frame类

Java 如何使用JBUtton打开Jung Frame类,java,swing,jframe,jbutton,jung2,Java,Swing,Jframe,Jbutton,Jung2,我创建了一个名为“Display”的类和一个名为“SimpleGraphicView”的JFrame类,该类使用jung2。我正在尝试创建一个打开JFrame的按钮。 我尝试了以下代码 JButton btnInteractions = new JButton("DNetwork"); btnInteractions.addActionListener(new ActionListener() { public void actionPerformed(ActionEve

我创建了一个名为“Display”的类和一个名为“SimpleGraphicView”的JFrame类,该类使用jung2。我正在尝试创建一个打开JFrame的按钮。 我尝试了以下代码

JButton btnInteractions = new JButton("DNetwork");
    btnInteractions.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            if (comboBox.getSelectedItem().toString()
                    .equals("Hereditery Breast Cancer")) {
                SimpleGraphicView frame = new SimpleGraphicView();
                frame.setExtendedState(JFrame.NORMAL);
                frame.setSize(600, 600);
                frame.setVisible(true);
                frame.getContentPane();
            }
在JUung Frame类中

public void run() {
            try {
                SimpleGraphicView frame = new SimpleGraphicView();
                frame.setVisible(true);
                frame.getContentPane().***add(vv);***
                frame.pack();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });

但是Jung2框架中的内容没有显示。我该怎么做呢?

顶部代码和底部代码之间的关系是什么?第一个代码来自我想用Jbutton显示的类,第二个是框架。第二个来自Jung JFrame类。(要显示的帧)vv是什么?这似乎是您想要的,而不是SimpleGraphViewvv是jung类中的VisualizationViewer这是我的观点,我认为您想要在框架中创建VisualizationViewer的实例,而不是SimpleGraphViewer