473,412 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

jcheckbox and actionlisteners

i wondering if any with blueJ will look at my program, and just tell me what im doing wrong. ive been trying to solve this problem for 3 weeks now, and i am just sick of it.

email. <Email removed>
aim. <AIM removed>

thanks.

Expand|Select|Wrap|Line Numbers
  1.  public void actionPerformed (ActionEvent event)
  2.       {
  3.           if (bathroom.isSelected()) {
  4.  
  5.                    bathroomb=true;
  6.                     }
  7.  
  8.         if (bathroomb == true){
  9.    f1.dispose();
  10. }
  11. }
thats basicly my problem. i dont understand why its not working.
Oct 29 '07 #1
6 1374
Ganon11
3,652 Expert 2GB
What is bathroom and bathroomb?
Oct 29 '07 #2
bathroom is a checkbox

bathroomb is a boolean

sorry.
Oct 29 '07 #3
Ganon11
3,652 Expert 2GB
Well, I don't see why you need both bathroom and bathroomb. Why not have the code:

Expand|Select|Wrap|Line Numbers
  1. if (bathroom.isSelected()) {
  2.    f1.dispose();
  3. }
If you do this, and it doesn't work, check out the dispose method you are calling on f1 (whatever that is).
Oct 29 '07 #4
Expand|Select|Wrap|Line Numbers
  1.       if (bathroom.isSelected()) {
  2.  
  3.          System.out.println("WONT PRINT");
  4.  
  5.       }
i was just using f1.dispose as an example. im just saying the code wont work.
Oct 29 '07 #5
Ganon11
3,652 Expert 2GB
Well, I have no clue. perhaps a better explanation of "does not work" would be helpful? Does it not compile? Does it compile, but not run? Does it run, but not do what you expect? We're going to need more details and background, because the code you have given here looks perfectly alright.
Oct 29 '07 #6
r035198x
13,262 8TB
You use an ItemListener not an ActionListener for the JCheckbox to handle the event that you want to handle here. You should have read the Java tutorial here before you tried this.
Oct 29 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: do | last post by:
This is direction: Modifying the calculateJButtonActionPerformed method. Modify the if statement that starts in line 217 to check if the user has not entered a name and/or selected any...
4
by: outofmymind | last post by:
Hi there, I did this program, but, im having problems with attaching the events. i want the total bill amount to be calculated when i click the ‘OK’ button, and i need it to be displayed in the...
0
by: Richie01 | last post by:
Ok, here i have the code for the form...but whenever i click update, delete or search all it does is close the form and nothing is done to the database. Could someone be kind enough to help me out...
1
by: Nelson Joseph | last post by:
Hi all, could you please tell me how to add a chechbox in the JTable column header since I am new to Swing please help me.
8
Nepomuk
by: Nepomuk | last post by:
Hi everyone! I'm experiencing a very annoying problem - I have a few JCheckBoxes, which the user should not be able to select or deselect (it's done automatically). However, I don't seem to be able...
4
by: carlos123 | last post by:
this is pretty basic I'm sure for most of you, but im having alot of trouble with the 2. Here is my code its BlueJ. Im sure this is simple for most of you, but im totally lost. Please try to explain...
1
by: carlos123 | last post by:
Ok ive been looking around and i have having the same problem as this fellow<Removed> im trying to use the same action listener for the buttons and the combo boxes it doesnt seem to be working. check...
1
by: carlos123 | last post by:
if (bathroom.isSelected()){ bathroom is a jcheckbox, why doesnt that work.
8
by: carlos123 | last post by:
hello, i am making a hall pass program for my computer programming class. i am having issues with my jcheckboxes. first off. this file reads from a .txt that just has greg john joe 54343 45777...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.