Results 1 to 5 of 5
Thread: Can somebody help me!
- 02-12-2011, 07:32 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
Can somebody help me!
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class order extends JFrame implements ActionListener
{
int totalPrice;
/**
*
*/
private static final long serialVersionUID = 1L;
JRadioButton plainrice, friedrice, adoborice, javarice;
JCheckBox chopseuy, chickencurry, adobonghito, batchoy, dinuguan, lechongkawali,chickenAdobo,menudo,karekare,tinola, mechado,beefsteak;
JButton order, clear, exit;
JPanel westPanel, eastPanel, midPanel, lowerPanel;
public order()
{
super("Order System");
JOptionPane.showMessageDialog(null, "\t\t List of Menu \n 1) Plain Rice P10.00 \n 2)Fried Rice P20.00 \n 3) Adobo Rice P30.00 \n 4) Java Rice P40.00 \n 5) Chopsuey P10.00 \n 6) Chicken Curry P20.00 \n 7) Adobong Hito P30.00 \n 8) Batchoy P40.00\n 9) Dinuguan P50.00 \n 10) Lechong Kawali P60.00 \n 11) Chicken Adobo P70.00 \n 12) Menudo P80.00 \n 13) Kare-Kare P90.00 \n 14) Tinola P100.00 \n 15) Mechado P110.00 \n 16) BeefSteak P120.00");
Container con = getContentPane();
con.setLayout(new BorderLayout());
plainrice = new JRadioButton("Plain Rice");
friedrice = new JRadioButton("Fried Rice");
adoborice = new JRadioButton("Adobo Rice");
javarice = new JRadioButton("Java Rice");
westPanel = new JPanel(new GridLayout(5,1,10,10));
westPanel.add(plainrice);
westPanel.add(friedrice);
westPanel.add(adoborice);
westPanel.add(javarice);
con.add(westPanel, BorderLayout.WEST);
chopseuy = new JCheckBox("Chopseuy");
chickencurry = new JCheckBox("Chicken Curry");
adobonghito = new JCheckBox("Adobong Hito");
batchoy = new JCheckBox("Batchoy");
dinuguan = new JCheckBox("Dinuguan");
lechongkawali = new JCheckBox("Lechong Kawali");
chickenAdobo = new JCheckBox("Chicken Adobo");
menudo = new JCheckBox("Menudo");
karekare = new JCheckBox("Kare-Kare");
tinola = new JCheckBox("Tinola");
mechado = new JCheckBox("Mechado");
beefsteak = new JCheckBox("Beef Steak");
midPanel = new JPanel(new GridLayout(5,1,10,10));
midPanel.add(chopseuy);
midPanel.add(chickencurry);
midPanel.add(adobonghito);
midPanel.add(batchoy);
midPanel.add(dinuguan);
midPanel.add(lechongkawali);
midPanel.add(chickenAdobo);
midPanel.add(menudo);
midPanel.add(karekare);
midPanel.add(tinola);
midPanel.add(mechado);
midPanel.add(beefsteak);
con.add(midPanel, BorderLayout.CENTER);
order = new JButton("Check Order");
clear = new JButton("Clear Order");
exit = new JButton("Close Counter");
lowerPanel = new JPanel(new GridLayout(1, 3, 5, 5));
lowerPanel.add(order);
lowerPanel.add(clear);
lowerPanel.add(exit);
con.add(lowerPanel, BorderLayout.SOUTH);
JLabel heading = new JLabel("-Berto's Carinderia-");
heading.setFont(new Font("Ravie", Font.BOLD | Font.BOLD, 29));
con.add(heading, BorderLayout.NORTH);
order.addActionListener(this);
clear.addActionListener(this);
exit.addActionListener(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(450, 250);
setLocation(400, 250);
setVisible(true);
clearUI();
}
public void actionPerformed(ActionEvent e)
{
Object source = e.getSource();
if (source == order)
placeOrder();
else if (source == clear)
clearUI();
else if (source == exit)
System.exit(0);
}
private void clearUI()
{
plainrice.setSelected(false);
friedrice.setSelected(false);
adoborice.setSelected(false);
javarice.setSelected(false);
chopseuy.setSelected(false);
chickencurry.setSelected(false);
adobonghito.setSelected(false);
batchoy.setSelected(false);
dinuguan.setSelected(false);
lechongkawali.setSelected(false);
chickenAdobo.setSelected(false);
menudo.setSelected(false);
karekare.setSelected(false);
tinola.setSelected(false);
mechado.setSelected(false);
beefsteak.setSelected(false);
}
private void placeOrder()
{
Object rice = "";
if (plainrice.isSelected())
rice = "Plain Rice P10.00 ";
else if (friedrice.isSelected())
rice = "Fried Rice P20.00";
else if(adoborice.isSelected())
rice = "Adobo Rice P30.00 ";
else if(javarice.isSelected())
rice = "Java Rice P40.00";
String ulam = "";
if (chopseuy.isSelected())
ulam = "Chopseuy P10.00 ";
else if (chickencurry.isSelected())
ulam = "ChickenCurry P20.00 ";
else if (adobonghito.isSelected())
ulam = "Adobong Hito P30.00 ";
else if (batchoy.isSelected())
ulam = "Batchoy P40.00 ";
else if(dinuguan.isSelected())
ulam = "Dinuguan P50.00 ";
else if(lechongkawali.isSelected())
ulam = "Lechong Kawali P60.00";
else if(chickenAdobo.isSelected())
ulam = "Chicken Adobo P70.00";
else if(menudo.isSelected())
ulam = "Menudo P80.00";
else if(karekare.isSelected())
ulam = "Kare-Kare P90.00";
else if(tinola.isSelected())
ulam = "Tinola P100.00";
else if(mechado.isSelected())
ulam = "Mechado P110.00";
else if(beefsteak.isSelected())
ulam = "Beef Steak P120.00";
JOptionPane.showMessageDialog(null,rice + ulam + totalPrice);
clearUI();
}
public static void main(String[] args)
{
order bertoSOrderSystem = new order();
}
}
- 02-12-2011, 07:35 AM #2
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
I can only order 1 rice and 1 ulam I want make an order at least all and ADD them ..Can somebody help me!
- 02-13-2011, 06:36 PM #3
Member
- Join Date
- Feb 2011
- Posts
- 1
- Rep Power
- 0
Help
package chelo;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
public class mycell extends JPanel implements ListCellRenderer {
JLabel first, second, third;
final static ImageIcon online = new ImageIcon("http://www.java-forums.org/images/online.gif");
final static ImageIcon dto = new ImageIcon("http://www.java-forums.org/images/dto.gif");
mycell() {
//GridLayout grid=new GridLayout(1, 8);
GridBagLayout g1= new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
c.fill=c.BOTH;
c.weightx =1;
c.weighty =1;
first = new JLabel();
first.setBorder(BorderFactory.createLineBorder(Col or.BLACK));
c.gridx = 0;
c.gridy = 0;
c.gridwidth = 1;
c.gridheight = 1;
g1.setConstraints(first, c);
second = new JLabel();
second.setBorder(BorderFactory.createLineBorder(Co lor.BLACK));
c.gridx = 2;
c.gridy = 0;
c.gridwidth = 1;
c.gridheight = 1;
g1.setConstraints(second, c);
third = new JLabel();
third.setBorder(BorderFactory.createLineBorder(Col or.BLACK));
c.gridx = 1;
c.gridy = 0;
c.gridwidth =1;
c.gridheight =1;
c.ipady=10;
g1.setConstraints(third, c);
first.setPreferredSize(new Dimension(30, 35)); // it doesn't work
this.setLayout(g1);
first.setOpaque(true);
second.setOpaque(true);
third.setOpaque(true);
this.add(first);
this.add(second);
this.add(third);
}
public Component getListCellRendererComponent(JList list, Object value, int index,
boolean isSelected, boolean cellHasFocus) {
String leftData = ((String[])value)[0];
String middleData = ((String[])value)[1];
String rightData = ((String[])value)[2];
first.setIcon(dto);
second.setIcon(online);
third.setText("<html> "+rightData+"<fon t size=2 color=gray> <br> me var maagari bichiii</font></html>");
if(isSelected){
first.setBackground(new Color(90, 166, 254));
first.setForeground(list.getSelectionForeground()) ;
second.setBackground(new Color(90, 166, 254));
second.setForeground(list.getSelectionForeground() );
third.setBackground(new Color(90, 166, 254));
third.setForeground(list.getSelectionForeground()) ;
}
else{
first.setBackground(list.getBackground());
first.setForeground(list.getForeground());
second.setBackground(list.getBackground());
second.setForeground(list.getForeground());
third.setBackground(list.getBackground());
third.setForeground(list.getForeground());
}
setEnabled(list.isEnabled());
setFont(list.getFont());
return this;
}
}
I WANT TO DO THIS SUCHBUT IT ISNOT LIKE IN THE PICTURELast edited by gijuna; 02-13-2011 at 06:44 PM.
- 02-14-2011, 02:48 PM #4
- 02-14-2011, 03:04 PM #5
the picture is barely readable. i only tried to start your code but what i get is far from a correct gridbag. perhaps reading this tutorial example you may improve your code a get what you want. if you have questions understanding the tutorial, let me know.


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks