我正在尝试创建一个具有 2 个窗口的摇摆应用程序(我已经这样做了),第一个窗口是主窗口,第二个窗口是 Qt Jambi 与 QWebView 一起出现的地方。我正在尝试使用 Qt Jambi 的 QWebView 使第二个窗口显示一个 HTML 页面,但它在尝试启动应用程序时给我错误。
这是我的代码..
import com.trolltech.qt.core.*;
import com.trolltech.qt.gui.*;
import com.trolltech.qt.webkit.*;
public class links extends QMainWindow {
private QWebView webView;
public links() { this(null); }
public links(QWidget parent) {
super(parent);
webView = new QWebView();
setCentralWidget(webView);
}
public void loadUrl(String url) {
webView.load(new QUrl(url));
}
public static void main(String[] args) {
QApplication.initialize(args);
links app = new links();
app.loadUrl("http://www.hypixel.net");
app.show();
QApplication.execStatic();
}
}
这是我的主要课程:
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Image;
import java.awt.SystemColor;
import java.awt.TextArea;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.WindowConstants;
public class Reporter {
private JFrame frame;
private JComboBox<String> comboBoxPerm;
private JTextArea textAreaResult;
private TextArea textAreaProof;
private TextArea textAreaOffense;
private JComboBox<String> comboBoxColor;
private JLabel lblName;
private JLabel lblProof;
private JLabel lblOffense;
private JLabel lblDoYouGive;
private JComboBox<String> comboBoxRank;
private JLabel lblRank;
private TextArea textAreaName;
public static void main(String[] args) {
links linksob = new links();
linksob.setVisible(true);
linksob.setBaseSize(400, 150);
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Reporter window = new Reporter();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public Reporter() {
initialize();
}
private void initialize() {
frame = new JFrame();
frame.getContentPane().setForeground(SystemColor.desktop);
frame.setBounds(100, 100, 812, 482);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
java.net.URL url = this.getClass().getResource("/logo2.png");
Toolkit kit = Toolkit.getDefaultToolkit();
Image img2 = kit.createImage(url);
frame.setIconImage(img2);
...
}
}