How to install Java 8 SE and run Income Tax India ITR 2019 Java utilities in Linux

Those who want to run the ITR Java utilities released by the Income Tax Department India on Linux, must note that Java 8 SE is no more supported by Oracle. It is outdated and has security bugs which have been fixed in future versions. Future versions do not run the ITR utilities. Follow below at … Continue reading How to install Java 8 SE and run Income Tax India ITR 2019 Java utilities in Linux

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 … Continue reading 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"); … Continue reading How to close the program in Java completely in Swing

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 [                        … Continue reading 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 … Continue reading 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 … Continue reading Where to place SQLite 3 database for use in a Java Project in Eclipse

How to filter selection of files by extension in Java Swing’s JFileChooser

Display of files of a particular extension like .txt or .csv in JFileChooser can be done using the FileNameExtensionFilter in Java as follows: fileChooser = new JFileChooser(); fileChooser.setSelectedFile(null); FileNameExtensionFilter fileFilter = new FileNameExtensionFilter("CSV Files", "csv"); fileChooser.setFileFilter(fileFilter); fileChooser.showOpenDialog(frame);

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 = new … Continue reading How to make a form refer to the parent frame using a JDialog