Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to set format to TextField and get data from the database to choice box

Posted on 1998-07-23
10
Medium Priority
?
409 Views
Last Modified: 2011-05-06
1.       Could you please help me write an application program to set format to TextFields:  
          phone number "(###)#### - ####"), time "00:00:00",  and get data such as phone number
          and address (State is a choice box in the user interface) from the "registration" table in
          database MOCS.mdb(c:/DB/MOCS.mdb)?
          My system data source name is "MyProject", and the driver is "Microsoft Access
          Driver(*.mdb).
         
2.      What are problems in the following codes?

              //Declare a public variables' class
              import java.awt.*;
              public class variable
              {
                  TextField Course1, Course2;
              }
0
Comment
Question by:AmyS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
10 Comments
 

Author Comment

by:AmyS
ID: 1228012
Edited text of question
0
 
LVL 1

Expert Comment

by:dryang
ID: 1228013
Can't answer the first one but the second is this:

1) If you want the data available for all methods to read and access

              public class variable
                 {
                     public static TextField Course1, Course2;
                 }

2) Or to encapsulate the data and use methods to access them (safer way)

              public class variable
                 {
                     TextField Course1, Course2;
                     
                     public TextField getCourse1()
                     {
                       return Course1;
                      }

                     public TextField getCourse2()
                     {
                       return Course2;
                      }
                  }

if you want to do it using the second way, remember to have methods to write to the TextFields!

cheerios
0
 
LVL 1

Expert Comment

by:dryang
ID: 1228014
ARRRRRRRRRRRRRGH! I'm getting senile

to answer your second question of what's wrong
- your data is not accessible to all mehods and classes. Any variables without the private, protected or public tags are consedered 'friendly' to the class itself (which means extremely unfriendly to others!)


0
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
LVL 2

Expert Comment

by:threshold
ID: 1228015
It's not easy for your first question, here is my solution:
  Make a Class to implement TextListener, and use TextField.addTextListener(...) to let your class can receive TextEvent from TextField.
  When your Class receives the TextEvent (when the text of TextField is changed),
    the method textValueChanged(...) will be actived.
  So, you should write some code in textValueChanged() of your Class to check/modify content of TextField with your pattern. You need to save legal content in every time.

  The another way is to create your own awt component that can fire KeyEvent and check current context with patterns.

  If you know about java bean, you can create your own bean for this purpose!

  Check the document of JDK1.1.x and java.sun.com, there are many examples and documents about Bean, and Event model.
0
 

Author Comment

by:AmyS
ID: 1228016
Thank Dryang for answering my second question. I should give him/her points, but I don't
know how I can do in this window. Sorry!
Actually, Dryang's answer for the first question was not clear. I hope somebody can help me write an application code for the first question ( at least, to solve the problem that
how to get data such as phone number and address (State is a choice box in the user interface) from the "registration" table in database MOCS.mdb(c:/DB/MOCS.mdb)?
My system data source name is "MyProject", and the driver is "Microsoft Access
Driver(*.mdb)". ).
0
 
LVL 1

Expert Comment

by:dryang
ID: 1228017
Its ok, AmyS. anyway, I was answering the second question only and did not touch the first question at all :) .
0
 
LVL 2

Expert Comment

by:threshold
ID: 1228018
Oh, To Know how to get data from .mdb file is a long story.
First, you should know about JDBC, and ODBC. then you can access .mdb file via JDBC-ODBC...
second, turn on the option 'view the system table' of access. Then you can get the table definition from .mdb file and read the input mask into JAVA.

0
 
LVL 2

Expert Comment

by:threshold
ID: 1228019
sorry, wrong click by me. The last post should be a comment, not answer...
0
 

Author Comment

by:AmyS
ID: 1228020
I have spent one more week to wait somebody help me write a simple program
to solve my first question. Now what should I do for the points?

0
 
LVL 1

Accepted Solution

by:
dryang earned 400 total points
ID: 1228021
Thanks AmyS
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question