Professor_Zed
Professor_Zed

Reputation: 1

Qt Jambi in Swing application

I'm trying to create a swing application (which I already did) which has 2 windows, the first window is the main one, the second one is where Qt Jambi comes in with QWebView. I'm trying to make the second window display a HTML page using Qt Jambi's QWebView, but its giving me errors whenever trying to launch the application.

Here's my code..

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();
   }
}

and this is my main class:

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);
        ...
    }
}

Upvotes: 0

Views: 328

Answers (0)

Related Questions