Go Premium for a chance to win a PS4. Enter to Win

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
?
411 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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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 last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

971 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