Skip to main content

Posts

JForm: Fill the form with style

After understanding and using swing toolkit, I understood that there is a allot of scope to develop Custom components easily. I have developed a component called JForm which basically a button and its selection pops up a window if it is not visible. Technically the JForm component is a combination of 2 components they are: 1. JButton 2. Window JButton is a API of swing toolkit where as Window is a API of AWT. Behaviour of JForm: JForm is a usual button like JButton. but it is glued to a Window component. this Window takes a JPanel class as an arguments. In the given example has 2 components they are 1. JTextArea  2. JButton [Submit] which are appended to a JPanel.. The below image shows the effect before selecting the JForm: This image shown is the effect after selecting the JForm:                                       the below code is an example which i...

JColorComboBox: JComboBox as Color Chooser

  Swing toolkit provides a component called JColorChooser to choose colors. It allows users to select color from multiple color combinations. Some times our application may need simple component with an option to select only basic colors/ less number of color options unlike sepearate dialog with too may color options[JColorChooser]. This JColorComboBox may serve the need. I wanted my color chooser to behave like JComboBox. The popup shows all 12 colors and their names, among all of them one color can be choosen. see the below image. I created two classes          1. JColorComboBox          2. ColorRenderer JColorComboBox extends the JComboBox and ColorRenderer extends JLabel and implements ListCellRenderer. import java.awt.Color; import java.awt.Component; import java.awt.Font; import java.util.Enumeration; import java.util.Hashtable; import javax.swing.*; /** * * @author sharath */ public class JCol...

Romain guy's blog

If you are interested in designing GUIs and building custom components with Swing toolkit, definitely Romain guy's blog  can be good reference for you, he writes about his work on swing components, custom components, tips and tricks on designing and using components. and you can download the demos of his work. You find more swing articles in 2005, 2006 archives. His URL: http://www.curious-creature.org/

DesignGridLayout: Simple, yet powerful Layoutmanager for arranging swing components

Swing toolkit comes with few standard Layout Managers where none of them serves the need of arranging components in a way that usually developers require. some of them does, but it takes lot of coding time to achieve it. GridBagLayout is the most flexible layout manager available in swing toolkit but their are so many variables that developer has to look after. DesignGridLayout can be a useful LayoutManager to arrange components in less time with very small snippet of code and can still get proper alignment. Layouting with DesignGridLayout is as easy as coding with various GUI Builder tools available in varoius IDEs. Simple program which demonstrates DesignGridLayout: import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import net.java.dev.designgr...

Java IDE for Learners:

           Simple editors like Notepad, Gedit, edit+  definitely allows us to write a program, but it is always difficult to code, debug and manage even smaller applications. and profession IDEs like Eclipse, Netbeans JDeveloper are definitely not suitable for beginners.[They are pretty advanced to students]            What if we have an IDE which allows the learners to understand the basic coding principles of java, Fundamentals of Object Oriented Programming[OOP] with the pictorial representation along with syntax highlighting, scope highlighting and other cool features?.. sounds good right.                                           BlueJ is a simple Java based IDE developed by Kent university for the beginners and students of Java programming language. The coolest thing about BlueJ is it not only allows ...

Controlling an executable from Java program

Windows tools like Notepad, internet explorer and other executable files can be started from java program through its core API. Procedure to start a Notepad application from java program:  Create an object for Runtime class                          Runtime runtime = Runtime.getRuntime();         Create the command string                          String command = "notepad.exe";         Call exec()                          try{                              Process process = runtime.exec(command);                          }catch(IOException e){                 ...

Introducing Java 7: Moving Java Forward

Hey check out this!.....Oracle is going to introduce Java 7 on July 7 Some of the latest innovations and changes in Java 7 are: 1. A fully functional and supported NIO.2 filesystem provider for zip and jar files. 2. Small language changes and enhancements [Project Coin]         Project Coin includes               Strings in switch statements               try-with-resource statements               Improved type inference for generic instance creation               simplified varargs method invocation               better integral literals,               and improved exception handling[multiple catch] 3. Support for Dynamically typed languages For attending live webcast just by sitting at your desk and for registrations  click below link http://www.o...