JTabbedPane不让我改变布局

时间:2014-12-15 02:52:51

标签: java swing size project layer

我可能只是个白痴。无论如何,我正在尝试多种方法,最终我得到了我的代码,但我的面板不让我把按钮和组件放在我希望它们去的地方。由于我是新手,所以我真正使用的是内容窗格,设置尺寸和流程布局等基础知识。

无论如何,这里发生了什么: http://i.imgur.com/bXRehT0.png

没有框架包

http://i.imgur.com/VT8GqqI.png

我觉得这很简单,但我一直在网上寻找答案,或者我已经遇到过它并没有意识到,这是一个小错误,或者我忘记了在某处。

无论哪种方式,感谢那些可以帮助我的人。

以下代码:

package CourseProject;
import javax.swing.*;

import java.awt.*;
import java.awt.event.*;

public class EngineerCalculator extends JFrame {

//Frame
JFrame frame = new JFrame();

//Create the object
JTabbedPane jtp = new JTabbedPane();

//panel
JPanel panel = new JPanel();

Pools pools = new Pools();
HotTubs hotTubs = new HotTubs();

public EngineerCalculator() {




    //This creates the template on the windowed application that we will be using
    frame.getContentPane().add(jtp);

    //Tab Creation
    JPanel pTemperature = new JPanel();
    JPanel pLength = new JPanel();
    JPanel pEdit = new JPanel();
    JPanel pCustInfo = new JPanel();
    JPanel pCoInfo = new JPanel();
    JPanel pGeneral = new JPanel();

    //Label additions
    JLabel lTemperature = new JLabel();
    JLabel lLength = new JLabel();
    JLabel lEdit = new JLabel();
    JLabel lCustInfo = new JLabel();
    JLabel lCoInfo = new JLabel();
    JLabel lGeneral = new JLabel();

    //Label editing
    lGeneral.setText("Date, time, and job informaiton will go here");
    pGeneral.add(lGeneral);


    //Adds the first tabs to our tab pane objects
    jtp.addTab("Pools", pools);
    jtp.addTab("Hot Tub", hotTubs);
    jtp.addTab("Temp Convert", pTemperature);
    jtp.addTab("Length Convert", pLength);
    jtp.addTab("Edit", pEdit);
    jtp.addTab("Customers", pCustInfo);
    jtp.addTab("Company", pCoInfo);
    jtp.addTab("General", pGeneral);

    //This will create the title you see in the upper left of the window    
    setTitle("Engineer Specifications Calculator");  
    //Set size
    frame.setSize(345, 400); 

    frame.setVisible(true); 

}

public static void main (String []args){
    EngineerCalculator tab = new EngineerCalculator();

    Temperature temperature = new Temperature();
    Length length = new Length();
    Edit edit = new Edit();
    CustInfo custInfo = new CustInfo();
    CoInfo coInfo = new CoInfo();
    General general = new General();
}

}

0 个答案:

没有答案