Delete a selected row in JTable with a custom model

DefaultTableModel model = (DefaultTableModel) myTable.getModel(); //Get reference to model model.removeRow(x); //Remove row x You can also add a method deleteRow(int row) to your custom model class code as in: public class MyTableModel extends AbstractModel { private Vector dataVector = new Vector(); String[] columnNames = {"First Name", "Last Name", "Age"}; public int getRowCount() { if (dataVector.size() … Continue reading Delete a selected row in JTable with a custom model

Java program bug due to multiple declaration of variable in code and the fix

I created a small Java class to accept a date. However, when I tried to use it, I got a NullPointerException error. This post is just to illustrate how it was fixed. 1 public class DateForm { 2 JFormattedTextField txtMyDate;     //This is a variable at class level 3 4 dateForm () { 5 JTextFormattedField … Continue reading Java program bug due to multiple declaration of variable in code and the fix

How to restrict size of JButton in GridLayout in Java

If you put the following code in Java with only the lines in blue in your Java Swing program, you will find that whenever the Java dialog is resized, the button grows and looks ugly as it occupies the full row of the GridLayout. Code Segment as below. parameterPanel.setLayout(new GridLayout(2,1)); JButton parameterButton = new JButton("Parameters"); … Continue reading How to restrict size of JButton in GridLayout in Java

How to create a new stock quote source for Gnucash using Finance::Quote

Note that I no longer use github. This post is for technical users. The objective is to share how the MumbaiStock.pm module was created. Visit this other post to know how to add the MumbaiStock.pm to Gnucash and use it. Problem: A friend of mine uses Gnucash to manage their personal finances. They configured and … Continue reading How to create a new stock quote source for Gnucash using Finance::Quote

Database Design Utilities in Linux

If you are into designing databases, you can use the following open source database design software. I had a problem wherein it became quite difficult to manage a database with lots of tables and relationships, and these kind of software made database design much simpler. easyDesigner http://sourceforge.net/projects/easydesigner/ project Mogwai http://mogwai.sourceforge.net/index.html http://mogwai.sourceforge.net/erdesignerng.html DBDesigner4 http://www.fabforce.net/dbdesigner4/ Database Deployment … Continue reading Database Design Utilities in Linux

Write Ahead Logging in SQLite 3.7.0 version and above

So far, SQLite did support transaction control, but entirely in memory. Version 3.7.0+ of SQLite now have a Write-Ahead Logging feature that allow more speed and flexibility to SQLite to manage record locking and journal management. This feature is called 'wal' in SQLite 3.7.0+. To activate WAL on a SQLite database, start up SQLite and … Continue reading Write Ahead Logging in SQLite 3.7.0 version and above

Use JTextPane in Java with HTML to print reports

We are all familiar with the Java Swing class JTextArea. Java also has a method called print associated with the JComponent class that can be used to print a JTextArea contents onto a printer. JTextArea jt = new JTextArea(); jt.setText("whatever text you desire"); jt.print(); The above code segment will print the contents of the JTextArea jt … Continue reading Use JTextPane in Java with HTML to print reports

How to print a date in the default JTable.print() header and setup the page

After a struggle, managed to figure out that the MessageFormat is not that complicated at all. All I wanted was to print a heading on each page of the JTable with the current date in it. The heading was to read "Report as on " + today's date. Here is how I accomplished the task. … Continue reading How to print a date in the default JTable.print() header and setup the page

MyApp.MyListListener is not abstract and does not override abstract method actionPerformed(ActionEvent) in ActionListener

Below error means that the spelling of actionPerformed method is incorrect. MyApp.java:100: error: MyApp.MyListListener is not abstract and does not override abstract method actionPerformed(ActionEvent) in ActionListener public class MyListListener implements ActionListener { public void actionPeformed(ActionEvent ev) { See the spelling of actionPerformed. It is incorrect.