How to update or commit code changes from local github repository to repository on github

A user can make changes to code in their local folder (in this case, MumbaiStock) and then update or commit  that code into the github repository. Below is the user information: github User ID is userid github User Name is "UserFirstName UserLastName" github User Email is "user@emailsystem.com" To update github or commit code from the … Continue reading How to update or commit code changes from local github repository to repository on github

Read data from a JTable created from AbstractTableModel

If you have a JTable in Java created with an AbstractTableModel, you can read the data from it, using following: int rowCount = testTable.getRowCount(); for (int i = 0; i < rowCount; i++) { String mColumn1 = (String) testTable.getModel().getValueAt(i, 0); String mColumn2 = (String) testTable.getModel().getValueAt(i, 1); } Alternatively, you could also try where the JTable … Continue reading Read data from a JTable created from AbstractTableModel

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 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

Create Java JAR file with execution entry point (main)

$ jar -cfe ContactListTestDrive.jar ContactListTestDrive ContactListTestDrive.class ContactList.class Contact.class <enter> where: JAR file = ContactListTestDrive.jar Entry Point class = ContactListTestDrive Entry Point class = ContactListTestDrive.class (This is the class with the main() function) ContactList.class and Contact.class are the other classes to add to the JAR file. Normally this is automatically done when you use an IDE … Continue reading Create Java JAR file with execution entry point (main)

Head First Java – Learn Java the fun way

After many years of trying to learn Java from a good book, I finally got down to learning it from "Head First Java". The authors have done a great job explaining programming concepts, object oriented programming concepts and Java in a fun way. All the investments made thus far, in other books were just that... … Continue reading Head First Java – Learn Java the fun way

Convert and compress PNG files to JPG in bulk

To compress PNG files to JPG, you can follow steps below: I. Convert all PNG files to JPG: Create a script using your favorite Linux text editor and type in the following lines: for i in $(ls *.png); do convert $i $i.jpg done II. Convert the JPG quality to 50% compression To compress the JPG … Continue reading Convert and compress PNG files to JPG in bulk