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
Tag: java
How to create a .jar file with entry point using jpackit for your Java application
Download jpackit from this link http://sourceforge.net/projects/jpackit/ Create a jar file of all the *.class files in your java folder $ jar -cvf myapplication.jar *.class <enter> Start jpackit as follows: $ java -jar jpackit-1.0.2.jar <enter> Now fill in the parameters by clicking the Choose ... button next to them Parameter Value Comment Base Dir /home/user/myapplication The … Continue reading How to create a .jar file with entry point using jpackit for your Java application
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
How to open multiple buffers in JEdit like in GEdit or Mousepad
Many of us use a text editor to edit program code. The simplest and clean edit is GEdit on the Gnome desktop. However, if you are not on the Gnome desktop, you may miss it. You can use JEdit which is much more powerful, however, by default, it does not open multiple programs alongside each … Continue reading How to open multiple buffers in JEdit like in GEdit or Mousepad
Install Oracle Java SDK on Fedora 18
Download the RPM for the 64 bit version from http://www.oracle.com/technetwork/java/javase/downloads/index.html Next install it on your computer by typing in a terminal window: # yum localinstall jdk*.rpm <enter> Once that is done, you need to now set up the alternatives to the OpenJDK version that is on your system. To change the alternatives, follow the steps … Continue reading Install Oracle Java SDK on Fedora 18
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.
Use SQLite with Java
In order to use SQLite 3 with Java, you need to do the following steps on your Linux or Windows box. I have deliberately kept off specific commands. Install SQLite3 from your Linux distribution repository. You can also download the Windows edition if you use Windows. Visit https://bitbucket.org/xerial/sqlite-jdbc and download the JDBC driver. I downloaded … Continue reading Use SQLite with Java
Very good example of Swing and JDBC code in Java
If you are new to Java Programming and need to understand clearly how Swing GUIs and JDBC work together for GUI and databases, you should have a look at http://www.javabeginner.com/java-swing/java-swing-address-book. One of the best examples available on the net to understand database programming.
Form fields height in Java – how to align correctly
When you create a GridLayout in Java Swing, you should define the main labels and the fields one after another. Then only you get the correct height of the fields. If you define all labels first and then all the fields later, the height of the rows and columns does not align correctly.
JEdit – powerful code editor for programmers
For code editors who do not need to use an IDE like Eclipse or Netbeans for programming, a good option is the JEdit programmers' code editor. It is open source and cross-platform. You can get it at http://www.jedit.org/