Java 导出到runnable jar时未打开JDialog
我一直试图使用JDialog作为我自己的输入窗口,不过当我通过eclipse启动程序时,它一切正常,没有任何问题,但当它是一个可运行的jar时就不行了 如果我将其导出为可运行的jar,程序本身也可以正常打开,但是当按下GUI上的按钮时,对话框根本没有打开,我没有收到任何错误,无论是在eclipse中(它工作正常),还是记录jar运行时发生的情况 这就是我的对话框的样子,当我四处寻找这个问题时,我发现人们根本没有让他们的jar运行,这不是我的问题,它运行得很好,其他一切都正常,但是这个对话框Java 导出到runnable jar时未打开JDialog,java,eclipse,Java,Eclipse,我一直试图使用JDialog作为我自己的输入窗口,不过当我通过eclipse启动程序时,它一切正常,没有任何问题,但当它是一个可运行的jar时就不行了 如果我将其导出为可运行的jar,程序本身也可以正常打开,但是当按下GUI上的按钮时,对话框根本没有打开,我没有收到任何错误,无论是在eclipse中(它工作正常),还是记录jar运行时发生的情况 这就是我的对话框的样子,当我四处寻找这个问题时,我发现人们根本没有让他们的jar运行,这不是我的问题,它运行得很好,其他一切都正常,但是这个对话框 pu
public class InputDialog extends JDialog
{
public JTextField name;
public InputDialog()
{
setTitle("Input");
initialize();
}
private void initialize() {
new JFrame("Anmelden");
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
this.setMinimumSize(new Dimension(500, 175));
this.name = new JTextField();
name.setBounds(74, 38, 380, 25);
this.setAlwaysOnTop(true);
this.setModal(true);
this.setLocationRelativeTo(null);
JButton add = new JButton("Ok");
add.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
}
});
add.setBounds(135, 74, 100, 50);
JButton cancel = new JButton("Abbrechen");
cancel.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
close();
}
}
);
cancel.setBounds(245, 74, 100, 50);
getContentPane().setLayout(null);
getContentPane().add(name);
getContentPane().add(add);
getContentPane().add(cancel);
JLabel lblNewLabel = new JLabel("<HTML><b>Anmelden</b></HTML>");
lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
lblNewLabel.setBounds(74, 11, 161, 16);
getContentPane().add(lblNewLabel);
name.requestFocus();
this.setVisible(true);
this.pack();
}
private void close()
{
this.dispose();
}
public类InputDialog扩展JDialog
{
公共JTextField名称;
公共输入对话框()
{
设置标题(“输入”);
初始化();
}
私有void初始化(){
新JFrame(“安梅尔登”);
此.setDefaultCloseOperation(JDialog.DISPOSE\u ON\u CLOSE);
此设置最小尺寸(新尺寸(500175));
this.name=new JTextField();
名称.立根(74,38,380,25);
此.setAlwaysOnTop(true);
此.setModal(true);
此.setLocationRelativeTo(空);
JButton add=新JButton(“确定”);
add.addActionListener(
新建ActionListener(){
已执行的公共无效操作(操作事件arg0){
}
});
增加立根(135,74,100,50);
JButton cancel=新JButton(“Abbrechen”);
cancel.addActionListener(
新建ActionListener()
{
已执行的公共无效操作(操作事件e)
{
close();
}
}
);
取消.退步(245,74,100,50);
getContentPane().setLayout(null);
getContentPane().add(名称);
getContentPane().add(添加);
getContentPane()。添加(取消);
JLabel lblNewLabel=新JLabel(“Anmelden”);
lblNewLabel.setFont(新字体(“Tahoma”,Font.PLAIN,13));
lblNewLabel.立根(74,11,161,16);
getContentPane().add(lblNewLabel);
name.requestFocus();
此.setVisible(true);
这个包();
}
私人作废关闭()
{
这个。dispose();
}