Question : Problem: WHy doesn't my textfields show and why doesn't my Calculate button work in my Pools tab?

I am using Java and am trying to set this up with tabs, which contain other components as well.  My textfields used to show but I have made many changes which have helped but in the commotion I can't get them to show up any more.  The Calculate button just hasn't ever shown up.  
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
package f2;
 
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
 
 
@SuppressWarnings("serial")
public class Final2 extends JPanel 
{
	static JFrame StartFrame;
	TextField FrmRptSumTextFieldEndUrl = new TextField();
    JTextArea FrmRptSumBoxRpt = new JTextArea();
    
	//component at Pools
	JTextField PoolsTextFieldd = new JTextField();
    JTextField PoolsTextFieldw = new JTextField();
    JTextField PoolsTextFieldl = new JTextField();
    JTextField PoolsTextFieldCalc = new JTextField();
 
    //component at Tubs
    JTextField TubsTextFieldUrl = new JTextField();
 
    //component at Hot Tubs
    JTextArea HotTubsBoxCA1 = new JTextArea();
    
    public Final2()
    {
    	SetIntro(); //call SetIntro
    }
	
	public static void main(String[] args) 
	{
		WindowListener l = new WindowAdapter()
        {
              public void windowClosing(WindowEvent e)
              {
                    System.exit(0);
              }
        };
        StartFrame = new JFrame("McNeil Landscaping");
        StartFrame.addWindowListener(l);
        StartFrame.getContentPane().add("Center", new Final2());
        StartFrame.pack();
        StartFrame.setBounds(250, 300, 700, 300); // (x,y,w,h)
        StartFrame.setVisible(true);
 
	}
 
	public void SetIntro()
    {
		//set up layout FramePanel1
        setLayout(null);
        setForeground(Color.black);
        setBorder(
              BorderFactory.createCompoundBorder(
                    BorderFactory.createLineBorder(Color.gray),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)));
        JLabel Label1 = new JLabel();
        Label1.setLayout(null);
        Label1.setText(" Welcome To McNeil Landscaping");
        Label1.setBounds(230, 10, 500, 20); //x,y,w,h
        add(Label1);
 
        Button Button1 = new Button();
        Button1.setLabel("OK");
        Button1.setBounds(200, 40, 100, 25);
        add(Button1);
        Button1.addActionListener(new ActionListener()
        {
              public void actionPerformed(ActionEvent e)
              {
                    //reformat StartFrame
                    removeAll();
                    StartFrame.pack();
                    StartFrame.setBounds(250, 200, 700, 400); // (x,y,w,h)
                    StartFrame.setVisible(true);
                    SetOpMain();
              }
        });
      
