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

Working of FocusGained method

126 64KB
Can somebody tell me how focusgained method works?
I have a application in which as i enter the text in a textbox it should populate the jTable, My code takes 5 to 10 mins to populate the data, i use java netbeans and microsoft access database.
Expand|Select|Wrap|Line Numbers
  1. jTextField1.addFocusListener(this);
  2.  
  3.     public void focusGained(FocusEvent e) {
  4.         try {
  5.                 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  6. String filename = "C:/Users/Office User/Desktop/testfordb/test.mdb";
  7. String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
  8.                 database+= filename.trim() + ";DriverID=22}";
  9. Connection con = DriverManager.getConnection( database ,"",""); 
  10. Statement st = con.createStatement();
  11.                 // search
  12. String query1 = "select * from "+jTextField4.getText()+" where `U NAME` like '"+name.getText()+"%' ";
  13. ResultSet rs1 = st.executeQuery(query1); 
  14.                             jTable1.setModel(DbUtils.resultSetToTableModel(rs1));
  15.  
  16.         }
  17. catch (ClassNotFoundException | SQLException e) {
  18.  e.printStackTrace();
  19.  System.out.println("Error: " + e);
  20.     }
  21.     }
  22.  
  23.     public void focusLost(FocusEvent e) {
  24.        // Save the text 
  25.     }
Apr 13 '13 #1

✓ answered by r035198x

You need a KeyListener to listen for key events: http://docs.oracle.com/javase/tutori...ylistener.html

3 1915
Rabbit
12,516 Expert Mod 8TB
Focus happens when you first enter a control when you weren't in it before. If you want something to happen each time a key is pressed, you'll need to use that event.
Apr 14 '13 #2
PreethiGowri
126 64KB
If you want something to happen each time a key is pressed, you'll need to use that event.

I did not understand this, Can i get an example please?
Apr 15 '13 #3
r035198x
13,262 8TB
You need a KeyListener to listen for key events: http://docs.oracle.com/javase/tutori...ylistener.html
Apr 15 '13 #4

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

Similar topics

0
by: Peer Dr. Griebel | last post by:
Hi, I'm currently working on a Python Management Console. During inspection of my objects I stumbled over method-wrapper objects. Such an object may be obtained e.g. as method_wrapper =...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
5
by: RickDee | last post by:
Please help, anybody. I am trying to write a program so that it can launch an exe file ( which is also genereated in C# ) and then simulate the button clicking and invoke the methods inside the...
9
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. ...
19
by: Flavio | last post by:
hi, I have an object defined with a number of hardcoded methods. Class soandso: def __init__(self): self.this = 0 self.that = 1 def meth1(self): ...
3
by: =?Utf-8?B?Sm9obkJhdGVz?= | last post by:
I'm trying to (programatically) backup and clear the security event log on the local machine. I can do this manually through the event viewer and I am logged on as an administrator. I can...
7
by: cbmeeks | last post by:
Hope I'm using the right terminology. Anyway, say I have a class like: class Animal { public double GetValues() {......} public void FilterBy(string text); {......}
11
by: =?Utf-8?B?QkxVRVNUQVI=?= | last post by:
Here is the link of the website http://www.smartcharlotte2050.com/YourThoughts.asp I have been told to change only the form action part of this site.which is to "response.asp" Here the method...
0
by: Cameron Simpson | last post by:
On 24Sep2008 18:27, Tim Arnold <a_jtim@bellsouth.netwrote: | I have a bunch of processes to run and each one needs its own working | directory. I'd also like to know when all of the processes are...
2
by: Sisira behera | last post by:
have created a add email method (jquery) to validate a multiple emails for recipient text box. it's working fine when prototype.js is not declared on the page. To get rid of the $ conflict i also...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.