I have been assigned to design an application that uses tabbed panes for different catagories and collects information bout size and quantity. Also it is suppose to display the cost of the order as information is gathered. How should I go about displaying the cost? I have the tabbed panes set up. I was thinking I need to utilize some sort of actionlistener but am not sure how to implement this. Thanks for the help.
I have included some of my code so far.
[code=java]
import javax.swing.*;
public class Layout
{
public static void main (String[] args)
{
JFrame frame = new JFrame ("Placing Orders");
frame.setDefaul tCloseOperation (JFrame.EXIT_ON _CLOSE);
JTabbedPane tp = new JTabbedPane();
tp.addTab ("Intro", new IntroPanel());
tp.addTab ("Pizza Selection", new PizzaSelectionP anel());
tp.addTab ("Beverage Selection", new BeverageSelecti onPanel());
tp.addTab ("Special Items", new SpecialSelectio nPanel());
frame.getConten tPane().add(tp) ;
frame.pack();
frame.setVisibl e(true);
}
}
import java.awt.*;
import javax.swing.*;
public class IntroPanel extends JPanel
{
public IntroPanel()
{
setBackground (Color.red);
JLabel I1 = new JLabel ("Placing Orders");
JLabel I2 = new JLabel ("Choose a tab to see ordering options.");
add (I1);
add (I2);
}
}
import java.awt.*;
import javax.swing.*;
public class PizzaSelectionP anel extends JPanel
{
private JRadioButton small, medium, large;
private JRadioButton one, two, three;
public PizzaSelectionP anel()
{
setLayout (new FlowLayout());
setBackground (Color.white);
small = new JRadioButton ("Small");
medium = new JRadioButton ("Medium");
large = new JRadioButton ("Large");
ButtonGroup group = new ButtonGroup();
group.add (small);
group.add (medium);
group.add (large);
add (small);
add (medium);
add (large);
one = new JRadioButton ("One");
two = new JRadioButton ("Two");
three = new JRadioButton ("Three");
ButtonGroup group2 = new ButtonGroup();
group2.add (one);
group2.add (two);
group2.add (three);
add (one);
add (two);
add (three);
}
}[/code]
I have included some of my code so far.
[code=java]
import javax.swing.*;
public class Layout
{
public static void main (String[] args)
{
JFrame frame = new JFrame ("Placing Orders");
frame.setDefaul tCloseOperation (JFrame.EXIT_ON _CLOSE);
JTabbedPane tp = new JTabbedPane();
tp.addTab ("Intro", new IntroPanel());
tp.addTab ("Pizza Selection", new PizzaSelectionP anel());
tp.addTab ("Beverage Selection", new BeverageSelecti onPanel());
tp.addTab ("Special Items", new SpecialSelectio nPanel());
frame.getConten tPane().add(tp) ;
frame.pack();
frame.setVisibl e(true);
}
}
import java.awt.*;
import javax.swing.*;
public class IntroPanel extends JPanel
{
public IntroPanel()
{
setBackground (Color.red);
JLabel I1 = new JLabel ("Placing Orders");
JLabel I2 = new JLabel ("Choose a tab to see ordering options.");
add (I1);
add (I2);
}
}
import java.awt.*;
import javax.swing.*;
public class PizzaSelectionP anel extends JPanel
{
private JRadioButton small, medium, large;
private JRadioButton one, two, three;
public PizzaSelectionP anel()
{
setLayout (new FlowLayout());
setBackground (Color.white);
small = new JRadioButton ("Small");
medium = new JRadioButton ("Medium");
large = new JRadioButton ("Large");
ButtonGroup group = new ButtonGroup();
group.add (small);
group.add (medium);
group.add (large);
add (small);
add (medium);
add (large);
one = new JRadioButton ("One");
two = new JRadioButton ("Two");
three = new JRadioButton ("Three");
ButtonGroup group2 = new ButtonGroup();
group2.add (one);
group2.add (two);
group2.add (three);
add (one);
add (two);
add (three);
}
}[/code]
Comment