        //Button2 to cancel
        Button Button2 = new Button(); //exit system
        Button2.setLabel("Cancel");
        Button2.setBounds(360, 40, 100, 25);
        add(Button2);
        Button2.addActionListener(new ActionListener()
        {
              public void actionPerformed(ActionEvent e)
              {
                    System.exit(0);
              }
        }); //end Button2
    }
    
	
	public void SetOpMain()
        {
		JPanel SetOpMain = new JPanel();
		SetOpMain.setLayout(null);
		SetOpMain.setBounds(5, 20, 680, 215);
		SetOpMain.setForeground(Color.darkGray);
		SetOpMain.setBorder(
              BorderFactory.createCompoundBorder(
                    BorderFactory.createLineBorder(Color.darkGray),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)));
		SetOpMain.setBorder(BorderFactory.createTitledBorder("Selections"));
        add(SetOpMain);
        
			JTabbedPane TabbedMain = new JTabbedPane();
			TabbedMain.setBounds(10, 20, 660, 180);
			SetOpMain.add(TabbedMain);
			JPanel Pools = new JPanel(new BorderLayout());
			TabbedMain.add(Pools, "Pools");
			JPanel Tubs = new JPanel(new BorderLayout());
			TabbedMain.add(Tubs, "Tubs");
			JPanel HotTubs = new JPanel(new BorderLayout());
			TabbedMain.add(HotTubs, "HotTubs");
    
			//components for Pools
			JPanel PoolsPanel1 = new JPanel(new BorderLayout());
			PoolsPanel1.setLayout(null);
			PoolsPanel1.setBounds(5, 5, 640, 170);
			PoolsPanel1.setBorder(
					BorderFactory.createCompoundBorder(
							BorderFactory.createLineBorder(Color.gray),
							BorderFactory.createEmptyBorder(5, 5, 5, 5)));
			Pools.add(PoolsPanel1);
			
			JLabel PoolsLabeld = new JLabel("Enter depth here(ft):  ");
			PoolsLabeld.setBounds(10, 10, 140, 20);
			PoolsPanel1.add(PoolsLabeld);
 
			JLabel PoolsLabelw = new JLabel("Enter width here(ft):  ");
			PoolsLabelw.setBounds(10, 35, 140, 20);
			PoolsPanel1.add(PoolsLabelw);
 
			JLabel PoolsLabell = new JLabel("Enter length here(ft):  ");
			PoolsLabell.setBounds(10, 60, 140, 20);
			PoolsPanel1.add(PoolsLabell);
			
			JButton PoolsButtonCalc = new JButton("Calculate");
			PoolsButtonCalc.setBounds(150, 85, 100, 25);
			PoolsButtonCalc.add(PoolsButtonCalc);
			
			PoolsTextFieldd.setBounds(150, 10, 50, 20);
			PoolsPanel1.add(PoolsTextFieldd);
			PoolsTextFieldw.setBounds(150, 35, 50, 20);
			PoolsPanel1.add(PoolsTextFieldw);
			PoolsTextFieldl.setBounds(150, 60, 50, 20);
			PoolsPanel1.add(PoolsTextFieldl);
			PoolsTextFieldCalc.setBounds (350, 85, 100, 20);
			PoolsButtonCalc.add(PoolsTextFieldCalc);
	       
			
			//exitButton = new JButton("Exit");
 
			//components for Tubs
			JPanel TubsPanel1 = new JPanel(new BorderLayout());
			TubsPanel1.setLayout(null);
			TubsPanel1.setBounds(5, 5, 640, 170);
			TubsPanel1.setBorder(
					BorderFactory.createCompoundBorder(
								BorderFactory.createLineBorder(Color.gray),
								BorderFactory.createEmptyBorder(5, 5, 5, 5)));
			Tubs.add(TubsPanel1);
 
			JLabel TubsLabelLoc = new JLabel("Data X");
			TubsLabelLoc.setBounds(10, 10, 100, 20);
			TubsPanel1.add(TubsLabelLoc);
 
			JLabel TubsLabelLink = new JLabel("Data Y");
			TubsLabelLink.setBounds(10, 35, 100, 20);
			TubsPanel1.add(TubsLabelLink);
 
			JTextField TubsTextFieldLoc = new JTextField();
			TubsTextFieldLoc.setBounds(100, 10, 150, 20);
			TubsPanel1.add(TubsTextFieldLoc);
			TubsTextFieldUrl.setBounds(100, 35, 370, 20);
			TubsPanel1.add(TubsTextFieldUrl);
 
			//components for HotTubs
			JPanel HotTubsPanel1 = new JPanel(new BorderLayout());
			HotTubsPanel1.setLayout(null);
			HotTubsPanel1.setBounds(5, 5, 640, 170);
			HotTubsPanel1.setBorder(
					BorderFactory.createCompoundBorder(
							BorderFactory.createLineBorder(Color.gray),
							BorderFactory.createEmptyBorder(5, 5, 5, 5)));
			HotTubs.add(HotTubsPanel1);
 
			JLabel HotTubsLabelAdd = new JLabel("Data Z");
			HotTubsLabelAdd.setBounds(10, 10, 100, 20);
			HotTubsPanel1.add(HotTubsLabelAdd);
 
			HotTubsBoxCA1.setBounds(80, 10, 200, 100);
    
			JScrollPane pane = new JScrollPane(HotTubsBoxCA1);
			pane.setBounds(80, 10, 200, 100);
			pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
			pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    
			HotTubsPanel1.add(pane);
        }
	
	
}
Open in New Window Select All

Answer : Problem: WHy doesn't my textfields show and why doesn't my Calculate button work in my Pools tab?

>                         PoolsButtonCalc.add(PoolsButtonCalc);

you can't add something to itself


Random Solutions  
 
programming4us programming4us