How to code multiple line tooltips with bold text

Many Java programs use tool tips in Java Swing to display more information when the mouse cursor hovers over a button or text field. There is a method of making text within that tool tip bold, italics, colored and more. Below is an illustration of the command that uses HTML tags to display that formatting . . . → Read More: How to code multiple line tooltips with bold text

How to close the program in Java completely in Swing

A Java Swing application can be closed using the following code segment to retrieve the parent of the container, check if it is a JFrame and then dispose the JFrame:

public class btnCancelListener implements ActionListener { public void actionPerformed(ActionEvent ev) { Container bframe = btnCancel.getParent(); bframe = bframe.getParent(); while (! (bframe instanceof JFrame)) { System.out.println(“Done”); . . . → Read More: How to close the program in Java completely in Swing

How to disable File Name Input in JFileChooser in Java

JFileChooser is a very powerful Component in Java. It even enables filtering of file names. However, there is no direct method to prevent a user from entering the File Name input in it.

The following method disables the JTextField File input text box in  JFileChooser, by basically taking the JFileChooser as a Component, looking for . . . → Read More: How to disable File Name Input in JFileChooser in Java

Error building Java Program in Eclipse Mars after changing Java version

Right Click on the Project in the Package Explorer. Select Build Path -> Configure Build Path -> Libraries. Now remove JRE System Library 1.7 and add the one for java-8-oracle by clicking on Add Library -> JRE System Library -> Click Execution Environment and set that to JavaSE-1.8 (java-8-oracle). Click Finish.

This resolves the error . . . → Read More: Error building Java Program in Eclipse Mars after changing Java version

How to resolve update-binfmts: warning: current package is oracle-java8, but binary format already installed by openjdk-7

I earlier had Oracle Java 7 installed on my Linux box. I upgraded to Oracle Java 8 as follows (below commands to be typed in a terminal window): $ sudo apt-get purge oracle-java7-installer <enter> $ sudo apt-get install oracle-java8-installer <enter>

However, when Oracle Java 8 was downloaded and installed, I saw a message like this: . . . → Read More: How to resolve update-binfmts: warning: current package is oracle-java8, but binary format already installed by openjdk-7

GridLayout struggle when it has excess rows and how to overcome

In my Java code, I am using GridLayout (line shown in red) in code below:

frame = new JFrame(“Contacts Details”); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainPanel = new JPanel(); buttonPanel = new JPanel(); mainPanel.setLayout(new GridLayout(9, 3)); buttonPanel.setLayout(new GridLayout(1, 3));

The result was this:

Name [                        ] (Text Box for name) City [                        ] (Text Box for City) Cell . . . → Read More: GridLayout struggle when it has excess rows and how to overcome

Where to place a text file for use with a Java project in Eclipse

I placed a text file myapp.txt in the folder ~/workspace/PayrollApp/src/org/username/payrollapp. However, it was not opening in the Java program.

To make it work correctly, I had to do use the following path in the Java program when opening the file: src/org/username/payrollapp/pay.txt

Code as follows:

try { FileReader fr = new FileReader(“src/org/username/payrollapp/pay.txt”); BufferedReader br = new . . . → Read More: Where to place a text file for use with a Java project in Eclipse

Where to place SQLite 3 database for use in a Java Project in Eclipse

My Eclipse Java project path is as follows: ~/workspace/PayrollApp/src/org/username/payrollapp/payroll.db

I had placed the SQLite database file payroll.db in the above path, and found it was not getting used when I ran the Java program.

Upon inspecting the contents of ~/workspace/PayrollApp, I found that payroll.db was there with 0 bytes. That implied that the file needs . . . → Read More: Where to place SQLite 3 database for use in a Java Project in Eclipse

Window Builder Pro hangs in Eclipse Luna on Ubuntu 14.04 LTS

If you use Eclipse IDE for Java development, you will find that there is a great GUI builder from Google, and it worked very well on previous releases of Ubuntu.

Unfortunately, Eclipse just freezes when you use Windows Builder on 64 bit Ubuntu 14.04 LTS. Several posts on the Internet suggest installing Oracle Java 7 . . . → Read More: Window Builder Pro hangs in Eclipse Luna on Ubuntu 14.04 LTS

How to make a form refer to the parent frame using a JDialog

Below code segment shows how to use a JDialog to refer to a parent frame. MyApp.java

public class MyApp { JDialog dialog; JFrame parentFrame; public static void main(String[] args) { MyApp app = new MyApp(); app.gui(); } public void gui() { //The parentFrame parentFrame = new JFrame(); parentFrame = setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //The dialog dialog = . . . → Read More: How to make a form refer to the parent frame using a JDialog

November 2017
M T W T F S S
« Aug    
 12345
6789101112
13141516171819
20212223242526
27282930