gpt4 book ai didi

java - jFormDesigner 设计后无法显示?

转载 作者:行者123 更新时间:2023-12-01 15:20:43 25 4
gpt4 key购买 nike

import java.awt.*;
import javax.swing.*;
import javax.swing.GroupLayout;

/**
* @author Ene Ion
*/
public class launcher extends JFrame {

public launcher() {
initComponents();
}

private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
// Generated using JFormDesigner Evaluation license - Ene Ion
mbmlauncherfata = new JFrame();
textField1 = new JTextField();
checkBox1 = new JCheckBox();
label1 = new JLabel();
comboBox1 = new JComboBox();
label2 = new JLabel();
comboBox2 = new JComboBox();
button1 = new JButton();
button2 = new JButton();
button3 = new JButton();
progressBar1 = new JProgressBar();
label3 = new JLabel();
label4 = new JLabel();
button4 = new JButton();
button5 = new JButton();
label5 = new JLabel();
button6 = new JButton();

//======== mbmlauncherfata ========
{
mbmlauncherfata.setTitle("MBMLauncher");
mbmlauncherfata.setIconImage(new ImageIcon("E:\\Chituri\\MBMLauncherJava\\src\\resursele\\icon_4_64x64x32.png").getImage());
mbmlauncherfata.setResizable(false);
Container mbmlauncherfataContentPane = mbmlauncherfata.getContentPane();

//---- textField1 ----
textField1.setText("Username");
textField1.setForeground(new Color(153, 0, 0));

//---- checkBox1 ----
checkBox1.setText("Remember Me");

//---- label1 ----
label1.setText("RAM Allocated");

//---- comboBox1 ----
comboBox1.setModel(new DefaultComboBoxModel(new String[] {
"256M",
"512M",
"1024M",
"2G",
"3G",
"4G"
}));

//---- label2 ----
label2.setText("to");

//---- comboBox2 ----
comboBox2.setModel(new DefaultComboBoxModel(new String[] {
"512M",
"1024M",
"2G",
"3G",
"4G",
"5G",
"6G"
}));

//---- button1 ----
button1.setText("Play");
button1.setFont(new Font("Snap ITC", Font.BOLD, 36));
button1.setForeground(new Color(255, 102, 0));

//---- button2 ----
button2.setText("Update Game");

//---- button3 ----
button3.setText("Update Launcher");

//---- label3 ----
label3.setText("Download status:");

//---- label4 ----
label4.setText("Nothing in download");

//---- button4 ----
button4.setText("Texture Packs");

//---- button5 ----
button5.setText(".game");

//---- label5 ----
label5.setText("Drag and drop your texture\npack in the box *.zip files");
label5.setIcon(new ImageIcon("E:\\Chituri\\MBMLauncherJava\\src\\resursele\\dasdasdasd.png"));

//---- button6 ----
button6.setText("Made By Malasuerte94");

GroupLayout mbmlauncherfataContentPaneLayout = new GroupLayout(mbmlauncherfataContentPane);
mbmlauncherfataContentPane.setLayout(mbmlauncherfataContentPaneLayout);
mbmlauncherfataContentPaneLayout.setHorizontalGroup(
mbmlauncherfataContentPaneLayout.createParallelGroup()
.addGroup(mbmlauncherfataContentPaneLayout.createSequentialGroup()
.addContainerGap()
.addGroup(mbmlauncherfataContentPaneLayout.createParallelGroup()
.addComponent(progressBar1, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(button1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(mbmlauncherfataContentPaneLayout.createSequentialGroup()
.addComponent(button2, GroupLayout.PREFERRED_SIZE, 131, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(button3, GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE))
.addGroup(mbmlauncherfataContentPaneLayout.createSequentialGroup()
.addComponent(button4, GroupLayout.PREFERRED_SIZE, 130, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(button5, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(mbmlauncherfataContentPaneLayout.createSequentialGroup()
.addComponent(textField1, GroupLayout.PREFERRED_SIZE, 136, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(checkBox1))
.addGroup(mbmlauncherfataContentPaneLayout.createSequentialGroup()
.addComponent(label1)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(comboBox1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(label2)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(comboBox2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(mbmlauncherfataContentPaneLayout.createSequentialGroup()
.addComponent(label3, GroupLayout.PREFERRED_SIZE, 96, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(label4))
.addComponent(label5, GroupLayout.PREFERRED_SIZE, 270, GroupLayout.PREFERRED_SIZE)
.addComponent(button6, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
mbmlauncherfataContentPaneLayout.setVerticalGroup(
mbmlauncherfataContentPaneLayout.createParallelGroup()
.addGroup(mbmlauncherfataContentPaneLayout.createSequentialGroup()
.addContainerGap()
.addGroup(mbmlauncherfataContentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(checkBox1)
.addComponent(textField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(mbmlauncherfataContentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(label2)
.addComponent(comboBox2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(label1)
.addComponent(comboBox1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(button1)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(mbmlauncherfataContentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(button2)
.addComponent(button3))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(progressBar1, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(mbmlauncherfataContentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(label4)
.addComponent(label3))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(mbmlauncherfataContentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(button4)
.addComponent(button5))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(label5)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(button6, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
.addContainerGap(10, Short.MAX_VALUE))
);
mbmlauncherfata.setSize(305, 395);
mbmlauncherfata.setLocationRelativeTo(null);
}
// JFormDesigner - End of component initialization //GEN-END:initComponents
}

// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// Generated using JFormDesigner Evaluation license - Ene Ion
private JFrame mbmlauncherfata;
private JTextField textField1;
private JCheckBox checkBox1;
private JLabel label1;
private JComboBox comboBox1;
private JLabel label2;
private JComboBox comboBox2;
private JButton button1;
private JButton button2;
private JButton button3;
private JProgressBar progressBar1;
private JLabel label3;
private JLabel label4;
private JButton button4;
private JButton button5;
private JLabel label5;
private JButton button6;
// JFormDesigner - End of variables declaration //GEN-END:variables

public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
launcher GUI = new launcher();
GUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GUI.setVisible(true);
}
});
}



}

结果是一个空的 java 框.. picture我尝试解决这个问题,但我是 java 脚本编写的初学者,问题出在哪里以及如何解决它?感谢您的帮助,请向我推荐一些好的 Eclipse 插件。

最佳答案

这通常发生在框架未打包时。

试试这个:

launcher GUI = new launcher();
GUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GUI.pack(); // <=========== PACK
GUI.setVisible(true);

Here是一个很好的教程,它将帮助您开始使用 Java 框架。

关于java - jFormDesigner 设计后无法显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10964297/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com