Programming Examples

Are you a Programmer or Application Developer or a DBA? Take a cup of coffee, sit back and spend few minutes here :)

JTextPane & Text Formatting

Java Swing JTextPane Example

The example is a JFrame Window which houses a JTextPane. Here, one can see the JTextPane Example displaying the content with a mixture of texts and images. The document displays heading text in blue colour and normal text in red colour. The heading text is slightly bigger than the normal text. Towards the end of the document, there will be document footer in green colour. This is not shown above.

Using this example, we will learn how to insert text and image into the JTextPane. At this moment, we can also visualize that we have three variations of the text and, in this example, we will group three types of text formatting styles to prepare the document.

Continue Reading →

JRadioButton & ItemListener

JRadioButton Example

Our example shows three radio buttons in a form. A user can select any one of these radio buttons and only one radio button will be in the selected state. Above, the radio button three is in the selected state. When a radio button is in checked (selected) state, our example will flash a message box stating which radio button is in the selected state. Here in this example, we will create all these radio buttons using JRadioButton component of the Java Swing.

Continue Reading →