Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 29th, 2006, 08:12 AM
blad3runner blad3runner is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 1 blad3runner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 48 m 20 sec
Reputation Power: 0
A Way to use an ItemEvent inside an ActionEvent?

Is there a way I can use an ItemEvent inside an ActionEvent?

so i can ahve an if statement in there suhc as;

if ((aPsource == btnRaise)&&(newcomboList == "Employee 1"))

WHat I am trying to do is give the 2 different Employees in the combo box raises. I want it so IF i select Employee 1 from combo box and hit raise it will give that employee a raise, then IF I select Employee 2 from the combobox it will give them a raise and set that value to the textbox.

===========
public void actionPerformed(ActionEvent aP){
Object aPsource = aP.getSource();
if (aPsource == btnRaise){

///// Employee 1 Raise //////

if ((Emp1.raisecnt == 0)&&(2006 - Emp1.getHireYear()) > 3){

hireYear = Emp1.getHireYear();
Emp1numsal = Emp1.getSalary();
Emp1newnumsal = Emp1.raiseSalary(Emp1numsal,hireYear);
Emp1Salary = twodp.format(Emp1newnumsal);
txtSalary.setText(Emp1Salary);

JOptionPane.showMessageDialog(null,"50% Raise Given","Raise",JOptionPane.WARNING_MESSAGE);
}

else if (((Emp1.raisecnt == 0)&&(2006 - Emp1.getHireYear()) < 3)){
JOptionPane.showMessageDialog(null,"No Raise Needed","No Raise",JOptionPane.WARNING_MESSAGE);
}

if (Emp1.raisecnt > 0){
JOptionPane.showMessageDialog(null,"Already Had Raise","No Cheating",JOptionPane.WARNING_MESSAGE);
}
Emp1.raisecnt++;
}

The code above is for an Action Event for a button called "btnRaise"


===============================
public void itemStateChanged(ItemEvent e){

Object source = e.getSource();
if(source == empList){

Object newempList = e.getItem();
if (newempList == "Martin Trebacz"){

txtHireYear.setText(Integer.toString(Emp1.getHireY ear()));
txtSalary.setText(Double.toString(Emp1.getSalary() ));



}

else if (newempList == "Sarah Madison"){
txtHireYear.setText(Integer.toString(Emp2.getHireY ear()));
txtSalary.setText(Double.toString(Emp2.getSalary() ));


}

that code above is for an Item Event, so if i select a particular employee it will set certain values to the txtBox.


New to Java so hope what I explained above is clear =/

Reply With Quote
  #2  
Old October 31st, 2006, 02:59 AM
xreddawg909x xreddawg909x is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2005
Posts: 91 xreddawg909x User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 27 m 20 sec
Reputation Power: 13
what kind of object are you adding the itemlistener to ? a JComboBox ? a radio button?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > A Way to use an ItemEvent inside an ActionEvent?


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap