2012-06-09 2 views
0
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); 
      } 
     }); 
    } 



} 

결과 picture 나는이 문제를 해결하려고하지만 난 자바 스크립트에 beginer에 오전, 여기서 문제는 내가 그것을 고칠 수있는 방법 .. 빈 자바 상자인가? 도와 주실 탱크, Eclipse 용 좋은 플러그인을 알려주세요.jFormDesigner 디자인이 표시되지 않습니까?

+0

양식 디자이너를 옆에두고 처음으로 스윙을 코딩하는 법을 배우는 것이 좋습니다. 스윙 튜토리얼이 도움이 될 것입니다. 그런 다음 나중에 스윙을 이해하면 폼 디자이너를 사용하십시오. –

답변

1

일반적으로 프레임을 포장하지 않을 때 발생합니다.

이 시도 :

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

Here는 자바 프레임을 시작하는 좋은 튜토리얼입니다.

+0

동일합니다. 변경했지만 비워 두십시오. – Malasuerte94

+0

자동 생성 코드를 변경하지 않았습니까? 양식의 선호 크기를 적절한 값으로 설정하십시오. – GETah

관련 문제