language: Java (sun-jdk-1.7.0_10)
date: 109 days 5 hours ago
link:
visibility: public
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
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
 
 
 
    public class PetSurvey extends JFrame
{
    public static void main (String [] args)
  {
 new PetSurvey() ; 
  }
 
    JTextField name, phone, address;
    JRadioButton cat, dog , fish, oneOrMore , threeOrMore ;
    JCheckBox house, bungalow, appartment;
    
   public PetSurvey()
    {
      this.setTitle ("Pet Survey");
      this.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
      JPanel panel = new JPanel ();
      panel.SetLayout ( new GridBagLayout());
      
   
 
 
  ButtonListener bl = new ButtonListener ();
      
      addItem(panel, new JLabel ("Name"),
              0, 0, 1, 1, GridBagConstraints.EAST);
     addItem(panel, new JLabel ("Phone: "), 
              0, 1, 1, 1, GridBagConstraints.EAST);
        name = new JTextField (20);
       phone = new JTextField(10);
        
        
      addItem(panel, name, 1, 0, 2, 1, GridBagConstraints.WEST);
        addItem(panel, phone, 1, 1, 1, 1, GridBagConstraints.WEST);
   
              
 
          
          
 Box sizeBox = Box.createVerticalBox();
 
 house = new JRadioButton("House");
 bungalow = new JRadioButton("bungalow");
 appartment = new JRadioButton("Appartment");
 ButtonGroup sizeGroup = new ButtonGroup();
 sizeGroup.add(house);                        //Adding buttons to button group
 sizeGroup.add(bungalow);
 sizeGroup.add(appartment);
 
 
 sizeBox.add(house);
 sizeBox.add(bungalow);
 sizeBox.add(appartment);
 sizeBox.setBorder(BorderFactory.createTitledBorder("Select your house"));
 addItem(panel, sizeBox, 0, 3, 1, 1, GridBagConstraints.NORTH);
 
 
 
 Box styleBox = Box.createVerticalBox ();
 oneOrMore = new JRadioButton("oneOrMore");
threeOrMore = new JRadioButton("threeOrMore");
 ButtonGroup styleGroup = new ButtonGroup();
 
 styleGroup.add(oneOrMore);
 styleGroup.add(threeOrMore);
 styleBox.add(oneOrMore);
 styleBox.add(threeOrMore);
 styleBox.setBorder(BorderFactory.createTitledBorder ("How many pets do you have"));
 addItem(panel, styleBox, 1, 3, 1, 1, GridBagConstraints.NORTH);
 
 Box topBox = Box.createVerticalBox();
 house = new JCheckBox("House");
 bungalow = new JCheckBox("Bungalow");
 appartment = new JCheckBox("Appartment");
 topBox.add(house);
 topBox.add(bungalow);
 topBox.add(appartment);
 topBox.setBorder(BorderFactory.createTitledBorder("Where do you live"));
 addItem(panel, topBox, 2, 3, 1, 1,  GridBagConstraints.NORTH);
 Box buttonBox = Box.createHorizontalBox();
     okButton = new JButton("OK");
     okButton.addActionListener(bl);
 
 closeButton = new JButton ("Close");
 closeButton.addActionListener(bl);
 
 buttonBox.add(okButton);
 buttonBox.add(Box.createHorizontalStrut (20));
 buttonBox.add(closeButton);
 addItem(panel1, buttonBox, 2, 4, 1, 1, GridBagConstraints.NORTH);
 this.add(panel1);
  this.pack ();
 this.setVisible(true);
 
 {
 private void addItem(JPanel p, JComponent c, int x, int y, int width, int height, int align)
 }
 
 GridBagConstraints gc = new GridBagConstraints ();
 gc.gridx = x;
 gc.gridy = y;
 gc.gridwidth = width;
 gc.gridheight = height;
 gc.weightx  = 100.0;
 gc.weighty = 100.0;
 gc.insets = new Insets (5, 5, 5, 5);
 gc.anchor = align;
 gc.fill = GridBagConstraints.NONE;
 p.add(c, gc);
 }
 
 private class ButtonListener implements ActionListener
 
  {
  public void actionPerformed(ActionEvent e)
  {
   if (e.getSource() == okButton)
   {
   
       String tops = "" ;
   if (house.isSelected()) tops +="House\n";
   if (bungalow.isSelected()) tops += "Bungalow \n";
   if (appartment.isSelected()) tops += "Appartment\n";
   
    String base = " your base type is ";
   if (oneOrMore.isSelected()) base += "OneOrMore";
   if(threeOrMore.isSelected()) base += "ThreeOrMore";
   
   String msg = "You ordered a ";
   if(small.isSelected()) msg += "...";
   if(medium.isSelected()) msg += "...";
   if (large.isSelected ()) msg += "...";
 
   
                                                         //String name = name.getText;
   
   if(tops.equals(""))
   
   msg += "you have no pets";
   else
 
   msg += "the following toppings:\n "+ tops + base; 
 
 
 JOptionPane.showMessageDialog(okButton, msg, "Your Results!", JOptionPane.INFORMATION_MESSAGE);
 
 house.setSelected(false);
 bungalow.setSelected(false);
 appartment.setSelected(false);
 cat.setSelected(false);
 dog.setSelected(true);
 fish.setSelected(true);
   }
 
   if (e.getSource() == closeButton)
   {
    System.exit(0);
   }
  }
}
   
}
 
 
 
 
 
 
Main.java:101: error: illegal start of expression
 private void addItem(JPanel p, JComponent c, int x, int y, int width, int height, int align)
 ^
Main.java:101: error: illegal start of expression
 private void addItem(JPanel p, JComponent c, int x, int y, int width, int height, int align)
         ^
Main.java:101: error: ';' expected
 private void addItem(JPanel p, JComponent c, int x, int y, int width, int height, int align)
                     ^
Main.java:101: error: ';' expected
 private void addItem(JPanel p, JComponent c, int x, int y, int width, int height, int align)
                                          ^
Main.java:101: error: not a statement
 private void addItem(JPanel p, JComponent c, int x, int y, int width, int height, int align)
                                           ^
Main.java:101: error: ';' expected
 private void addItem(JPanel p, JComponent c, int x, int y, int width, int height, int align)
                                            ^
Main.java:101: error: <identifier> expected
 private void addItem(JPanel p, JComponent c, int x, int y, int width, int height, int align)
                                                    ^
Main.java:101: error: not a statement
 private void addItem(JPanel p, JComponent c, int x, int y, int width, int height, int align)
                                                         ^
Main.java:101: error: ';' expected
 private void addItem(JPanel p, JComponent c, int x, int y, int width, int height, int align)
                                                          ^
Main.java:101: error: <identifier> expected
 private void addItem(JPanel p, JComponent c, int x, int y, int width, int height, int align)
                                                                      ^
Main.java:101: error: not a statement
 private void addItem(JPanel p, JComponent c, int x, int y, int width, int height, int align)
                                                                           ^
Main.java:101: error: ';' expected
 private void addItem(JPanel p, JComponent c, int x, int y, int width, int height, int align)
                                                                                 ^
Main.java:101: error: ';' expected
 private void addItem(JPanel p, JComponent c, int x, int y, int width, int height, int align)
                                                                                            ^
13 errors