程序很奇怪

时间:2014-04-23 13:39:09

标签: java

试图让程序在点击它之后它应该打开新的JFrame里面它应该有不同的标签和TextFields ....它全部编译和工作如何它应该在History JTextField和hisScrollPAne旁边这些ScrollPAne没有出现在所有TextField出现在完全错误的地方....如果更改边界盔甲JTextField和historyJTextField然后它的历史出现在正确的地方,但盔甲在错误..不确定我做错了什么... JFrame的维数(800,900) 这是与此JFrame相关的完整代码...

private void object704JButtonActonPerformed(ActionEvent event)     {

    JFrame object704  = new JFrame("object704");
    object704.setLayout(new BorderLayout());



        JLabel titleJLabel704 = new JLabel();
        titleJLabel704.setBounds(0,20,800,36);
        titleJLabel704.setFont(new Font("Serif",Font.BOLD,30));
        titleJLabel704.setText("Object704");
        titleJLabel704.setHorizontalAlignment(JLabel.CENTER);
        object704.add(titleJLabel704);

        JLabel obPicJLabel = new JLabel();
        obPicJLabel.setBounds(190,90,400,215);
        obPicJLabel.setIcon(new ImageIcon("gr/objPic.jpg"));
        object704.add(obPicJLabel);

        JLabel weaponJLabel = new JLabel();
        weaponJLabel.setBounds(113,345,70,30);
        weaponJLabel.setFont(new Font("Serif",Font.BOLD,20));
        weaponJLabel.setText("Weapon");
        object704.add(weaponJLabel);

        JLabel armorJLabel = new JLabel();
        armorJLabel.setBounds(345,345,70,30);
        armorJLabel.setFont(new Font("Serif",Font.BOLD,20));
        armorJLabel.setText("Armor");
        object704.add(armorJLabel);

        JLabel historyJLabel = new JLabel();
        historyJLabel.setBounds(590,345,70,30);
        historyJLabel.setFont(new Font("Serif",Font.BOLD,20));
        historyJLabel.setText("History");
        object704.add(historyJLabel);

        JTextArea weaponJTextArea = new JTextArea("Test2");
        weaponJTextArea.setEditable(false);
        weaponJTextArea.setBounds(40,380,225,400);
        object704.add(weaponJTextArea);

        JScrollPane scrollJScrollPane = new JScrollPane(weaponJTextArea);
        scrollJScrollPane.setBounds(40,380,225,400);
        object704.add(scrollJScrollPane);

        JTextArea armorJTextArea = new JTextArea("Test1");
        //armorJTextArea.setEditable(false);
        armorJTextArea.setVerticalAlignment(JTextArea.CENTER);
        armorJTextArea.setBounds(287,380,225,400);  
        object704.add(armorJTextArea);  

        JScrollPane armScrollPane = new JScrollPane(armorJTextArea);
        armScrollPane.setBounds(287,380,225,400);
        object704.add(armScrollPane);

        JTextField historyJtextField = new JTextField("test");
        //historyJtextField.setEditable(false);
        historyJtextField.setBounds(530,380,200,400);
        object704.add(historyJtextField);


        JTextArea historyJTextArea = new JTextArea();
        historyJTextArea.setEditable(false);
        historyJTextArea.setBounds(530,380,200,400);
        object704.add(historyJTextArea);

        JScrollPane hisScrollPane = new JScrollPane(historyJTextArea);
        hisScrollPane.setBounds(530,380,200,400);
        object704.add(hisScrollPane);


        object704.setSize(850,900);
        object704.setVisible(true); 

0 个答案:

没有答案