Click here to Skip to main content
   

Java

 
AnswerRe: demende d'aide PinmemberJibesh5-Mar-13 9:47 
SuggestionRe: demende d'aide PinmvpRichard MacCutchan5-Mar-13 10:46 
GeneralRe: demende d'aide Pinmemberdusty_dex6-Mar-13 1:31 
GeneralRe: demende d'aide PinmvpRichard MacCutchan6-Mar-13 1:39 
GeneralRe: demende d'aide Pinmemberdusty_dex6-Mar-13 5:43 
Questionjava Pinmemberjaved alm4-Mar-13 19:38 
AnswerRe: java PinmvpRichard MacCutchan5-Mar-13 0:19 
QuestionJava Server read txt file and compare to data in Excel file. PinmemberEuphorialXTC4-Mar-13 9:49 
AnswerRe: Java Server read txt file and compare to data in Excel file. PinmvpRichard MacCutchan5-Mar-13 0:18 
GeneralRe: Java Server read txt file and compare to data in Excel file. PinmemberEuphorialXTC5-Mar-13 0:22 
Questionandroid app PinmemberStudentGirl3-Mar-13 20:36 
AnswerRe: android app PinmvpSandeep Mewara3-Mar-13 21:13 
GeneralRe: android app PinmemberStudentGirl5-Mar-13 5:03 
QuestionHow to manipulate a combo box? PinmemberMember 98295362-Mar-13 0:28 
Would someone please give me an example of a program that increments and decrements values with just the use of combo box and buttons, no other stuffs like a JDialog or even JTable. I'm having a hard time trying to understand complicated programs after all I'm just a newbie in java, so I need a very simple one that is easy to understand.

the code is this:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Scanner;
 
    public class EditStack {
    private JComboBox comboBox = new JComboBox();
    private JButton button = new JButton("Add Order");
    private JButton button_1 = new JButton("Decrease Order");
    JComboBox combo;
    private static String z  = "";
    private static String w  = "";
    private static String x  = "";
    private static String a  = "";
    private int numClick = 0;
    
public EditStack() {
 
    String mgaPagkainTo[] = {"PM1 (Paa/ Spicy Paa with Thigh part)","PM2 (Pecho)","PM3 (Pork Barbeque 4 pcs.)","PM4 (Bangus Sisig)","PM5 (Pork Sisig)","PM6 (Bangus Inihaw)","SM1 (Paa)","SM2 (Pork Barbeque 2 pcs.)","Pancit Bihon","Dinuguan at Puto","Puto","Ensaladang Talong","Softdrinks","Iced Tea","Halo-Halo","Leche Flan","Turon Split"};
    JFrame frame = new JFrame("Mang Inasal Ordering System");
    JPanel panel = new JPanel();
    combo = new JComboBox(mgaPagkainTo);
    combo.setBackground(Color.gray);
    combo.setForeground(Color.red);
    panel.add(combo);
    panel.add(button);
    panel.add(button_1);
    frame.add(panel);
 
    combo.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
        String str = (String)combo.getSelectedItem();
        a = str;
        EditLang messageOrder1 = new EditLang();
        messageOrder1.ShowOrderPo();
       }
    });
 
    button.addActionListener(new ActionListener() { //this is the part I'm stuck with
        public void actionPerformed(ActionEvent e) {
            String selectedItem = (String) comboBox.getSelectedItem(); // I want here to display the selected item in the combo box
            numClick++ // and then increment it whenever I clicked on the add button
        }
    }
    );
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(300,250);
    frame.setVisible(true);
  }
 
  public static void main(String[] args) {
  Scanner inp = new Scanner(System.in);
  boolean ulitinMoPows = true;
  boolean tryAgain = true;
 
    System.out.print("\nInput Customer Name: ");
    String customerName = inp.nextLine();
    w = customerName;
    System.out.print("\nInput Cashier Name: ");
    String user = inp.nextLine();
    z = user;
   do{
    System.out.print("\nInput either Dine In or Take Out: ");
    String dInDOut = inp.nextLine();
    x = dInDOut;
        if (x.equals("Dine In") || x.equals("Take Out")){
         System.out.print("");
         ulitinMoPows = false;
         }
        else{
         JOptionPane.showMessageDialog(null, "Try again! Please input Dine In or Take Out only!","Error", JOptionPane.ERROR_MESSAGE);
             ulitinMoPows = true;
             System.out.print ("\f");
            }
     }while(ulitinMoPows);
     do{
    System.out.print("\nInput password: ");
    String pass = inp.nextLine();
    if(pass.equals("admin")){
        EditLang messageShowMenu = new EditLang();
        messageShowMenu.ShowMo();
        tryAgain = false;
    }
    if(!pass.equals("admin")){
        JOptionPane.showMessageDialog(null, "Try again! Invalid password!","Error Logging-In", JOptionPane.ERROR_MESSAGE);
    tryAgain = true;
     System.out.print ("\f");
    }
}while(tryAgain);
 
EditStack j = new EditStack();
    }
  public static String kuhaOrder()
  {
  return a;
  }
 
  public static String kuhaUserName()
  {
  return z;
  }
 
  public static String kuhaCustomerName()
  {
  return w;
  }
 
  public static String kuhaSanKainPagkain()
  {
  return x;
  }  
}
//Class of EditLang:

