javafx-swing应用程序不显示GUI

时间:2018-09-06 08:59:01

标签: swing javafx windows-server-2012

我有一个javafx-swing应用程序,在其中我将javafx嵌入到了webview中。

登录到该应用程序后,应该会显示该网页,但该网页不会显示在Windows Server 2012中,而是显示其他Windows 7和Windows 10。

public class MainPage1 extends JFrame {

    /**
     * 
     */

    private JPanel contentPane;  




    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    MainPage1 frame = new MainPage1();
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the frame.
     * @throws InterruptedException 
     * @throws SQLException 
     * @throws ClassNotFoundException 
     */
    public MainPage1() throws ClassNotFoundException, SQLException, InterruptedException {
        setFont(new Font("Tahoma", Font.BOLD, 20));
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 871, 488);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(contentPane);
        contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.X_AXIS));

        JPanel mainpanel = new JPanel();
        contentPane.add(mainpanel);
        mainpanel.setLayout(new BorderLayout(0, 0));

        JPanel panel = new JPanel();
        mainpanel.add(panel);
        GridBagLayout gbl_panel = new GridBagLayout();
        gbl_panel.columnWidths = new int[] {900, 200};
        gbl_panel.rowHeights = new int[] {0};
        gbl_panel.columnWeights = new double[]{0.0, 0.0, 1.0};
        gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, 1.0};
        panel.setLayout(gbl_panel);

        JPanel leftpanel = new JPanel();
        leftpanel.setBackground(Color.LIGHT_GRAY);
        GridBagConstraints gbc_leftpanel = new GridBagConstraints();
        gbc_leftpanel.insets = new Insets(0, 0, 0, 5);
        gbc_leftpanel.gridheight = 4;
        gbc_leftpanel.gridwidth = 2;
        gbc_leftpanel.fill = GridBagConstraints.BOTH;
        gbc_leftpanel.gridx = 0;
        gbc_leftpanel.gridy = 0;
        panel.add(leftpanel, gbc_leftpanel);
        leftpanel.setLayout(new BorderLayout(0, 0));
         //To add web page
        final JFXPanel jfxPanel = new JFXPanel();
        leftpanel.add(jfxPanel);
        Platform.runLater( () -> { 
           WebView webView = new WebView();
           webView.getEngine().load( "https://127.0.0.1/" );
           jfxPanel.setScene( new Scene( webView ) );

        });

        leftpanel.repaint();
        leftpanel.revalidate();

        JPanel rightpanel = new JPanel();
        GridBagConstraints gbc_rightpanel = new GridBagConstraints();
        gbc_rightpanel.gridheight = 4;
        gbc_rightpanel.fill = GridBagConstraints.BOTH;
        gbc_rightpanel.gridx = 2;
        gbc_rightpanel.gridy = 0;
        panel.add(rightpanel, gbc_rightpanel);
        GridBagLayout gbl_rightpanel = new GridBagLayout();
        gbl_rightpanel.columnWidths = new int[]{0, 0};
        gbl_rightpanel.rowHeights = new int[] {100, 100, 100};
        gbl_rightpanel.columnWeights = new double[]{1.0, Double.MIN_VALUE};
        gbl_rightpanel.rowWeights = new double[]{1.0, 1.0, 1.0};
        rightpanel.setLayout(gbl_rightpanel);

        JPanel rightpanel1 = new JPanel();
        GridBagConstraints gbc_rightpanel1 = new GridBagConstraints();
        gbc_rightpanel1.insets = new Insets(0, 0, 5, 0);
        gbc_rightpanel1.fill = GridBagConstraints.BOTH;
        gbc_rightpanel1.gridx = 0;
        gbc_rightpanel1.gridy = 0;
        rightpanel.add(rightpanel1, gbc_rightpanel1);
        rightpanel1.repaint();
        rightpanel1.revalidate();
        rightpanel1.setLayout(new BorderLayout(0, 0));
        SdjTable st=new SdjTable();
        rightpanel1.add(st);
        rightpanel1.setVisible(true);
        st.setVisible(true);
    }
}

0 个答案:

没有答案