SWING / NOTES</>↗Swing06 Jun 2009
The SpinnerDateModel allow us to display and select date information from the JSpinner component. By default, the initial value of the model will be set to the current date. To change it we can call the setValue method of the JSpinner object. package org.kodejava.swing; import javax.swing.*; import java.awt.*; import java.util.GregorianCalendar; import java.util.Calendar; public class JSpinnerDate […]
SWING / NOTES</>↗Swing03 Jun 2009
This example show you how to create a JSpinner component and pass a SpinnerListModel as the available values of the JSpinner component. The SpinnerListModel can hold a value of collections object and a simple array of object instance. package org.kodejava.swing; import javax.swing.*; import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class JSpinnerCreateDemo extends JFrame { public […]
SWING / NOTES</>↗Swing31 May 2009
JSpinner is a single line input field with two buttons (arrow up and arrow down) that allow us to select a value like number or object from a sequence value. It looks like a combobox without a drop-down. In the following example we create the default JSpinner that will give us a spinner to select […]
JDOM / NOTES</>↗JDOM31 May 2009
The following example demonstrates how to read mixed content of an xml element. A mixed content can have more than one type of content such as text (Text), comment (Comment), CDATA (CDATA) or some child elements (Element). You also see that we can remove the mixed content from the element by calling the remove method […]
JDOM / NOTES</>↗JDOM29 May 2009
This example demonstrates how to add CDATA section into an xml document. A CDATA section indicates a block that shouldn’t be parsed. To build a CDATA section just wrap the string with a CDATA object. package org.kodejava.jdom; import org.jdom2.CDATA; import org.jdom2.Document; import org.jdom2.Element; import org.jdom2.JDOMException; import org.jdom2.input.SAXBuilder; import org.jdom2.output.Format; import org.jdom2.output.XMLOutputter; import java.io.IOException; import java...
JDOM / NOTES</>↗JDOM28 May 2009
This example show you how so set text content of XML element. Using JDOM we can easily insert text such as HTML tags without worrying about escaping the tags. JDOM will automatically do this conversion. package org.kodejava.jdom; import org.jdom2.Document; import org.jdom2.Element; import org.jdom2.JDOMException; import org.jdom2.input.SAXBuilder; import org.jdom2.output.Format; import org.jdom2.output.XMLOutputter; import java.io.IOException; import java.io.StringReader; pub...