after i added in my JTextArea, everything seem mess up, their position have already run away, whats going on ?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
public class MainTabbed
{
JLabel locationLabel;
JLabel divingTypeLabel;
JLabel dateLabel;
JLabel maxDepthLabel;
JLabel averageDepthLabel;
JLabel fBuddyLabel;
JLabel sBuddyLabel;
JLabel timeInLabel;
JLabel timeOutLabel;
// tank
JLabel barStartLabel;
JLabel barEndLabel;
JLabel tankSizeLabel;
//temp
JLabel airLabel;
JLabel surfaceLabel;
JLabel bottomLabel;
// time point
JLabel startTimeLabel;
JLabel stopTimeLabel;
JLabel bottomTimeLabel;
//miscellaneous
JLabel weatherLabel;
JLabel waterTypeLabel;
JLabel visibilityLabel;
JLabel diveLogLabel;
JLabel diveNoLabel;
JLabel EquipmentLabel;
JLabel firstNameLabel;
JPanel mainPane= new JPanel();
JPanel mainPaneTop = new JPanel();
JPanel mainPaneDetail=new JPanel();
JPanel mainPaneTime= new JPanel();
JPanel mainPaneTank= new JPanel();
JPanel mainPaneTemp= new JPanel();
JPanel mainPaneTimePoint= new JPanel();
JPanel mainPaneMis= new JPanel();
JPanel buttonPane = new JPanel();
JButton jButtonOk = new JButton();
JButton jButtonReset = new JButton();
JButton jButtonQuit = new JButton();
JPanel textAreaPane = new JPanel();
JLabel textAreaLabel;
GridBagConstraints gbcMain, gbcDetail, gbcTop, gbcMainPaneTime;
GridBagConstraints gbcMainPaneTank;
GridBagConstraints gbcMainPaneTemp;
GridBagConstraints gbcMainPaneTimePoint;
GridBagConstraints gbcMainPaneMis;
GridBagConstraints gbcTextArea;
JPanel diverPane = new JPanel();
Font font =
new Font("Serif", Font.PLAIN, 14);
public MainTabbed()
{
mainPaneTop.setFont(font);
mainPaneDetail.setFont(font);
mainPaneTime.setFont(font);
mainPaneTank.setFont(font);
mainPaneTemp.setFont(font);
mainPaneTimePoint.setFont(font);
mainPaneMis.setFont(font);
/* @@@@@@@@@@@@@@@@ creating panels @@@@@@@@@@@@@@@@ */
mainPane.setBorder(new LineBorder(Color.BLACK, 1));
Border loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
Border borderTitle = BorderFactory.createTitledBorder(loweredetched, "Detail");
/* @@@@@@@@@@@@@@@@ Detail for MainPane @@@@@@@@@@@@@@@@ */
mainPane.setFont(font);
locationLabel=new JLabel("Location :");
JTextField l = new JTextField(15);
l.setBorder(BorderFactory.createEtchedBorder());
mainPaneDetail.setLayout(new GridBagLayout());
gbcDetail = new GridBagConstraints();
gbcDetail.anchor= GridBagConstraints.WEST;
// gbcDetail.insets = new Insets(5,5,5,5);
gbcDetail.gridx = 0;
gbcDetail.gridy = 0;
mainPaneDetail.add(locationLabel,gbcDetail);
gbcDetail.gridx = 1;
mainPaneDetail.add(l, gbcDetail);
divingTypeLabel=new JLabel("Diving Type :");
JTextField a = new JTextField(15);
a.setBorder(BorderFactory.createEtchedBorder());
gbcDetail.gridx=0;
gbcDetail.gridy=1;
mainPaneDetail.add(divingTypeLabel, gbcDetail);
gbcDetail.gridx=1;
mainPaneDetail.add(a, gbcDetail);
dateLabel = new JLabel("Date :");
JTextField a1 = new JTextField(15);
a1.setBorder(BorderFactory.createEtchedBorder());
gbcDetail.gridx=0;
gbcDetail.gridy=2;
mainPaneDetail.add(dateLabel, gbcDetail);
gbcDetail.gridx=1;
mainPaneDetail.add(a1,gbcDetail);
maxDepthLabel = new JLabel("Max Depth :");
JTextField a2 = new JTextField(15);
a2.setBorder(BorderFactory.createEtchedBorder());
gbcDetail.gridx=0;
gbcDetail.gridy=3;
mainPaneDetail.add(maxDepthLabel, gbcDetail);
gbcDetail.gridx=1;
mainPaneDetail.add(a2,gbcDetail);
averageDepthLabel = new JLabel("Average Depth :");
JTextField a3 = new JTextField(15);
a3.setBorder(BorderFactory.createEtchedBorder());
gbcDetail.gridx=0;
gbcDetail.gridy=4;
mainPaneDetail.add(averageDepthLabel, gbcDetail);
gbcDetail.gridx=1;
mainPaneDetail.add(a3,gbcDetail);
fBuddyLabel = new JLabel("1st Buddy :");
JTextField a4 = new JTextField(15);
a4.setBorder(BorderFactory.createEtchedBorder());
gbcDetail.gridx=0;
gbcDetail.gridy=5;
mainPaneDetail.add(fBuddyLabel, gbcDetail);
gbcDetail.gridx=1;
mainPaneDetail.add(a4,gbcDetail);
sBuddyLabel = new JLabel("2nd Buddy :");
JTextField a5 = new JTextField(15);
a5.setBorder(BorderFactory.createEtchedBorder());
gbcDetail.gridx=0;
gbcDetail.gridy=6;
mainPaneDetail.add(sBuddyLabel, gbcDetail);
gbcDetail.gridx=1;
mainPaneDetail.add(a5,gbcDetail);
mainPaneDetail.setBorder(borderTitle);
/* @@@@@@@@@@@@@@@@ Time for MainPane @@@@@@@@@@@@@@@@ */
mainPaneTime.setLayout(new GridBagLayout());
gbcMainPaneTime = new GridBagConstraints();
gbcMainPaneTime.anchor = GridBagConstraints.NORTHWEST;
Border timeTitle = BorderFactory.createTitledBorder(loweredetched, "Time");
timeInLabel=new JLabel("Time In :");
JTextField b = new JTextField(2);
b.setBorder(BorderFactory.createEtchedBorder());
gbcMainPaneTime.gridx=0;
gbcMainPaneTime.gridy=0;
mainPaneTime.add(timeInLabel, gbcMainPaneTime);
gbcMainPaneTime.gridx=1;
mainPaneTime.add(b, gbcMainPaneTime);
timeOutLabel=new JLabel("Time Out :");
JTextField b1 = new JTextField(2);
b1.setBorder(BorderFactory.createEtchedBorder());
gbcMainPaneTime.gridx=0;
gbcMainPaneTime.gridy=1;
mainPaneTime.add(timeOutLabel, gbcMainPaneTime);
gbcMainPaneTime.gridx=1;
mainPaneTime.add(b1, gbcMainPaneTime);
mainPaneTime.setBorder(timeTitle);
/* @@@@@@@@@@@@@@@@ Tank for MainPane @@@@@@@@@@@@@@@@ */
mainPaneTank.setLayout(new GridBagLayout());
gbcMainPaneTank = new GridBagConstraints();
gbcMainPaneTank.anchor = GridBagConstraints.NORTHWEST;
Border tankTitle = BorderFactory.createTitledBorder(loweredetched, "Tank");
barStartLabel=new JLabel("Bar Start :");
JTextField d= new JTextField(3);
d.setBorder(BorderFactory.createEtchedBorder());
gbcMainPaneTank.gridx=0;
gbcMainPaneTank.gridy=0;
mainPaneTank.add(barStartLabel, gbcMainPaneTank);
gbcMainPaneTank.gridx=1;
mainPaneTank.add(d, gbcMainPaneTank);
barEndLabel=new JLabel("Bar End :");
JTextField d1= new JTextField(3);
d1.setBorder(BorderFactory.createEtchedBorder());
gbcMainPaneTank.gridx=0;
gbcMainPaneTank.gridy=1;
mainPaneTank.add(barEndLabel, gbcMainPaneTank);
gbcMainPaneTank.gridx=1;
mainPaneTank.add(d1, gbcMainPaneTank);
tankSizeLabel=new JLabel("Bar Size :");
JTextField d2= new JTextField(5);
d2.setBorder(BorderFactory.createEtchedBorder());
gbcMainPaneTank.gridx=0;
gbcMainPaneTank.gridy=3;
mainPaneTank.add(tankSizeLabel, gbcMainPaneTank);
gbcMainPaneTank.gridx=1;
mainPaneTank.add(d2, gbcMainPaneTank);
mainPaneTank.setBorder(tankTitle);
/* @@@@@@@@@@@@@@@@ Temperature for MainPane @@@@@@@@@@@@@@@@ */
mainPaneTemp.setLayout(new GridBagLayout());
gbcMainPaneTemp = new GridBagConstraints();
gbcMainPaneTemp.anchor = GridBagConstraints.WEST;
Border tempTitle = BorderFactory.createTitledBorder(loweredetched, "Temperature");
airLabel=new JLabel("Air :");
JTextField e=new JTextField(10);
e.setBorder(BorderFactory.createEtchedBorder());
gbcMainPaneTemp.gridx=0;
gbcMainPaneTemp.gridy=0;
mainPaneTemp.add(airLabel, gbcMainPaneTemp);
gbcMainPaneTemp.gridx=1;
mainPaneTemp.add(e, gbcMainPaneTemp);
surfaceLabel=new JLabel("Surface :");
JTextField e1=new JTextField(10);
e1.setBorder(BorderFactory.createEtchedBorder());
gbcMainPaneTemp.gridx=0;
gbcMainPaneTemp.gridy=1;
mainPaneTemp.add(surfaceLabel, gbcMainPaneTemp);
gbcMainPaneTemp.gridx=1;
mainPaneTemp.add(e1, gbcMainPaneTemp);
bottomLabel=new JLabel("Bottom :");
JTextField e2=new JTextField(10);
e2.setBorder(BorderFactory.createEtchedBorder());
gbcMainPaneTemp.gridx=0;
gbcMainPaneTemp.gridy=2;
mainPaneTemp.add(bottomLabel, gbcMainPaneTemp);
gbcMainPaneTemp.gridx=1;
mainPaneTemp.add(e2, gbcMainPaneTemp);
mainPaneTemp.setBorder(tempTitle);
/* @@@@@@@@@@@@@@@@ Time Point for MainPane @@@@@@@@@@@@@@@@ */
mainPaneTimePoint.setLayout(new GridBagLayout());
gbcMainPaneTimePoint = new GridBagConstraints();
gbcMainPaneTimePoint.anchor = GridBagConstraints.WEST;
Border tPointTitle = BorderFactory.createTitledBorder(loweredetched, "Time Point");
startTimeLabel=new JLabel("Start Time :");
JTextField f=new JTextField(10);
f.setBorder(BorderFactory.createEtchedBorder());
gbcMainPaneTimePoint.gridx=0;
gbcMainPaneTimePoint.gridy=0;
mainPaneTimePoint.add(startTimeLabel, gbcMainPaneTimePoint);
gbcMainPaneTimePoint.gridx=1;
mainPaneTimePoint.add(f, gbcMainPaneTimePoint);
stopTimeLabel=new JLabel("Stop Time :");
JTextField f1=new JTextField(10);
f1.setBorder(BorderFactory.createEtchedBorder());
gbcMainPaneTimePoint.gridx=0;
gbcMainPaneTimePoint.gridy=1;
mainPaneTimePoint.add(stopTimeLabel, gbcMainPaneTimePoint);
gbcMainPaneTimePoint.gridx=1;
mainPaneTimePoint.add(f1, gbcMainPaneTimePoint);
bottomTimeLabel=new JLabel("Bottom Time :");
JTextField f2=new JTextField(10);
f2.setBorder(BorderFactory.createEtchedBorder());
gbcMainPaneTimePoint.gridx=0;
gbcMainPaneTimePoint.gridy=2;
mainPaneTimePoint.add(bottomTimeLabel, gbcMainPaneTimePoint);
gbcMainPaneTimePoint.gridx=1;
mainPaneTimePoint.add(f2, gbcMainPaneTimePoint);
mainPaneTimePoint.setBorder(tPointTitle);
/* @@@@@@@@@@@@@@@@ Time Point for MainPane @@@@@@@@@@@@@@@@ */
mainPaneMis.setLayout(new GridBagLayout());
gbcMainPaneMis = new GridBagConstraints();
gbcMainPaneMis.anchor = GridBagConstraints.WEST;
Border MisTitle = BorderFactory.createTitledBorder(loweredetched, "Miscellaneous");
weatherLabel=new JLabel("Weather :");
JTextField g=new JTextField(5);
g.setBorder(BorderFactory.createEtchedBorder());
gbcMainPaneMis.gridx=0;
gbcMainPaneMis.gridy=0;
mainPaneMis.add(weatherLabel, gbcMainPaneMis);
gbcMainPaneMis.gridx=1;
mainPaneMis.add(g, gbcMainPaneMis);
waterTypeLabel=new JLabel("Water Type :");
JTextField g1=new JTextField(5);
g1.setBorder(BorderFactory.createEtchedBorder());
gbcMainPaneMis.gridx=0;
gbcMainPaneMis.gridy=1;
mainPaneMis.add(waterTypeLabel, gbcMainPaneMis);
gbcMainPaneMis.gridx=1;
mainPaneMis.add(g1, gbcMainPaneMis);
visibilityLabel=new JLabel("Visibility :");
JTextField g3=new JTextField(5);
g3.setBorder(BorderFactory.createEtchedBorder());
gbcMainPaneMis.gridx=0;
gbcMainPaneMis.gridy=2;
mainPaneMis.add(visibilityLabel, gbcMainPaneMis);
gbcMainPaneMis.gridx=1;
mainPaneMis.add(g3, gbcMainPaneMis);
mainPaneMis.setBorder(MisTitle);
/* @@@@@@@@@@@@@@@@ top for MainPane @@@@@@@@@@@@@@@@ */
diveLogLabel=new JLabel("Dive Log: ");
gbcTop = new GridBagConstraints();
JTextField c = new JTextField(15);
c.setBorder(BorderFactory.createEtchedBorder());
mainPaneTop.setLayout(new GridBagLayout());
gbcTop.gridx=0;
gbcTop.gridy=0;
mainPaneTop.add(diveLogLabel, gbcTop);
gbcTop.gridx=1;
mainPaneTop.add(c, gbcTop);
diveNoLabel=new JLabel("Dive No: ");
JTextField c1 = new JTextField(5);
c1.setBorder(BorderFactory.createEtchedBorder());
mainPaneTop.setLayout(new GridBagLayout());
gbcTop.gridx=2;
gbcTop.gridy=0;
mainPaneTop.add(diveNoLabel, gbcTop);
gbcTop.gridx=3;
mainPaneTop.add(c1, gbcTop);
// create text area
gbcTextArea = new GridBagConstraints();
textAreaPane.setLayout(new GridBagLayout());
JTextArea area = new JTextArea();
area.setColumns(70);
area.setRows(10);
area.setBorder(BorderFactory.createEtchedBorder());
textAreaLabel = new JLabel("Comment :");
gbcTextArea.anchor=GridBagConstraints.NORTHWEST;
gbcTextArea.gridx=0;
gbcTextArea.gridy=0;
textAreaPane.add(textAreaLabel, gbcTextArea);
gbcTextArea.gridx=1;
textAreaPane.add(area, gbcTextArea);
buttonPane.setLayout(new GridBagLayout());
jButtonOk.setText(" Save ");
jButtonReset.setText(" Reset ");
jButtonQuit.setText(" Quit ");
buttonPane.add(jButtonOk);
buttonPane.add(jButtonReset);
buttonPane.add(jButtonQuit);
// adding panel to the major panel
gbcMain = new GridBagConstraints();
mainPane.setLayout(new GridBagLayout());
gbcMain.anchor=GridBagConstraints.NORTHWEST;
// gbcMain.fill=GridBagConstraints.RELATIVE;
// gbcMain.ipadx=30;
// gbcMain.ipady=20;
// gbcMain.gridwidth=100;
// gbcMain.gridheight=100;
gbcMain.gridx=0;
gbcMain.gridy=0;
mainPane.add(mainPaneDetail, gbcMain);
gbcMain.anchor=GridBagConstraints.NORTHWEST;
// gbcMain.ipadx=0;
// gbcMain.ipady=0;
gbcMain.gridx=1;
gbcMain.gridy=0;
mainPane.add(mainPaneTop, gbcMain);
gbcMain.anchor=GridBagConstraints.NORTH;
gbcMain.gridx=1;
gbcMain.gridy=1;
mainPane.add(mainPaneTime, gbcMain);
gbcMain.gridx=2;
mainPane.add(mainPaneTank, gbcMain);
gbcMain.anchor=GridBagConstraints.NORTHEAST;
gbcMain.gridx=3;
mainPane.add(mainPaneTemp, gbcMain);
gbcMain.gridy=2;
mainPane.add(mainPaneTimePoint, gbcMain);
gbcMain.gridy=3;
mainPane.add(mainPaneMis, gbcMain);
gbcMain.anchor=GridBagConstraints.SOUTHWEST;
gbcMain.gridx=0;
gbcMain.gridy=4;
mainPane.add(textAreaPane, gbcMain);
gbcMain.anchor=GridBagConstraints.SOUTHWEST;
gbcMain.gridx=4;
gbcMain.gridy=4;
mainPane.add(buttonPane, gbcMain);
}
}
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.NORTHWEST ;
contentPane.add(toolBar,gbc);
menuFile.setFont(font);
.
.
.
.
gbc.gridy = 1;
gbc.fill = GridBagConstraints.BOTH;
gbc.anchor = GridBagConstraints.NORTHWEST;
// gbc.gridwidth = 2;
// c.anchor = GridBagConstraints.WEST;
gbc.weightx = 30.0;
gbc.weighty = 30.0;
// gbc.gridwidth = GridBagConstraints.REMAINDER;
tabs.setFont(font);
MainTabbed mPane = new MainTabbed();
DiverTabbed dPane=new DiverTabbed();
LocationTabbed lPane=new LocationTabbed();
BuddyTabbed bPane= new BuddyTabbed();
tabs.addTab(" Main ", mPane.mainPane);
tabs.addTab(" Diver ", dPane.diverPane);
tabs.addTab(" Location ", lPane.locationPane);
tabs.addTab(" Buddy ", bPane.buddyPane);
// tabs.addTab(" Search ");
tabs.setSelectedIndex(0);
contentPane.add(tabs,gbc);