public class EditLang {
 
public void ShowMo(){
    String user = EditStack.kuhaUserName();
    System.out.print("\n\n\t\tCashier: " +user);
    String dInDOut = EditStack.kuhaSanKainPagkain();
    System.out.print("                          "+dInDOut);
    String customerName = EditStack.kuhaCustomerName();
    System.out.print("\n\t\tCustomer Name: " +customerName);
}
 
public void ShowOrderPo() {
    String order = EditStack.kuhaOrder();
    System.out.print("\t\t\t\t\n " +order);
 
}
}
//I want to do something like that. Any help will be appreciated thanks!

AnswerRe: How to manipulate a combo box? PinmvpRichard MacCutchan2-Mar-13 0:59 
QuestionImage Mosaicing Pinmemberrachit1328-Feb-13 20:03 
QuestionCan we have Scala added to the list? Pinmemberdusty_dex26-Feb-13 7:48 
AnswerRe: Can we have Scala added to the list? Pinmemberjschell26-Feb-13 10:04 
GeneralRe: Can we have Scala added to the list? Pinmemberdusty_dex26-Feb-13 10:42 
Questionchoise of framework for end of study Pinmembersimontifo25-Feb-13 3:33 
AnswerRe: choise of framework for end of study PinprofessionalPrasad Khandekar2-May-13 21:15 
Questioncompiler PinmemberOlfat Ameen23-Feb-13 18:56 
AnswerRe: compiler PinmvpRichard MacCutchan23-Feb-13 22:18 
QuestionJava Pinmemberthevivek.pro21-Feb-13 20:42 
AnswerRe: Java PinmemberMarco Bertschi21-Feb-13 23:08 
Questionproblem with looping PinmemberMember 982953620-Feb-13 23:20 
AnswerRe: problem with looping PinmvpRichard MacCutchan20-Feb-13 23:56 
AnswerRe: problem with looping Pinmemberameymh21-Feb-13 19:59 
GeneralRe: problem with looping PinmvpRichard MacCutchan21-Feb-13 23:35 
SuggestionRe: problem with looping PinmemberSENTHILKANTH26-Feb-13 2:44 
QuestionCalendar Recommendations PinmemberFyreWyrm16-Feb-13 6:45 
AnswerRe: Calendar Recommendations PinprofessionalPrasad Khandekar2-May-13 21:20 
QuestionJava convert Image to unsigned char [][] Pingroupchor_savorn12-Feb-13 21:44 
AnswerRe: Java convert Image to unsigned char [][] PinmvpRichard MacCutchan12-Feb-13 23:26 
GeneralRe: Java convert Image to unsigned char [][] Pingroupchor_savorn4-Mar-13 0:07 
GeneralRe: Java convert Image to unsigned char [][] PinmvpRichard MacCutchan4-Mar-13 0:18 
GeneralRe: Java convert Image to unsigned char [][] Pingroupchor_savorn4-Mar-13 15:36 
GeneralRe: Java convert Image to unsigned char [][] PinmvpRichard MacCutchan4-Mar-13 23:52 
GeneralRe: Java convert Image to unsigned char [][] Pingroupchor_savorn5-Mar-13 23:09 
GeneralRe: Java convert Image to unsigned char [][] PinmvpRichard MacCutchan5-Mar-13 23:21 
GeneralRe: Java convert Image to unsigned char [][] Pingroupchor_savorn5-Mar-13 23:40 
GeneralRe: Java convert Image to unsigned char [][] PinmvpRichard MacCutchan6-Mar-13 0:35 
QuestionMS Doc in Java PinmemberThirunavukkarasu Dhanushkodi11-Feb-13 5:55 
AnswerRe: MS Doc in Java PinmvpRichard MacCutchan11-Feb-13 6:08 
GeneralRe: MS Doc in Java PinmemberThirunavukkarasu Dhanushkodi11-Feb-13 6:13 
AnswerRe: MS Doc in Java PinmemberTorstenH.14-Feb-13 5:03 
QuestionJDBC PinmemberThirunavukkarasu Dhanushkodi9-Feb-13 19:09 
AnswerRe: JDBC PinmvpRichard MacCutchan9-Feb-13 22:38 
AnswerRe: JDBC PinmemberThirunavukkarasu Dhanushkodi11-Feb-13 5:53 
Questionimage and video trapping using with mobile camera in java and j2me language code Pinmemberanand pal8-Feb-13 21:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web04 | 2.8.150123.1 | Last Updated 23 Jan 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid