How do I get runtime information about the JDBC Driver?

Use the following DatabaseMetaData methods:       * getDriverMajorVersion()     * getDriverMinorVersion()     * getDriverName()     * getDriverVersion()

How does the Java Database Connectivity (JDBC) work?

The JDBC is used whenever a Java application should communicate with a relational database for which a JDBC driver exists. JDBC is part of the Java platform standard; all visible classes and interfaces used in the JDBC are placed in package Java   Main JDBC classes:       * DriverManager. Manages a list of database [...]

How do I let my Swing text component support undo/redo?

The Swing text components come with built in support for undoing and redoing text operations. All you have to do is associate an UndoManager to the Document of the text component:   JTextField textField = new JTextField(); UndoManager manager = new UndoManager(); Document document = textField.getDocument(); document.addUndoableEditListener(manager);     Then, when it comes time to [...]

How do I display a multi-line tooltip?

You can include HTML content in tooltip text as follows:   setToolTipText(“<html>This is the first line<br>This is the second line</html>”);

How can I validate data entered in a TextField?

You can validate the data in any of the three location       * As the user types characters       Register a DocumentListener with the JTextField and validate data in the events of DocumentListener.     * After the user is done with the field       You need to register listeners for: Focus change (leaving the [...]

What exactly is the “Event Dispatch” thread (aka “AWT” Thread)?

When you run a GUI applet or application, the code in your main() method creates a GUI and sets up event handling. When you call setVisible(true) for your Frame, Window, Dialog, or when the browser displays the Applet, the user must be able to interact with the GUI.   The problem is that your main() [...]

How do I ensure a specific row is visible in my JTable?

To ensure a specific row (or cell) is visible, you need to get the rectangle surrounding a specific row/column (cell) than make sure that is visible:   Rectangle rect = table.getCellRect(row, column, true); table.scrollRectToVisible(rect);

How do I change the current look and feel of my Swing program?

You can either call the setLookAndFeel() method of the UIManager class or set the swing.defaultlaf property of your Java program before it starts.   If you wish to change the look and feel of a running program, you will need to call the updateComponentTreeUI() method of the SwingUtilities class to update each top-level window.   [...]

How can I determine the active JFrame?

Call Frame.getFrames() which will return all frames created by the application.   Frame[] f = Frame.getFrames(); Frame active = null; for (int i = 0; i < f.lenght; i++) {   if (f[i].isActive()) {     active = f[i];     break;   } }  

What is the difference between AWT and SWT?

SWT (Standard Widget Toolkit) is a completely independent Graphical User Interface (GUI) toolkit from IBM. They created it for their new Eclipse Integrated Development Environment (IDE).   IBM began work on SWT a few years ago, because Swing was still immature and didn’t perform well. They decided to create a new toolkit to provide better [...]

Follow

Get every new post delivered to your Inbox.