Swing/AWT/SWT :: Action Listeners - Pizza Ordering GUI

Dec 3, 2014

I've got the layout put correctly but I can't seem to get my action listeners to work correctly.

import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class PizzaOrderDriver
{
public static void main(String[] args)
{
JCheckBox show1;

[Code] .....

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: Multiple Action Listeners?

Oct 25, 2014

So im making a calculator just basic 4 function with a clear button. as i am working into this project i am running into an issue of assigning which click sets what. For instance i click the two button how do i tell it to assign it to firstNum, versus secondNum?

private class theHandler implements ActionListener{
public void actionPerformed(ActionEvent event){
if(event.getSource()==one){
firstNum=1;
}
if(event.getSource()==two){
secondNum =2;
}
if(event.getSource()==three){
secondNum =3;
}

So this for instance allows me to set one to the firstNum and then add it to two or three but im not sure what to do next. I have in my mind i want to do something like make three listener classes, that operate in sequential order like you pick the first numbers, click an operation, and then select the second numbers then hit the operation(equal) button to display answer. Am i on the right track or what?

View Replies View Related

Pizza Pickup And Delivery Ordering Java Program

Jul 31, 2014

This is my code for a Pizza Pickup and delivery I am am having a few issues.

public class Internal {
public static void main(String[]args) {
double total2 = 0;
String customerName = " ";
String address = " ";
String phoneNum ="0";

[Code] ....

View Replies View Related

How To Reference Action Listeners

Mar 15, 2015

I am making an MVC program and I am not allowed to put the action listeners in the view class. I was able to get one button working fine but since I am unable to reference them I cannot give them both individual responses.

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Controller {
HobbyList model;
ListView view;

[code]....

View Replies View Related

ATM Machine - Action Listeners

Mar 27, 2014

My output is all over the place. I cancelled out the borderlayouts beneath each panel I created and it completely changed the output, and I'm not sure why. The first photo below, shows what it looked like with the layouts and the second shows the output without. I still don't understand why I don't see the digits 1-9.

Java Code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
public class Atm extends JFrame {
Atm(){
super("ATM");
//Create Panels For ATM
JPanel buttonPanel1 = new JPanel(); //To Contain Digits 1-9

[Code] ....

Why would setting the layout beneath each object change the layout so much? I stayed consistent in my use of BLayout and GLayout in the program.

View Replies View Related

Swing/AWT/SWT :: GUI Codelines Ordering

Feb 14, 2015

i am studying java from head first java book and yesterday i was working on a program called QuizCardBuilder. what i noticed is that when i changed the order of the lines from the book i get a blank frame with nothing on it.this is my code that gives blank frame

public class QuizCardBuilder{
JFrame frame;
JTextArea question;
JTextArea answer;
JButton nextButton;
ArrayList<QuizCard> cardList;

[code]....

View Replies View Related

Swing/AWT/SWT :: MVC Layout - Adding Listeners?

May 4, 2014

So I'm doing a basic MVC layout for a pretty basic game that I am making in order to understand the whole MVC layout. The game requires the user to move up/down/left/right via JButtons on the GUI. Since I'm using an MVC layout and my buttons are in a different class than the ActionListeners, I was wondering what the best way to add the action listeners are?

Method 1:

View Replies View Related

AWT Action Listener In Swing GUI?

Feb 22, 2014

I'm using Eclipse with the Window Builder Pro plugin to create a Java program. I noticed that when I had Eclipse create an action listener for a combobox in a Swing GUI it created an AWT listener.

Did I choose the wrong type of listener? I want my code to use the Swing components because I understand that they are more portable.

View Replies View Related

Swing/AWT/SWT :: JComboBox Listener - Bound Action?

Jul 14, 2014

I have three JComboBoxes. When the user selects an entry in the first JComboBox the entries in the second are set. For this I use an Action extends AbstractAction which is bound to the first JComboBox.

I have also bound an Action to the second JComboBox.

Problem: this also fires when the entries on the second JCombox are added which leads to a Nullpointer.

I need a Listener which only reacts to user input, and does not react when the model of the JComboBox is changed.

View Replies View Related

Swing/AWT/SWT :: How To Change Action After 1st JButton Click

Aug 3, 2014

I am relatively new to java. . I cannot...(actually do not know) how to change the actionlistener (actionPerformed) after the second click in an array of JButtons. This is how the program performs right now.

On the 1st click on the grid, the border of the button clicked will change to 'blue' and another button will change its boarder to 'red'. on the next click the same action is performed.

What I need is to change action when the 'red' bordered button is clicked, lets say change the color of the buttons from the 'red' to the 'blue' buttons.(x 3 buttons).

The logic about how to perform the final result I think I can do on my own but my problem is how to change the action when the red bordered button is clicked.

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;

[Code] .....

View Replies View Related

Servlets :: There Is No Action Mapped For Namespace And Action Name Associated

Nov 16, 2014

This is my first servlet program. I wanted to try a web application where "register" user module will be in servlet program.I can access my index.jsp but when I enter values and click submit.

I get "There is no Action mapped for namespace [/] and action name [RegisterUserServlet] associated with context path [/TrainingApplication]. - [unknown location]".

Here's my index.jsp file:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

[code]....

I am using apache-tomcat-8.0.14 server.

View Replies View Related

Swing/AWT/SWT :: Action Listener Does Not Work With Button Click

Feb 22, 2015

I have buttons created on a frame and then I register the listener from a controller in a controller-view relationship.

When I click the button on the face, the action never executes for some reason. I thought maybe there was a problem registering the listener but I can call the buttons doclick() method and it executes as it should. Perhaps I'm overlooking something really obvious here but I can't see it.

btnEight = new JButton( "8" );
// btnEight.addActionListener( controller );
btnEight.setBounds( 212, 90, 41, 23 );
frame.getContentPane().add( btnEight );

and then I add the listener

public void setController( ActionListener theController ) {
Component[] components = frame.getContentPane().getComponents();
for ( Component component : components ) {
if ( component instanceof JButton ) {
JButton button = ( JButton ) component;
button.addActionListener( theController );
}
}

again, when i click the button nothing happens. but if i add the following code

btnEight.doclick()

the actionPerformed invokes in theController as I intended.

You can see the entire project on GitHub so you can see the full context. The controller class contains the listener and the view class contains the buttons.

View Replies View Related

Swing/AWT/SWT :: Void Is Invalid Type For Variable Action-performed

May 1, 2015

Here is part of my program that contains the code giving me problems.

import java.awt.EventQueue;
import javax.swing.JFrame;
import java.awt.Label;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.TextArea;
import java.awt.Choice;
import javax.swing.JRadioButton;

[code]....

View Replies View Related

Pizza Program For Java / Resetting Prices Does Not Function

Jul 26, 2014

I am making a pizza program and most of the program works. I have made an order button that will output the total price of the order. The reset button that I made makes the JTextArea output $0.00, but if I press the order button to make another order, the program does not add the new amount to zero. For example, if I make an order that totals $5.00, but I want to make another order after resetting, the price for the new order will be added on to the previous order's price.

Here is the code. This is a JApplet program. Why the price will not reset? This code was made in BlueJ.

//Author:Kishan Patel
// Sources will be cited soon.
//This is Lab 7, the pizza parlour program.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;

[code]....

View Replies View Related

Writing A Pizza Program - Average Cost Of Order

Oct 9, 2014

I'm trying to write a program that will output the total number of large,medium,and small pizza along with the average cost of an order. I'm stuck on this error , "Else without if" on line 48 else ...medium.

import java.util.Scanner;
public class PizzaOrder
{
public static void main(String[] args)
{
Scanner input = new Scanner (System.in);
double cost,total, average;
String name,response,size,type;
int count,l,m,s;

[code]....

View Replies View Related

Array List Of Pizza Toppings - Access Cost Through Get And Set Method?

Dec 1, 2014

So I have created a array list of pizza toppings, only 4 in total, and each ingredient needs to have a cost property. I'm supposed to access the cost through a get / set method, as the user can create their own pizza and it will total up the cost, but how to.

View Replies View Related

Ordering System In Eclipse?

Jul 22, 2014

it gives me an error at the end class part some syntax error insert "}"..

* Course: IT110 - Introduction to Programming
* Filename: MyCustomShirtsPhase1.java
*
* Purpose: Created a simple online ordering system for My Custom Shirts customers
*/
import javax.swing.JOptionPane;

[code]....

View Replies View Related

Simple Meal Ordering System

Aug 4, 2014

requirments:
meal module -payment module
list of items/vm
single item - delated/add
value meal item
all with prizes
price module
per items
per meal
total

View Replies View Related

How To Add Listeners In A Object

Apr 27, 2014

I am having some issues with my GUI. I have a UserList GUI (not finished) that, on button click, will check for an open chat window and open a new window if none exists or add a tab if one does (this is working fine). My issue is that the listeners I added to my chat window only work for the last tab added. If I switch back to a previous tab, I can no longer use my input textField and send button to write to my textArea. I add listeners when I initially create the window and first tab. I thought about adding ChangeState listener, but couldn't work out how it would be any different than what I am doing now. Do I not fully understand how listeners are added to a particular object?

I will post my code for the whole class so you can get the full picture.

Java Code: public class Chat extends JFrame{
private JPanel tabPanels, mainPanel;
private JTextArea chatArea;
private JTextField inputArea;
private JButton send;
private JTabbedPane tabPane;
private JScrollPane scroll;
private String name;

[Code]...

View Replies View Related

Create A Restaurant Ordering System Using JFrame

Oct 14, 2014

How to create a restaurant ordering system using JFrame .....

View Replies View Related

Infix To Postfix And Prefix - Not Ordering Correctly

Jul 28, 2014

So my code works perfectly when I input (a+(c-d) and i get ab+cd- for postfix and *+ab-cd for prefix. However when I input a+b+c for infix i receive abc++ postfix and +a+bc prefix when its supposed to be ab+c+ postfix and ++a b c prefix. So my issue is that any infix input with parenthesis, it converts them correctly, however without parenthesis it does not convert correctly.

import java.util.*;
public class stack {
public static char[] convertToPostfix(char[] infixEx) {
Stack<Character> operatorStack = new Stack<Character>();
char[] postfix = new char[infixEx.length];
int index = 0;

[Code] .....

View Replies View Related

MVC Layout - Adding Listeners?

May 4, 2014

So I'm doing a basic MVC layout for a pretty basic game that I am making in order to understand the whole MVC layout. The game requires the user to move up/down/left/right via JButtons on the GUI. Since I'm using an MVC layout and my buttons are in a different class than the ActionListeners, I was wondering what the best way to add the action listeners are?

Method 1:

View Class ActionListener method:
Java Code: public void addMovementListeners(ActionListener u, ActionListener d, ActionListener l, ActionListener r){
moveUp.addActionListener(u);
moveDown.addActionListener(d);
moveLeft.addActionListener(l);
moveRight.addActionListener(r);

[Code] ....

Which method is better? Is there another method that is even better than these two? Trying to get this MVC thing down.

View Replies View Related

How To Use Event Listeners In Java

May 6, 2014

How the event Listeners work in java,To get the data based on the event occurs in outside the application. I have this method in one of my API class I am not understanding how this methods are going to work.
 
public interface SBXPCXMLEventListener {  
public void OnReceiveEventXML(String eventXML);
}  
private static List<SBXPCXMLEventListener> listenerList = new ArrayList<SBXPCXMLEventListener>();  
protected static void fireXMLEvent(String xml) {  

[Code] ....

I have done like this.This is used to capture the events from the fingerprint machine when run this class I am not getting any data from the machine when i did thumb impression in the machine.

public class EventListnere implements SBXPCXMLEventListener {
    public static void main(String[] args) {
        boolean flag = SBXPCProxy.ConnectTcpip(1, "10.0.0.8", 5005, 1234);
        System.out.println("flag = " + flag);
//        SBXPCProxy.st

[Code] .....

View Replies View Related

JavaFX 2.0 :: Remove All Listeners And / Or All Bindings?

Jun 17, 2014

Is there any way in JavaFX 8 to remove all change/invalidation listeners on an observable? And is there any way to remove all bindings on a property?

View Replies View Related

Lexicographic Ordering - When Input String Values / No Output Takes Place

Jan 28, 2015

I have a assignment to do some Lexigraphic ordering. I have figured how to get the majority of this done, however, when I input my string values. No output takes place? :s

import java.util.Scanner;
public class Lab03c {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner lexi = new Scanner (System.in);
String s1,s2;

[Code] ....

View Replies View Related

Set Listeners Of Cells To Save Information Of Entire Table After Modification

Aug 18, 2014

I am having trouble with a jTable that I am using. I have set the listeners of the cells to save the information of the entire table every time they are modified, but run into the problem that the last modified cell does will not reflect its most recent value. The value will display visually, but not show up when I try to read from the cell. I have tried wrapping the saveProcGuide() call in swing's invokelater, but to no avail. I have marked the area where the problem becomes evident (values returned do not match those present in the visible table object). Below is the offending code:

// This is where I set up the listeners
private void addProcGuideWithValues() {
procTableModel.addRow(new Object[]{"", ""});
// document listener to be fed into editor/renderers for cells...
DocumentListener docuListener = new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
saveProcGuide();

[Code] .....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved