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: swing
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
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.
Error Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException in Java program
In your Java code, you have the following code segment: public class BigOne { public static int i = 0; JButton onebutton; JLabel label; JFrame frame; public static void main(String[] args) { BigOne gui = new BigOne(); gui.go(); } public void go() { frame = new JFrame(); … Continue reading Error Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException in Java program
Use Windows Builder from Google to create GUIs in Java quickly
If you use Eclipse to create Java programs, you would know that there are several plugins that enable Eclipse to do magic. However, the Google Windows Builder plugin available from the eclipse market place, almost proves it can make "coffee". Using Windows Builder, you can create GUI windows using Swing, SWT or XWT in minutes. … Continue reading Use Windows Builder from Google to create GUIs in Java quickly