473,378 Members | 1,492 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,378 software developers and data experts.

don't reset check box

19
Hi! this might be so easy but I can't make it work: I just have a check box, the user selects it, then the user exits that form, when the user comes back to the form I need the check box to be as the user left it.
I defined the check box not initialized but if I select it, then leave that form and come back the check box appears unselected.
Apr 10 '08 #1
3 1432
BigDaddyLH
1,216 Expert 1GB
Hi! this might be so easy but I can't make it work: I just have a check box, the user selects it, then the user exits that form, when the user comes back to the form I need the check box to be as the user left it.
I defined the check box not initialized but if I select it, then leave that form and come back the check box appears unselected.
More information please. What GUI is this? Swing? AWT? SWT?
Apr 10 '08 #2
aleplgr
19
Sorry, it's Swing...
Apr 10 '08 #3
BigDaddyLH
1,216 Expert 1GB
Sorry, it's Swing...
I'm surprised then that the control doesn't maintain its state. Can you post a simple yet runnable example of this behaviour?

edit: demo
Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4.  
  5. public class CheckBoxExample {
  6.     public static void main(String[] args) {
  7.         EventQueue.invokeLater(new Runnable(){
  8.             public void run() {
  9.                 createAndShowGUI();
  10.             }
  11.         });
  12.     }
  13.  
  14.     static void createAndShowGUI() {
  15.         final JFrame f = new JFrame();
  16.         final JDialog d = new JDialog(f, "checkbox", false);
  17.         d.getContentPane().add(new JCheckBox("See if state is maintained"));
  18.         d.pack();
  19.         JButton btn = new JButton("show dialog");
  20.         btn.addActionListener(new ActionListener(){
  21.             public void actionPerformed(ActionEvent e) {
  22.                 d.toFront();
  23.                 d.setVisible(true);
  24.             }
  25.         });
  26.         f.getContentPane().add(btn);
  27.         f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  28.         f.pack();
  29.         f.setLocationRelativeTo(null);
  30.         d.setLocationRelativeTo(f);
  31.         f.setVisible(true);
  32.     }
  33. }
If you close the dialog, then make it visible again you see that the checkbox state is maintained, so I don't see your problem.
Apr 10 '08 #4

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

Similar topics

6
by: google | last post by:
Hi, is it possible to reset a SELECT-Tag to it's default value but not reset all other form fields? Here's an example: <select id="myselect" name="myselect"> <option> value1 </option>...
0
by: Dan K. | last post by:
Hi NG, the problem : im working with the error provider (EP) to remind users of filling required fields. in each control i ve a check method which check the field inputs and set if needed the...
3
by: Gianmaria I. | last post by:
Hi, i'm using a timer like this: System.Timers.Timer myTimer= new System.Timers.Timer(60000); in some conditions i want my timer to be reset... so if something happen i know i want the timer to...
2
by: TD | last post by:
I've read several posts here that say global variables are reset whenever an unhandled error occurs. I want to use a custom form property instead of a global variable to store a boolean value. My...
7
by: Ina Schmitz | last post by:
Hi NG, I wanted to reset the database (manager) configuration with RESET DATABASE CONFIGURATION and RESET DATABASE MANAGER CONFIGURATION After doing this, I rebooted server and client and...
16
by: Animesh K | last post by:
What's the best practice for using an image for a reset button? Unfortunately, we cannot use <input type="image" src="..."in this case. Any helpful tutorial from the web will be appreciated. I...
2
by: DarthPeePee | last post by:
Hello everyone. I am working on a Password Strength Meter and I am running into 1 problem that I would like to fix. When pressing the "Clear Password & Try Again" button, the password clears...
7
by: sara | last post by:
I have a friend doing some pro-bono work for a non-profit that does job training for distressed kids under DCSS care. He asked me for code to do the following (he's using A2003). I can't find...
3
by: pinko1204 | last post by:
My Update function cannot successful update to sql table even don't have any error. Please help to check .....thx PHP1 <?php require_once 'header.php'; ?> <style type="text/css"> <!--
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.