CookSwing Reference: Swing Component Tags


 

 

Support This Project

 

stats counter

 

Logo SourceForge.net Logo IntelliJ IDEA

Not all attributes of a tag are listed as it is rather a huge task for one person to really write a full documentation for the Swing. Just the ones that I did something special are listed. For the rest, you may find the tag reference of SwiXml, another cool XML to Swing toolkit, helpful. As always, Java JDK is the best source of the information.

Basically, for a class, any functions (static or non-static) start with "set" prefix and only has one parameter can be used as an attribute which does not have the "set" prefix and in lower case. For example, if you see a setSize(Dimension size) function, then there is an attribute "size", and the value for the attribute should be a Dimension object. Similarly for any public variables (static or non-static), there is a corresponding attribute name in lowercase. As always, check the converters page for the available converters that can convert string to the corresponding data type.

Notes:

  • An internal tag should not be used directly.
  • If a tag is inherited from a tag, then all attributes and adders are inherited from that tag. For example, textarea inherits textcomponent, which in turn inherts component. Then textarea has all the attributes and adders its ancestors textcomponent, and component have besides one it has, which has more prioity.

applet

Inherited from tag: window-constants

Class: JApplet


dialog

Inherited from tag: window-constants

Class: JDialog

Attribute Possible values Description
ctor id:name
var:name
If the constructor of the object is specified in the form of "id:name" or "var:name", then the object associated with the id or the variable is used to set the parent of the JDialog.
decorated boolean If value is "true", the dialog is built with a decorated frame.

frame

Inherited from tag: window-constants

Class: JFrame

Attribute Possible values Description
decorated boolean If value is "true", the dialog is built with a decorated frame.

internalframe

Inherited from tag: window-constants

Class: JInternalFrame


window

Inherited from tag: window-constants

Class: JWindow


component

Inherited from tag: listeners

Class: JComponent

Child Description
Border setBorder(Border border) is called.
LayoutManager setLayout(LayoutManager mgr) is called.
Component add(Component c) is called.

menubar

Inherited from tag: component

Class: JMenuBar


popupmenu

Inherited from tag: component

Class: JPopupMenu


menu

Inherited from tag: abstractbutton

Class: JMenu


menuitem

Inherited from tag: abstractbutton

Class: JMenuItem


menusplit

This tag is a way to insert a menu separator into the parent menu or popupmenu objects. Another way is to use the separator tag.


checkboxmenuitem

Inherited from tag: abstractbutton

Class: JCheckBoxMenuItem


radiobuttonmenuitem

Inherited from tag: abstractbutton

Class: JRadioButtonMenuItem


separator

Inherited from tag: component

Class: JSeparator


toolbar

Inherited from tag: component

Class: JToolBar


toolbar-separator

Inherited from tag: component

Class: JToolBar.Separator


button

Inherited from tag: abstractbutton

Class: JButton


togglebutton

Inherited from tag: abstractbutton

Class: JToggleButton


radiobutton

Inherited from tag: abstractbutton

Class: JRadioButton


checkbox

Inherited from tag: abstractbutton

Class: JCheckBox


label

Inherited from tag: component

Class: JLabel

Attribute Possible values Description
displayedmnemonic integer One of the value with "VK_" prefix in KeyEvent. This attribute is typically used in conjunction with "labelfor" attribute.
labelfor Component It can be either "id:idReference" or "var:variableReference". Ids/Variables declared after this label tag) can be used.

textfield

Inherited from tag: textcomponent

Class: JTextField


formattedtextfield

Inherited from tag: textfield

Class: JFormattedTextField


passwordfield

Inherited from tag: textfield

Class: JPasswordField


textarea

Inherited from tag: textcomponent

Class: JTextArea


textpane

Inherited from tag: textcomponent

Class: JTextPane


editorpane

Inherited from tag: textcomponent

Class: JEditorPane


panel

Inherited from tag: component

Class: JPanel


desktoppane

Inherited from tag: component

Class: JDesktopPane


splitpane

Inherited from tag: component

Class: JSplitPane


scrollpane

Inherited from tag: component

Class: JScrollPane

Child Description
Component setViewportView (Component c) is called.

rootpane

Inherited from tag: component

Class: JRootPane

Child Description
menubar setJMenuBar(JMenuBar menuBar) is called.
Container setContentPane(Container contentPane) is called.

tabbedpane

Inherited from tag: component

Class: JTabbedPane


tab

Helper: TabHelper

This tag is used to add a component to the parent tabbedpane element with specified title, icon, etc.

Attribute Possible values Description
mnemonic integer One of the value with "VK_" prefix in KeyEvent
Child Description
Component The component is added to the tabbedpane using the attributes specified in the tab.

filechooser

Inherited from tag: component

Class: JFileChooser

Attribute Possible values Description
approvedbuttonmnemonic integer One of the value with "VK_" prefix in KeyEvent

colorchooser

Inherited from tag: component

Class: JColorChooser


table

Inherited from tag: component

Class: JTable


defaulttablemodel

Class: DefaultTableModel

Child Description
Vector addRow (Vector rowData) is called.
Map The entries in the map are sorted by the key and then each entry are entered as a row into the model.

tableheader

Inherited from tag: component

Class: JTableHeader

This tag does not create a JTableHeader object, but rather it takes the JTableHeader from the JTable parent object.


list

Inherited from tag: component

Class: JList


defaultlistmodel

Class: DefaultListModel

Child Description
Object addElement(Object obj) is called.

tree

Inherited from tag: component

Class: JTree


combobox

Inherited from tag: component

Class: JComboBox

Child Description
Object addItem(Object obj) is called.

defaultcomboboxmodel

Class: DefaultComboBoxModel

Child Description
Object addElement(Object obj) is called.

progressbar

Inherited from tag: component

Class: JProgressBar


scrollbar

Inherited from tag: component

Class: JScrollBar


slider

Inherited from tag: component

Class: JSlider


spinner

Inherited from tag: component

Class: JSpinner


tooltip

Inherited from tag: component

Class: JToolTip


uimanager

Attribute Possible values Description
ctor Object UIManager.get(Object key) is called to retrieve the value. See UIManager.
systemlookandfeel boolean If the value is "true", UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) is called to install the system look&feel.
lookandfeel String UIManager.setLookAndFeel(String className) is called.

listeners

internal

Basically this internal tag redirect the setting of listener attributes to functions that add listeners. For example, an attribute setting actionlistener="myActionListener" would become addActionListener (myActionListener), where myActionListener is the variable name. All listeners defined in JDK are included.


window-constants

internal

Inherited from tag: listeners

Attribute Possible values Description
locationrelativeto Component If value is "true", the window is centered on the component after all internal components are setup and size specified.
packed boolean If value is "true", the size of the window is set to its preferred size after all internal components are setup.
Child Description
menubar setJMenuBar(JMenuBar menuBar) is called.
Container setContentPane(Container contentPane) is called.

abstractbutton

internal

Inherited from tag: component

Attribute Possible values Description
action String The value should be the name of the variable which holds an Action object.
mnemonic integer One of the value with "VK_" prefix in KeyEvent

textcomponent

internal

Inherited from tag: component


buttongroup

Class: ButtonGroup

Child Description
abstractbutton add(AbstractButton button) is called.

syncbuttonstate

Helper: SyncButtonStateHelper

Child Description
abstractbutton Buttons in this element have synchronized states.

(c) Copyright 2004-2007 Heng Yuan. All rights reserved.

Valid XHTML 1.0! Valid CSS!