Qt Jambi在Swing应用程序中

时间:2015-09-26 21:03:04

标签: java swing qt jambi

我试图创建一个拥有2个窗口的swing应用程序(我已经做过),第一个窗口是主窗口,第二个窗口是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);
        ...
    }
}

0 个答案:

没有答案