This site requires JavaScript, please enable it in your browser!
Greenfoot back
divinity
divinity wrote ...

2017/4/4

import of jradiobutton and checkboxes

divinity divinity

2017/4/4

#
hi this is jus a question. if you are doing a program that uses a GUI, with the radiobutton, checkboxes and so on why do you have add an import for all the jradiobutton and jcheckbox. is is necessary to add an import for each of them
danpost danpost

2017/4/4

#
divinity wrote...
if you are doing a program that uses a GUI, with the radiobutton, checkboxes and so on why do you have add an import for all the jradiobutton and jcheckbox. is is necessary to add an import for each of them
You could just use this:
1
import javax.swing.*;
divinity divinity

2017/4/4

#
hey am doing this subway assignment for class and i have been getting these error
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
JRadioButton jrbwheat= new JRadioButton("Wheat");
        JRadioButton jrbitalian = new JRadioButton("Italian");
        JRadioButton jrbparmesanOrgeano = new JRadioButton("Parmesan Orgeano");
        JRadioButton jrbhoney = new JRadioButton("Honey Oats");
        bread.add(Wheat);
        bread.add(Italian); this area here is where I am getting the error: the erros says(non-static variable bread cannot be referenced from a static context) how can i fix this
 
        bread.add(Parmeasan Orgeano);
        bread.add(Honey Oats);
   }
        //type of sub
        JPanel type1 = new JPanel(new GridLayout 6,1); another error is here: it is telling me to import a javaz gridlayout. do i have to
        JRadioButton jrbblt = new JRadioButton("Italian B.L.T - $5.00");
        JRadioButton jrbsubwayclub = new JRadioButton("Subway Club - $5.00");
        JRadioButton jrbsteak = new JRadioButton("Steak & Cheese -$5.00");
        JRadioButton jrbchickenteriyaki = new JRadioButton("Chicken Teriyaki - $7.00");
        JRadioButton jrbsubwaymelt = new JRadioButton("Subway Melt - $5.00");
        JRadioButton jrbtura = new JRadioButton("Tura - $5.00");
        JRadioButton jrbroastbeef = new JRadioButton("Roast Beef $ 7.00");
        JRadioButton jrbveggiedelite = new JRadioButton("Veggie Delite");
danpost danpost

2017/4/4

#
I cannot tell what 'bread' is. You use the 'add' method, but I cannot say whether it is a List object or an object of some class you created and added an 'add' method in. At any rate, I find it difficult to believe that lines 5 through 9 should be placed in your code where you have it. And certainly lines 8 and 9 will not compile, as is, having just a space between two words in a parameter list.
danpost danpost

2017/4/4

#
You will need:
1
2
3
import java.awt.GridLayer;
// or at least
java.awt.*;
divinity divinity

2017/4/4

#
hi danpost the bread is the type of bread the user would order whether it is parmaesan bread, honey oats, wheat, teriyaki adn I was trying to add it using the add methods.
danpost danpost

2017/4/4

#
divinity wrote...
the bread is the type of bread the user would order whether it is parmaesan bread, honey oats, wheat, teriyaki adn I was trying to add it using the add methods.
That would be a very general description of the bread which has nothing to do with how you are trying to code it. I mean, I now how to make a submarine sandwich and how to order one at Subway. My question was, basically, how (and where) did you declare the variable 'bread' in your code?
You need to login to post a reply.