当前位置: 首页 > 知识库问答 >
问题:

从IDE Netbeans运行GUI程序的Java

万楷
2023-03-14

我正在用SWING用JAVA开发一个图形用户界面应用程序。当我试图从Netbean IDE运行图形用户界面时,我遇到了一个问题,一旦图形用户界面运行,我就无法在界面上点击或做任何事情,换句话说,我无法与用户界面交互。例如,当我尝试按下一个按钮时,它什么也不做,就像冻结一样,但是它不会显示任何错误,你可以正常关闭它(x图标)。这是一张照片

有人知道如何解决这个问题吗?

我用的是Ubuntu 14.04 LTS 64,

java版本“1 . 7 . 0 _ 75”open JDK运行时环境(iced tea 2 . 5 . 4)(7u 75-2 . 5 . 4-1 ~ trust y1)open JDK 64位服务器VM (build 24.75-b04,混合模式)

JAVAC 1.7.0_75

这是密码。它只是自动生成的代码。

public class MainPageAppUI extends javax.swing.JFrame {

/**
 * Creates new form MainPageAppUI
 */
public MainPageAppUI() {
    initComponents();
}

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
private void initComponents() {

    jPanel2 = new javax.swing.JPanel();
    jPanel1 = new javax.swing.JPanel();
    DiagnosticoButton = new javax.swing.JButton();
    NuevoPacienteButton1 = new javax.swing.JButton();
    PuntoAcupunturaButton = new javax.swing.JButton();
    PulsosButton = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Acupuntura");
    setBackground(new java.awt.Color(0, 0, 0));
    setEnabled(false);
    setResizable(false);

    jPanel2.setBackground(new java.awt.Color(255, 255, 255));
    jPanel2.setForeground(new java.awt.Color(255, 255, 255));

    DiagnosticoButton.setText("Diagnóstico");
    DiagnosticoButton.setToolTipText("");

    NuevoPacienteButton1.setText("Nuevo Paciente");
    NuevoPacienteButton1.setPreferredSize(new java.awt.Dimension(146, 29));
    NuevoPacienteButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            NuevoPacienteButton1ActionPerformed(evt);
        }
    });

    PuntoAcupunturaButton.setText("Puntos Acupuntura");
    PuntoAcupunturaButton.setToolTipText("");

    PulsosButton.setText("Pulsos");
    PulsosButton.setToolTipText("");

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addGap(23, 23, 23)
            .addComponent(NuevoPacienteButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(39, 39, 39)
            .addComponent(PuntoAcupunturaButton, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(44, 44, 44)
            .addComponent(DiagnosticoButton, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
            .addComponent(PulsosButton, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(30, 30, 30))
    );
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addGap(20, 20, 20)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(NuevoPacienteButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(PuntoAcupunturaButton, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(DiagnosticoButton, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(PulsosButton, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addContainerGap(22, Short.MAX_VALUE))
    );

    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(
        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
    jPanel2Layout.setVerticalGroup(
        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel2Layout.createSequentialGroup()
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(0, 333, Short.MAX_VALUE))
    );

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(0, 0, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );

    pack();
}// </editor-fold>                        

private void NuevoPacienteButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                                     
    System.out.println("You've pressed Nuevo paciente!");

}                                                    

/**
 * @param args the command line arguments
 */
public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(MainPageAppUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(MainPageAppUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(MainPageAppUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(MainPageAppUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new MainPageAppUI().setVisible(true);
        }
    });
}

// Variables declaration - do not modify                     
private javax.swing.JButton DiagnosticoButton;
private javax.swing.JButton NuevoPacienteButton1;
private javax.swing.JButton PulsosButton;
private javax.swing.JButton PuntoAcupunturaButton;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
// End of variables declaration                   
}

提前感谢!

暂时还没有答案

 类似资料:
  • 我过去经常用这样的命令运行程序: 然后我可以用我的Ubuntu系统的显示器运行wireshark。就像这个页面的例子:用docker运行GUI应用程序 现在它不工作了。当我运行wireshark时,我得到这个错误:

  • 问题内容: 我正在学习Java中的GUI,为此我创建了一个演示程序: 它已成功编译。但是,当我尝试执行程序时,发现以下错误: 我正在使用Xubuntu 10.10并给出: 我该怎么办? 还有一件事:这是我尝试执行Dr. Java和HJSplit的jar文件时遇到的错误。 问题答案: Ubuntu可以选择安装无头Java,这意味着无需图形库。并非总是如此,但是前几天我在尝试运行Java文本编辑器10

  • 我正在尝试使用Windows中的docker工具箱运行自定义java swing GUI。我现在想要容器化这个应用程序,但是得到以下错误: 我正在运行一个DockerFile。设置为: 3)复制到包含JAR的文件夹上 4)运行docker容器,该容器将启动GUI(不是linux前端,最好不使用vnc)。 我将Xlaunch用于windows上的终端,并且能够使用它在docker上启动一个firef

  • 问题内容: 我正在尝试围绕我的烧瓶应用程序为办公室中的菜鸟创建一个简单的tkinter GUI窗口。我希望脚本按以下顺序执行这些任务: 启动Flask Web服务器 用一个按钮打开一个tkinter GUI窗口。当按下时,该按钮将打开应用程序的索引页面(例如http://127.0.0.1:5000) 关闭tkinter gui窗口时终止flask Web服务器 到目前为止,这是我所拥有的,但是该

  • 问题内容: 所以我在这里有一个菜鸟般的时刻,我以前从未使用过命令行来运行Java程序,但现在我需要。我遇到的问题是,当我尝试运行程序时,出现ClassNotFoundException。我的课叫做OmadUpdate。我已经使用javac命令将OmadUpdate.java文件编译为OmadUpdate.class。我已经检查了目录,并且它们都绝对存在,但是当我运行java OmadUpdate命

  • 我下载了一个java程序,它由两个文件夹src和classes组成,分别包含源文件和类文件。现在,src和classes文件夹包含几个嵌套的子文件夹,其中最后一个子文件夹分别包含源文件和类文件。更准确地说,源文件和类文件的路径是src/edu/univ/。java和classes/edu/univ/。班假设包含main函数的文件是main。java,如何从命令行运行此程序。 我尝试过: 我也尝试过