0

I'm probably just an idiot. Anyways, I was trying out multiple things and eventually I got my code to work but my panel won't let me place the buttons and components where I want them to go. Since I'm new, all I've really used are the basics such as content pane, set size, and flow layout.

Anyways, here's what's happening: http://i.imgur.com/bXRehT0.png

without the frame pack

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

I feel it's something simple but I've been looking online for answers and either I already came across it and didn't realize, it's a small mistake, or I forgot a line somewhere.

Either way, thanks to those who can help me.

Code Below:

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();
}

}

Midhun MP
  • 103,496
  • 31
  • 153
  • 200
  • 3
    Start by taking a look at [Laying Out Components Within a Container](http://docs.oracle.com/javase/tutorial/uiswing/layout/index.html) – MadProgrammer Dec 15 '14 at 02:54
  • 1
    The default layout of `JPanel` is `FlowLayout`, so the result is not unexpected. – trashgod Dec 15 '14 at 03:12
  • See [Should I avoid the use of set(Preferred|Maximum|Minimum)Size methods in Java Swing?](http://stackoverflow.com/q/7229226/418556) (Yes.) – Andrew Thompson Dec 15 '14 at 06:24

0 Answers0