Solved

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

Posted on 1998-07-23
10
403 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

623 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