Solved

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

Posted on 1998-07-23
10
362 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
 
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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 100 total points
ID: 1228021
Thanks AmyS
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now