我有一个java应用程序,它在JFrame中有一个JTabbedPane。
我想模拟firefox选项卡。当您运行applet时,它会以某种方式为该applet启动一个新进程,当您终止该选项卡时,该进程将终止。我想为组件类做这个。
目前我有:
package pkgmessaging;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
public class Frame extends javax.swing.JFrame {
private final JTabbedPane TabPane = new JTabbedPane();
private ArrayList<Message> Messages = new ArrayList<>();
public Frame() {
this.add(TabPane);
this.pack();
this.setVisible(true);
this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
}
public void addMessage() {
//Message is a JPanel that holds other components.
Message C = new Message(); //Some how create this in a new Process/JVM and add it to my JTabbedPane.
this.Messages.add(C);
this.addTab(TabPane, "One", C);
this.pack();
}
private void addTab(final String Title, final Component component) {
//To other stuff here..
CloseButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
synchronized (Frame.this.TabPane) {
TabPane.remove(component);
//Some how close the process/jvm here.
}
}
});
}
}
那么如何在新进程/ jvm中运行一个类并将其添加到我的JTabbedPane?我需要JNI吗?如果是这样,我会看到什么?我只需要知道在哪里寻找以及如何开始。