Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more: , +
Java
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);
            }
        });
    }



}

Result is a empty java box.. I try to fix this problem but i am beginer in java scripting, where is the problem and how i can fix it ? Tanks for helping, and recomand me please some good plugins for Eclipse.
PICTURE
Posted

1 solution

Look at the code above and tell me what is readable and what can not be read.
now you know where the failure is. That is also where the layout is done and where your components loose ground.

Java
 Container mbmlauncherfataContentPane = mbmlauncherfata.getContentPane();

// init of components

GroupLayout mbmlauncherfataContentPaneLayout = new GroupLayout(mbmlauncherfataContentPane);
mbmlauncherfataContentPane.setLayout(mbmlauncherfataContentPaneLayout);
mbmlauncherfataContentPaneLayout.setHorizontalGroup(
  //fancy Layout
);


in the first line you are creating the ContentPane "mbmlauncherfataContentPane" with the ContentPane from the JFrame and create your own party. Fact is, that the JFrame is not invited and therefor does not take part.

Java
// Container mbmlauncherfataContentPane = mbmlauncherfata.getContentPane();

// init of components

GroupLayout mbmlauncherfataContentPaneLayout = new GroupLayout(getContentPane());
getContentPane().setLayout(mbmlauncherfataContentPaneLayout);
mbmlauncherfataContentPaneLayout.setHorizontalGroup(
  //fancy Layout
);


works much better.

You need to take care of some more things here:

Java
label5.setIcon(new ImageIcon("E:\\Chituri\\MBMLauncherJava\\src\\resursele\\dasdasdasd.png"));


Absolute Paths only work on your machine.

Java
mbmlauncherfata.setTitle("MBMLauncher");
mbmlauncherfata.setSize(305, 395);
mbmlauncherfata.setLocationRelativeTo(null);


same failure same result. You do not need to reference the Jframe as a object - you are working inside the JFrame.

Java
this.setTitle("MBMLauncher");
this.setSize(305, 395); // setPrefferedSize(new Dimension(height, width)) will do the trick, setSize does not work
this.setLocationRelativeTo(null);


works much better. to prevent that please delete the member variable "mbmlauncherfata" (line 186 of this code):

Java
// Generated using JFormDesigner Evaluation license - Ene Ion
//    private JFrame mbmlauncherfata; false reference
    private JTextField textField1;
    private JCheckBox checkBox1;


and please try to bring some readable sense into the GroupLayout - that looks nasty here and doesn't get better in a IDE.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900