/************************************************************************
* *
* javax.swing *
* *
* Interfaces: *
* Action MenuElement *
* BoundedRangeModel MutableComboBoxModel *
* ButtonModel Renderer *
* CellEditor RootPaneContainer *
* ComboBoxEditor Scrollable *
* ComboBoxModel ScrollPaneConstants *
* DesktopManager SingleSelectionModel *
* Icon SwingConstants *
* JComboBox.KeySelectionManager UIDefaults.ActiveValue *
* ListCellRenderer UIDefaults.LazyValue *
* ListModel WindowConstants *
* ListSelectionModel *
* *
* Classes: *
* AbstractAction JMenuItem *
* AbstractButton JOptionPane *
* AbstractListModel JPanel *
* BorderFactory JPasswordField *
* Box JPopupMenu *
* BoxLayout JProgressBar *
* ButtonGroup JRadioButton *
* CellRendererPane JRadioButtonMenuItem *
* DebugGraphics JRootPane *
* DefaultBoundedRangeModel JScrollBar *
* DefaultButtonModel JScrollPane *
* DefaultCellEditor JSeparator *
* DefaultComboBoxModel JSlider *
* DefaultDesktopManager JSplitPane *
* DefaultFocusManager JTabbedPane *
* DefaultListCellRenderer JTable *
* DefaultListModel JTextArea *
* DefaultListSelectionModel JTextField *
* DefaultSingleSelectionModel JTextPane *
* FocusManager JToggleButton *
* GrayFilter JToolBar *
* ImageIcon JToolTip *
* JApplet JTree *
* JButton JViewport *
* JCheckBox JWindow *
* JCheckBoxMenuItem KeyStroke *
* JColorChooser LookAndFeel *
* JComboBox MenuSelectionManager *
* JComponent OverlayLayout *
* JDesktopPane ProgressMonitor *
* JDialog ProgressMonitorInputStream *
* JEditorPane RepaintManager *
* JFileChooser ScrollPaneLayout *
* JFrame SizeRequirements *
* JInternalFrame SwingUtilities *
* JLabel Timer *
* JLayeredPane ToolTipManager *
* JList UIDefaults *
* JMenu UIManager *
* JMenuBar ViewportLayout *
* *
* InnerClasses: *
* Box.Filler *
* DefaultListCellRenderer.UIResource *
* JInternalFrame.JDesktopIcon *
* JPopupMenu.Separator *
* JToggleButton.ToggleButtonModel *
* JToolBar.Separator *
* JTree.DynamicUtilTreeNode *
* JTree.EmptySelectionModel *
* ScrollPaneLayout.UIResource *
* UIManager.LookAndFeelInfo *
* *
* Exceptions: *
* UnsupportedLookAndFeelException *
* *
************************************************************************/
package Test.Chris;
import javax.swing.*;
public class Javax_swing {
private String TESTGIF = "Test/Chris/TestBeanIconColor16.gif";
public static void main(String[] args) {
Javax_swing obj = new Javax_swing();
obj.jframe();
System.exit(0);
}
/*********************************************************************
* *
* JFrame: *
* *
* Fields: *
* $accessibleContext $rootPaneCheckingEnabled *
* $rootPane *
* *
* Methods: *
* $addImpl $processKeyEvent *
* $createRootPane $processWindowEvent *
* $frameInit setContentPane *
* getAccessibleContext setDefaultCloseOperation *
* getContentPane setGlassPane *
* getDefaultCloseOperation setJMenuBar *
* getGlassPane setLayeredPane *
* getJMenuBar setLayout *
* getLayeredPane $setRootPane *
* getRootPane $setRootPaneCheckingEnabled *
* $isRootPaneCheckingEnabled update *
* $paramString *
* *
*********************************************************************/
private JFrame myFrame = new JFrame("Test Frame");
private boolean myFrameActive = true;
void jframe() {
int i;
boolean b;
String s;
java.awt.Dimension d;
JRootPane rp;
JLayeredPane lp;
java.awt.Container cp;
java.awt.Component gp;
JMenuBar mb;
javax.accessibility.AccessibleContext a;
i = myFrame.getDefaultCloseOperation(); // Returns the operation which occurs when the user initiates a "close" on this frame
a = myFrame.getAccessibleContext(); // Get the AccessibleContext associated with this JFrame
rp = myFrame.getRootPane(); // Returns the rootPane object for this frame
lp = myFrame.getLayeredPane(); // Returns the layeredPane object for this frame
cp = myFrame.getContentPane(); // Returns the contentPane object for this frame
gp = myFrame.getGlassPane(); // Returns the glassPane object for this frame
mb = myFrame.getJMenuBar(); // Returns the menubar set on this frame
myFrame.setDefaultCloseOperation(
myFrame.HIDE_ON_CLOSE); // Sets the operation which will happen by default when the user initiates a "close" on this frame
myFrame.setLayeredPane(lp); // Sets the layeredPane property
myFrame.setContentPane(cp); // Sets the contentPane property
myFrame.setGlassPane(gp); // Sets the glassPane property
myFrame.setJMenuBar(mb); // Sets the menubar for this frame
myFrame.update(myFrame.getGraphics()); // Just calls paint(g)
d = myFrame.getToolkit().getScreenSize();
myFrame.setVisible(true);
try {
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
// UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
// UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
} catch(UnsupportedLookAndFeelException e) {
System.out.println(e);
} catch(InstantiationException e) {
System.out.println(e);
} catch(ClassNotFoundException e) {
System.out.println(e);
} catch(IllegalAccessException e) {
System.out.println(e);
}
/* Components */
/* myFrame.getContentPane().add(myLabel);
myFrame.getContentPane().add(myButton);
myFrame.getContentPane().add(myToggleButton);
myFrame.getContentPane().add(myCheckBox);
myFrame.getContentPane().add(myRadioButton0);
myFrame.getContentPane().add(myRadioButton1);
myFrame.getContentPane().add(myHScrollBar);
myFrame.getContentPane().add(myVScrollBar);
myFrame.getContentPane().add(myHSlider);
myFrame.getContentPane().add(myVSlider);
myFrame.getContentPane().add(myHProgressBar);
myFrame.getContentPane().add(myVProgressBar);
myFrame.getContentPane().add(myList);
myFrame.getContentPane().add(myComboBox);
myFrame.getContentPane().add(myPanel);
myFrame.getContentPane().add(mySplitPane);
myFrame.getContentPane().add(myScrollPane);
myFrame.getContentPane().add(myTabbedPane);
myFrame.getContentPane().add(myBox);
myFrame.getContentPane().add(myOverlayLayout);
myFrame.getContentPane().add(myMenuBar);
myFrame.getContentPane().add(myToolBar); */
myFrame.getContentPane().add(new javax.swing.JScrollPane(myTable));
/* myFrame.getContentPane().add(myTextField);
myFrame.getContentPane().add(myTextArea);
myFrame.setJMenuBar(myMenuBar);
swingconstants();
jcomponent();
jlabel();
imageicon();
jbutton();
abstractbutton();
buttonmodel();
defaultbuttonmodel();
jtogglebutton();
jcheckbox();
buttongroup();
jradiobutton();
boundedrangemodel();
defaultboundedrangemodel();
jscrollbar();
jslider();
jprogressbar();
jlist();
listmodel();
abstractlistmodel();
defaultlistmodel();
listselectionmodel();
defaultlistselectionmodel();
jcombobox();
comboboxmodel();
defaultcomboboxmodel();
mutablecomboboxmodel();
comboboxeditor();
jpanel();
jrootpane();
rootpanecontainer();
jlayeredpane();
windowconstants();
jwindow();
japplet();
jdesktoppane();
jsplitpane();
jscrollpane();
scrollpaneconstants();
scrollpanelayout();
scrollable();
jviewport();
viewportlayout();
jtabbedpane();
box();
boxlayout();
overlaylayout();
sizerequirements();
jpopupmenu();
jmenu();
jmenubar();
jmenuitem();
jseparator();
jcheckboxmenuitem();
jradiobuttonmenuitem();
menuelement();
keystroke();
singleselectionmodel();
defaultsingleselectionmodel();
jtoolbar();
jtoolbar_separator(); */
jtable();
/* jtextfield();
jtextarea();
jtextcomponent(); */
myFrame.addWindowListener(new WindowAdapter());
// Frame Methods
myFrame.getContentPane().setLayout(new java.awt.FlowLayout());
myFrame.pack();
myFrame.setSize(400, 400);
myFrame.setLocation(200, 200);
myFrame.show();
myFrame.toFront();
/* jdialog();
joptionpane();
progressmonitor();
progressmonitorinputstream();
jfilechooser();
jcolorchooser(); */
while (myFrameActive) {
try { Thread.sleep(250); } catch(InterruptedException e) { }
}
myFrame.dispose(); // disposes of the frame
/*
menuselectionmanager();
abstractaction();
borderfactory();
cellrendererpane();
debuggraphics();
defaultcelleditor();
defaultfocusmanager();
focusmanager();
grayfilter();
jeditorpane();
jpasswordfield();
jtextpane();
jtooltip();
jtree();
lookandfeel();
repaintmanager();
swingutilities();
timer();
tooltipmanager();
uidefaults();
uimanager();
defaultlistcellrenderer_uiresource();
jpopupmenu_separator();
jtogglebutton_togglebuttonmodel();
jtree_dynamicutiltreenode();
jtree_emptyselectionmodel();
scrollpanelayout_uiresource();
uimanager_lookandfeelinfo();
action();
celleditor();
icon();
renderer();
uidefaults_activevalue();
uidefaults_lazyvalue();
*/
}
class WindowAdapter implements java.awt.event.WindowListener {
public void windowActivated(java.awt.event.WindowEvent e) { }
public void windowClosed(java.awt.event.WindowEvent e) { }
public void windowClosing(java.awt.event.WindowEvent e) { myFrameActive = false; }
public void windowDeactivated(java.awt.event.WindowEvent e) { }
public void windowDeiconified(java.awt.event.WindowEvent e) { }
public void windowIconified(java.awt.event.WindowEvent e) { }
public void windowOpened(java.awt.event.WindowEvent e) { }
}
/*********************************************************************
* *
* JComponent: *
* *
* Fields: *
* $accessibleContext UNDEFINED_CONDITION *
* $listenerList WHEN_ANCESTOR_OF_FOCUSED_COMPONENT *
* $ui WHEN_FOCUSED *
* TOOL_TIP_TEXT_KEY WHEN_IN_FOCUSED_WINDOW *
* *
* Methods: *
* addAncestorListener isRequestFocusEnabled *
* addNotify isValidateRoot *
* addPropertyChangeListener paint *
* addVetoableChangeListener $paintBorder *
* computeVisibleRect $paintChildren *
* contains $void paintComponent *
* createToolTip paintImmediately *
* firePropertyChange $paramString *
* $fireVetoableChange $processComponentKeyEvent *
* getAccessibleContext $processFocusEvent *
* getActionForKeyStroke $processKeyEvent *
* getAlignmentX $processMouseMotionEvent *
* getAlignmentY putClientProperty *
* getAutoscrolls registerKeyboardAction *
* getBorder registerKeyboardAction *
* getBounds removeAncestorListener *
* getClientProperty removeNotify *
* $getComponentGraphics removePropertyChangeListener *
* getConditionForKeyStroke removeVetoableChangeListener *
* getDebugGraphicsOptions repaint *
* getGraphics requestDefaultFocus *
* getHeight requestFocus *
* getInsets resetKeyboardActions *
* getLocation reshape *
* getMaximumSize revalidate *
* getMinimumSize scrollRectToVisible *
* getNextFocusableComponent setAlignmentX *
* getPreferredSize setAlignmentY *
* getRegisteredKeyStrokes setAutoscrolls *
* getRootPane setBackground *
* getSize setBorder *
* getToolTipLocation setDebugGraphicsOptions *
* getToolTipText setDoubleBuffered *
* getTopLevelAncestor setEnabled *
* getUIClassID setFont *
* getVisibleRect setForeground *
* getWidth setMaximumSize *
* getX setMinimumSize *
* getY setNextFocusableComponent *
* grabFocus setOpaque *
* hasFocus setPreferredSize *
* isDoubleBuffered setRequestFocusEnabled *
* isFocusCycleRoot setToolTipText *
* isFocusTraversable $setUI *
* isLightweightComponent setVisible *
* isManagingFocus unregisterKeyboardAction *
* isOpaque update *
* isOptimizedDrawingEnabled updateUI *
* isPaintingTile *
* *
*********************************************************************/
void jcomponent() {
int i;
boolean f;
float x;
String s;
Integer k = new Integer(1);
java.awt.Rectangle r;
java.awt.Graphics g;
java.awt.Insets n;
java.awt.Component ac;
java.awt.Dimension d = new java.awt.Dimension(66,17);
java.awt.Point p = new java.awt.Point(0,0);
java.awt.Font font = new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12);
javax.swing.border.Border b = new javax.swing.border.EtchedBorder();
javax.accessibility.AccessibleContext a;
KeyStroke[] ks;
JRootPane rp;
java.awt.Container an;
JComponent c = myLabel;
f = JComponent.isLightweightComponent(c); // test if component is lightweight
c.setEnabled(true); // Sets whether or not this component is enabled
c.setVisible(true); // Makes the component visible or invisible
c.setAutoscrolls(false); // If true this component will automatically scroll its contents when dragged, if contained in a component that supports scrolling, such as JViewport
c.setDoubleBuffered(false); // Set whether the receiving component should use a buffer to paint
c.setOpaque(false); // If true the components background will be filled with the background color
c.setRequestFocusEnabled(false); // Set whether the receiving component can obtain the focus by calling requestFocus
c.setDebugGraphicsOptions(
DebugGraphics.NONE_OPTION); // Enables or disables diagnostic information about every graphics operation performed within the component or one of its children
c.setAlignmentX(0.0f); // Set the the vertical alignment
c.setAlignmentY(0.5f); // Set the the horizontal alignment
c.setMaximumSize(d); // Sets the maximumSize of this component to a constant value
c.setMinimumSize(d); // Sets the minimumSize of this component to a constant value
// c.setPreferredSize(d); // Set the preferred size of the receiving component
c.setToolTipText("Test ToolTip"); // Registers the text to display in a tool tip
c.setBorder(b); // Sets the border of this component
c.setBackground(java.awt.Color.gray); // Sets the background color of this component
c.setForeground(java.awt.Color.black); // Sets the foreground color of this component
c.setFont(font); // Sets the font for this component
c.putClientProperty("myProp", k); // Add an arbitrary key/value "client property" to this component
c.grabFocus(); // Set the focus on the receiving component
c.requestFocus(); // Set focus on the receiving component if isRequestFocusEnabled returns true
c.paint(c.getGraphics()); // This method is invoked by Swing to draw components
c.update(c.getGraphics()); // Calls paint(g)
c.revalidate(); // Support for deferred automatic layout
s = c.getUIClassID(); // Return the UIDefaults key used to look up the name of the swing.plaf.ComponentUI class that defines the look and feel for this component
s = c.getToolTipText(); // Return the tooltip string that has been set with setToolTipText()
f = c.contains(10, 10); // Give the UI delegate an opportunity to define the precise shape of this component for the sake of mouse processing
f = c.getAutoscrolls(); // Returns true if this component automatically scrolls its contents when dragged, (when contained in a component that supports scrolling, like JViewport
f = c.hasFocus(); // Returns true if this Component has the keyboard focus
f = c.isDoubleBuffered(); // Return whether the receiving component should use a buffer to paint
f = c.isFocusCycleRoot(); // Override this method and return true if your component is the root of of a component tree with its own focus cycle
f = c.isFocusTraversable(); // Identifies whether or not this component can receive the focus
f = c.isManagingFocus(); // Override this method and return true if your JComponent manages focus
f = c.isOpaque(); // Returns true if this component is completely opaque
f = c.isOptimizedDrawingEnabled(); // T Returns true if this component tiles its children, i.e
f = c.isPaintingTile(); // Returns true if the receiving component is currently painting a tile
f = c.isRequestFocusEnabled(); // T Return whether the receiving component can obtain the focus by calling requestFocus
f = c.isValidateRoot(); // If this method returns true, revalidate() calls by descendants of this component will cause the entire tree beginning with this root to be validated
f = c.requestDefaultFocus(); // Request the focus for the component that should have the focus by default
i = c.getDebugGraphicsOptions(); // Returns the state of graphics debugging
i = c.getHeight(); // 0 Return the current height of this component
i = c.getWidth(); // 0 Return the current width of this component
i = c.getX(); // 0 Return the current x coordinate of the components origin
i = c.getY(); // 0 Return the current y coordinate of the components origin
x = c.getAlignmentX(); // Overrides Container.getAlignmentX to return the vertical alignment
x = c.getAlignmentY(); // Overrides Container.getAlignmentY to return the horizontal alignment
d = c.getMaximumSize(); // [66,17] If the maximumSize has been set to a non-null value just return it
d = c.getMinimumSize(); // [66,17] If the minimumSize has been set to a non-null value just return it
d = c.getPreferredSize(); // [66,17] If the preferredSize has been set to a non-null value just return it
d = c.getSize(d); // [0,0] Store the width/height of this component into "return value" rv and return rv
r = c.getVisibleRect(); // Returns the Component's "visible rectangle" - the intersection of this components visible rectangle: new Rectangle(0, 0, getWidth(), getHeight()); and all of its ancestors visible Rectangles
r = c.getBounds(r); // Store the bounds of this component into "return value" rv and return rv
p = c.getLocation(p); // Store the x,y origin of this component into "return value" rv and return rv
n = c.getInsets(); // If a border has been set on this component, returns the border's insets, else calls super.getInsets
n = c.getInsets(n); // Returns an Insets object containing this component's inset values
g = c.getGraphics(); // Returns this component's graphics context, which lets you draw on a component
b = c.getBorder(); // Returns the border of this component or null if no border is currently set
ac = c.getNextFocusableComponent(); // Return the next focusable component or null if the focus manager should choose the next focusable component automatically
ks = c.getRegisteredKeyStrokes(); // Return the KeyStrokes that will initiate registered actions
rp = c.getRootPane(); // Returns the JRootPane ancestor for a component
an = c.getTopLevelAncestor(); // Returns the top-level ancestor of this component (either the containing Window or Applet), or null if this component has not been added to any container
a = c.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
k = (Integer)c.getClientProperty("myProp"); // Returns the value of the property with the specified key
JComponentAdapter adapt = new JComponentAdapter();
c.addPropertyChangeListener(adapt); // Add a PropertyChangeListener to the listener list
c.firePropertyChange("myProp", 1, 2); // Reports a bound property change
c.addVetoableChangeListener(adapt); // Add a VetoableChangeListener to the listener list
c.addAncestorListener(adapt); // Registers listener so that it will receive AncestorEvents when it or any of its ancestors move or are made visible / invisible
c.removePropertyChangeListener(adapt); // Remove a PropertyChangeListener from the listener list
c.removeVetoableChangeListener(adapt); // Remove a VetoableChangeListener from the listener list
c.removeAncestorListener(adapt); // Unregisters listener so that it will no longer receive AncestorEvents This method will migrate to java.awt.Component in the next major JDK release
/*
static String TOOL_TIP_TEXT_KEY // The comment to display when the cursor is over the component, also known as a "value tip", "flyover help", or "flyover label"
static int UNDEFINED_CONDITION // Constant used by some of the apis to mean that no condition is defined
static int WHEN_ANCESTOR_OF_FOCUSED_COMPONENT // Constant used for registerKeyboardAction() which means that the comand should be invoked when the receiving component is an ancestor of the focused component or is itself the focused component
static int WHEN_FOCUSED // Constant used for registerKeyboardAction() which means that the command should be invoked when the component has the focus
static int WHEN_IN_FOCUSED_WINDOW // Constant used for registerKeyboardAction() which means that the command should be invoked when the receiving component is in the window that has the focus or is itself the focused component
int getConditionForKeyStroke(KeyStroke aKeyStroke); // Return the condition that determines whether a registered action occurs in response to the specified keystroke
Point getToolTipLocation(MouseEvent event); // Return the tooltip location in the receiving component coordinate system If null is returned, Swing will choose a location
String getToolTipText(MouseEvent event); // Returns the string to be used as the tooltip for event
JToolTip createToolTip(); // Returns the instance of JToolTip that should be used to display the tooltip
ActionListener getActionForKeyStroke(KeyStroke aKeyStroke); // Return the object that will perform the action registered for a given keystroke
void addNotify(); // Notification to this component that it now has a parent component
void removeNotify(); // Notification to this component that it no longer has a parent component
void computeVisibleRect(Rectangle visibleRect); // Returns the Component's "visible rect rectangle" - the intersection of the visible rectangles for this component and all of its ancestors
void scrollRectToVisible(Rectangle aRect); // Forwards the scrollRectToVisible() message to the JComponent's parent
void reshape(int x, int y, int w, int h); // Moves and resizes this component
void paintImmediately(int x, int y, int w, int h); // Paint the specified region in this component and all of its descendants that overlap the region, immediately
void paintImmediately(Rectangle r); // Paint the specified region now
void repaint(long tm, int x, int y, int width, int height); // Adds the specified region to the dirty region list if the component is showing
void repaint(Rectangle r); // Adds the specified region to the dirty region list if the component is showing
void registerKeyboardAction(ActionListener anAction, KeyStroke aKeyStroke, int aCondition); // Calls registerKeyboardAction(ActionListener,String,KeyStroke,condition) with a null command
void registerKeyboardAction(ActionListener anAction, String aCommand, KeyStroke aKeyStroke, int aCondition); // Register a new keyboard action
void unregisterKeyboardAction(KeyStroke aKeyStroke); // Unregister a keyboard action
void resetKeyboardActions(); // Unregister all keyboard actions
void setNextFocusableComponent(Component aComponent); // Specifies the next component to get the focus after this one, for example, when the tab key is pressed
void updateUI(); // Resets the UI property to a value from the current look and feel
*/
}
class JComponentAdapter implements java.beans.PropertyChangeListener, java.beans.VetoableChangeListener,
javax.swing.event.AncestorListener {
public void propertyChange(java.beans.PropertyChangeEvent e) {
if (e.getPropertyName().equals("myProp")) {
myLabel.putClientProperty("myProp", e.getNewValue());
}
}
public void vetoableChange(java.beans.PropertyChangeEvent e) throws java.beans.PropertyVetoException {
if (e.getPropertyName().equals("myProp")) {
myLabel.putClientProperty("myProp", e.getNewValue());
}
}
public void ancestorAdded(javax.swing.event.AncestorEvent e) { }
public void ancestorMoved(javax.swing.event.AncestorEvent e) { }
public void ancestorRemoved(javax.swing.event.AncestorEvent e) { }
}
/*********************************************************************
* *
* JLabel: Component for placing text in a container *
* *
* Methods: *
* $checkHorizontalKey getVerticalTextPosition *
* $checkVerticalKey $paramString *
* getAccessibleContext setDisabledIcon *
* getDisabledIcon setDisplayedMnemonic *
* getDisplayedMnemonic setHorizontalAlignment *
* getHorizontalAlignment setHorizontalTextPosition *
* getHorizontalTextPosition setIcon *
* getIcon setIconTextGap *
* getIconTextGap setLabelFor *
* getLabelFor setText *
* getText setUI *
* getUI setVerticalAlignment *
* getUIClassID setVerticalTextPosition *
* getVerticalAlignment updateUI *
* *
*********************************************************************/
private JLabel myLabel = new JLabel("Test JLabel");
void jlabel() {
int i;
String s;
Icon p;
javax.accessibility.AccessibleContext a;
java.awt.Component c;
javax.swing.plaf.LabelUI ui = new javax.swing.plaf.metal.MetalLabelUI();
myLabel.setText("Test JLabel"); // sets text for this label
myLabel.setIcon(myImageIcon); // defines the icon this component will display
myLabel.setDisabledIcon(myImageIcon); // icon to be displayed if this JLabel is "disabled"
myLabel.setHorizontalAlignment(
SwingConstants.LEFT); // sets the alignment of the label's contents along the X axis
myLabel.setHorizontalTextPosition(
SwingConstants.RIGHT); // sets the horizontal position of the label's text, relative to its image
myLabel.setIconTextGap(4); // if both the icon and text properties are set, this property defines the space between them
myLabel.setVerticalAlignment(
SwingConstants.CENTER); // sets the alignment of the label's contents along the Y axis
myLabel.setVerticalTextPosition(
SwingConstants.CENTER); // sets the vertical position of the label's text, relative to its image
myLabel.setUI(ui); // sets the L&F object that renders this component
myLabel.updateUI(); // notification from the UIFactory that the L&F has changed
myLabel.setDisplayedMnemonic('T'); // specifies the displayedMnemonic as a char value
myLabel.setLabelFor(myButton); // set the component this is labelling
s = myLabel.getText(); // gets text of this label
s = myLabel.getUIClassID(); // name of the l&f class
i = myLabel.getDisplayedMnemonic(); // keycode that indicates a mnemonic key
i = myLabel.getHorizontalAlignment(); // alignment of the label's contents along the X axis
i = myLabel.getHorizontalTextPosition(); // horizontal position of the label's text
i = myLabel.getIconTextGap(); // amount of space between the text and the icon
i = myLabel.getVerticalAlignment(); // alignment of the label's contents along the Y axis
i = myLabel.getVerticalTextPosition(); // vertical position of the label's text
p = myLabel.getIcon(); // returns the graphic image (glyph, icon) that the label displays
p = myLabel.getDisabledIcon(); // returns the value of the disabledIcon property if it's been set, If it hasn't been set and the value of the icon property is an ImageIcon, we compute a "grayed out" version of the icon and update the disabledIcon property with that
a = myLabel.getAccessibleContext(); // get the AccessibleContext of this object
c = myLabel.getLabelFor(); // get the component this is labelling
ui = myLabel.getUI(); // returns the L&F object that renders this component
}
/*********************************************************************
* *
* SwingConstants: *
* *
* Fields: *
* BOTTOM NORTH SOUTH_WEST *
* CENTER NORTH_EAST TOP *
* EAST NORTH_WEST TRAILING *
* HORIZONTAL RIGHT VERTICAL *
* LEADING SOUTH WEST *
* LEFT SOUTH_EAST *
* *
*********************************************************************/
void swingconstants() {
// Box Orientation
switch (myLabel.getHorizontalAlignment()) {
case SwingConstants.CENTER: break; // central position in an area
case SwingConstants.TOP: break; // top of a box
case SwingConstants.BOTTOM: break; // bottom of a box
case SwingConstants.LEFT: break; // left side of a box
case SwingConstants.RIGHT: break; // right side of a box
case SwingConstants.LEADING: break; // leading edge of text
case SwingConstants.TRAILING: break; // trailing edge of text
}
// compass orientation
switch (myLabel.getHorizontalAlignment()) {
case SwingConstants.CENTER: // The central position in an area
System.out.println("SwingConstants.CENTER: " + SwingConstants.CENTER);
break;
case SwingConstants.NORTH: // Compass-direction North (up)
System.out.println("SwingConstants.NORTH: " + SwingConstants.NORTH);
break;
case SwingConstants.NORTH_EAST: // Compass-direction north-east (upper right)
System.out.println("SwingConstants.NORTH_EAST: " + SwingConstants.NORTH_EAST);
break;
case SwingConstants.EAST: // Compass-direction east (right)
System.out.println("SwingConstants.EAST: " + SwingConstants.EAST);
break;
case SwingConstants.SOUTH_EAST: // Compass-direction south-east (lower right)
System.out.println("SwingConstants.SOUTH_EAST: " + SwingConstants.SOUTH_EAST);
break;
case SwingConstants.SOUTH: // Compass-direction south (down)
System.out.println("SwingConstants.SOUTH: " + SwingConstants.SOUTH);
break;
case SwingConstants.SOUTH_WEST: // Compass-direction south-west (lower left)
System.out.println("SwingConstants.SOUTH_WEST: " + SwingConstants.SOUTH_WEST);
break;
case SwingConstants.WEST: // Compass-direction west (left)
System.out.println("SwingConstants.WEST: " + SwingConstants.WEST);
break;
case SwingConstants.NORTH_WEST: // Compass-direction north west (upper left)
System.out.println("SwingConstants.NORTH_WEST: " + SwingConstants.NORTH_WEST);
break;
}
switch (myLabel.getHorizontalAlignment()) {
case SwingConstants.HORIZONTAL: // Horizontal orientation
System.out.println("SwingConstants.HORIZONTAL: " + SwingConstants.HORIZONTAL);
break;
case SwingConstants.VERTICAL: // Vertical orientation
System.out.println("SwingConstants.VERTICAL: " + SwingConstants.VERTICAL);
break;
}
}
/*********************************************************************
* *
* Icon Interface: *
* *
* Methods: *
* getIconHeight getIconWidth paintIcon *
* *
*********************************************************************/
Icon myIcon = new CMRIcon(20, 50);
class CMRIcon implements Icon {
private int width;
private int height;
public CMRIcon(int w, int h) {
width = w;
height = h;
}
public int getIconHeight() { return height; }; // icon's height
public int getIconWidth() { return width; }; // icon's width
public void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y) {
g.setColor(java.awt.Color.black);
g.drawOval(x, y, width-1, height-1); // draw the icon at the specified location
}
}
/*********************************************************************
* *
* ImageIcon: *
* *
* Fields: *
* $component $tracker *
* *
* Methods: *
* getDescription getImageLoadStatus setDescription *
* getIconHeight getImageObserver setImage *
* getIconWidth $loadImage setImageObserver *
* getImage paintIcon *
* *
*********************************************************************/
ImageIcon myImageIcon = new ImageIcon(TESTGIF);
void imageicon() {
int i;
String s;
java.awt.Image img;
java.awt.image.ImageObserver obs;
s = myImageIcon.getDescription(); // Get the description of the image
i = myImageIcon.getIconHeight(); // Get the height of the Icon
i = myImageIcon.getIconWidth(); // Get the width of the Icon
i = myImageIcon.getImageLoadStatus(); // Returns the status of the image loading operation
switch (i) {
case java.awt.MediaTracker.COMPLETE: break;
case java.awt.MediaTracker.ABORTED: break;
case java.awt.MediaTracker.ERRORED: break;
}
img = myImageIcon.getImage(); // Returns the Icon's Image
obs = myImageIcon.getImageObserver(); // Return the umage observer for the image
myImageIcon.setDescription(s); // Set the description of the image
myImageIcon.setImage(img); // Set the image displayed by this icon
myImageIcon.setImageObserver(obs); // Set the image observer for the image
/*
void paintIcon(Component c, Graphics g, int x, int y); // Paints the Icon
*/
}
/*********************************************************************
* *
* JButton: Creates a labeled button *
* *
* Methods: *
* getAccessibleContext $paramString *
* getUIClassID setDefaultCapable *
* isDefaultButton updateUI *
* isDefaultCapable *
* *
*********************************************************************/
private JButton myButton = new JButton("Test JButton");
void jbutton() {
boolean f;
String s;
JRootPane rp;
javax.accessibility.AccessibleContext a;
myButton.updateUI(); // Notification from the UIFactory that the L&F has changed
myButton.setDefaultCapable(true); // Sets whether or not this button is capable of being the default button on the RootPane
f = myButton.isDefaultButton(); // Returns whether or not this button is the default button on the RootPane
f = myButton.isDefaultCapable(); // Returns whether or not this button is capable of being the default button on the RootPane
s = myButton.getUIClassID(); // Returns the class ID for the UI
a = myButton.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
rp = myButton.getRootPane(); // JComponent method
rp.setDefaultButton(myButton); // JRootPane method
}
/*********************************************************************
* *
* AbstractButton: *
* *
* Fields: *
* $actionListener *
* $changeEvent *
* $changeListener *
* $itemListener *
* $model *
* BORDER_PAINTED_CHANGED_PROPERTY *
* CONTENT_AREA_FILLED_CHANGED_PROPERTY *
* DISABLED_ICON_CHANGED_PROPERTY *
* DISABLED_SELECTED_ICON_CHANGED_PROPERTY *
* FOCUS_PAINTED_CHANGED_PROPERTY *
* HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY *
* HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY *
* ICON_CHANGED_PROPERTY *
* MARGIN_CHANGED_PROPERTY *
* MNEMONIC_CHANGED_PROPERTY *
* MODEL_CHANGED_PROPERTY *
* PRESSED_ICON_CHANGED_PROPERTY *
* ROLLOVER_ENABLED_CHANGED_PROPERTY *
* ROLLOVER_ICON_CHANGED_PROPERTY *
* ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY *
* SELECTED_ICON_CHANGED_PROPERTY *
* TEXT_CHANGED_PROPERTY *
* VERTICAL_ALIGNMENT_CHANGED_PROPERTY *
* VERTICAL_TEXT_POSITION_CHANGED_PROPERTY *
* *
* Methods: *
* addActionListener isFocusPainted *
* addChangeListener isRolloverEnabled *
* addItemListener isSelected *
* $checkHorizontalKey $paintBorder *
* $checkVerticalKey $paramString *
* $createActionListener removeActionListener *
* $createChangeListener removeChangeListener *
* $createItemListener removeItemListener *
* doClick setActionCommand *
* $fireActionPerformed setBorderPainted *
* $fireItemStateChanged setContentAreaFilled *
* $fireStateChanged setDisabledIcon *
* getActionCommand setDisabledSelectedIcon *
* getDisabledIcon setEnabled *
* getDisabledSelectedIcon setFocusPainted *
* getHorizontalAlignment setHorizontalAlignment *
* getHorizontalTextPosition setHorizontalTextPosition *
* getIcon setIcon *
* %getLabel %setLabel *
* getMargin setMargin *
* getMnemonic setMnemonic *
* getModel setModel *
* getPressedIcon setPressedIcon *
* getRolloverIcon setRolloverEnabled *
* getRolloverSelectedIcon setRolloverIcon *
* getSelectedIcon setRolloverSelectedIcon *
* getSelectedObjects setSelected *
* getText setSelectedIcon *
* getUI setText *
* getVerticalAlignment setUI *
* getVerticalTextPosition setVerticalAlignment *
* $init setVerticalTextPosition *
* isBorderPainted updateUI *
* isContentAreaFilled *
* *
*********************************************************************/
void abstractbutton() {
int i;
boolean f;
String s;
Object[] ox;
Icon p = myImageIcon;
java.awt.Insets n = new java.awt.Insets(2, 14, 2, 14);
ButtonModel m = myButton.getModel();
javax.swing.plaf.ButtonUI ui = new javax.swing.plaf.metal.MetalButtonUI();
myButton.setText("Test JButton"); // Sets the button's text
myButton.setActionCommand("myButtonCmd"); // Sets the action command for this button
myButton.setEnabled(true); // Enables (or disables) the button
myButton.setBorderPainted(true); // Sets whether the border should be painted
myButton.setContentAreaFilled(true); // Sets whether the button should paint the content area or leave it transparent
myButton.setFocusPainted(true); // Sets whether focus should be painted
myButton.setRolloverEnabled(false); // Sets whether rollover effects should be enabled
myButton.setSelected(false); // Sets the state of the button
myButton.setHorizontalAlignment(
SwingConstants.CENTER); // Sets the horizontal alignment of the icon and text
myButton.setHorizontalTextPosition(
SwingConstants.RIGHT); // Sets the horizontal position of the text relative to the icon
myButton.setVerticalAlignment(
SwingConstants.CENTER); // Sets the vertical alignment of the icon and text
myButton.setVerticalTextPosition(
SwingConstants.CENTER); // Sets the vertical position of the text relative to the icon
myButton.setMnemonic('B'); // Specifies the mnemonic value
myButton.setMargin(n); // Sets space for margin between the button's border and the label
myButton.setModel(m); // Set the model that this button represents
myButton.setDisabledIcon(p); // Sets the disabled icon for the button
myButton.setDisabledSelectedIcon(p); // Sets the disabled selection icon for the button
myButton.setIcon(p); // Sets the button's default icon
myButton.setPressedIcon(p); // Sets the pressed icon for the button
myButton.setRolloverIcon(p); // Sets the rollover icon for the button
myButton.setRolloverSelectedIcon(p); // Sets the rollover selected icon for the button
myButton.setSelectedIcon(p); // Sets the selected icon for the button
myButton.doClick(); // Programatically perform a "click"
myButton.doClick(2000); // Programatically perform a "click"
myButton.setUI(ui); // Sets the button's UI
myButton.updateUI(); // Gets a new UI object from the default UIFactory
s = myButton.getText(); // button's text
s = myButton.getActionCommand(); // action command for this button
f = myButton.isBorderPainted(); // Returns whether the border should be painted
f = myButton.isContentAreaFilled(); // Checks whether the "content area" of the button should be filled
f = myButton.isFocusPainted(); // Returns whether focus should be painted
f = myButton.isRolloverEnabled(); // Checks whether rollover effects are enabled
f = myButton.isSelected(); // Returns the state of the button
i = myButton.getHorizontalAlignment(); // Returns the horizontal alignment of the icon and text
i = myButton.getHorizontalTextPosition(); // Sets the horizontal position of the text relative to the icon
i = myButton.getVerticalAlignment(); // Returns the vertical alignment of the text and icon
i = myButton.getVerticalTextPosition(); // Returns the vertical position of the text relative to the icon Valid keys: CENTER (the default), TOP, BOTTO
i = myButton.getMnemonic(); // Get the keyboard mnemonic from the the current mode
n = myButton.getMargin(); // Returns the margin between the button's border and the label
m = myButton.getModel(); // Get the model that this button represents
p = myButton.getDisabledIcon(); // Returns the icon used by the button when it's disabled
p = myButton.getDisabledSelectedIcon(); // Returns the icon used by the button when it's disabled and selected
p = myButton.getIcon(); // Returns the default icon
p = myButton.getPressedIcon(); // Returns the pressed icon for the button
p = myButton.getRolloverIcon(); // Returns the rollover icon for the button
p = myButton.getRolloverSelectedIcon(); // Returns the rollover seletion icon for the button
p = myButton.getSelectedIcon(); // Returns the selected icon for the button
ui = myButton.getUI(); // Returns the button's current UI
ox = myButton.getSelectedObjects(); // Returns an array (length 1) containing the label or null if the button is not selected
AbstractButtonAdapter adapt = new AbstractButtonAdapter();
myButton.addActionListener(adapt); // Adds an ActionListener to the button
myButton.addChangeListener(adapt); // Adds a ChangeListener to the button
myButton.addItemListener(adapt); // Adds an ItemListener to the button
myButton.removeActionListener(adapt); // Removes an ActionListener from the button
myButton.removeChangeListener(adapt); // Removes a ChangeListener from the button
myButton.removeItemListener(adapt); // Removes an ItemListener from the button
// JComponent methods
myButton.addPropertyChangeListener(adapt);
myButton.removePropertyChangeListener(adapt);
}
class AbstractButtonAdapter implements java.awt.event.ActionListener, java.awt.event.ItemListener,
javax.swing.event.ChangeListener, java.beans.PropertyChangeListener {
public void actionPerformed(java.awt.event.ActionEvent e) { }
public void itemStateChanged(java.awt.event.ItemEvent e) { }
public void stateChanged(javax.swing.event.ChangeEvent e) { }
public void propertyChange(java.beans.PropertyChangeEvent e) {
if (e.getPropertyName().equals(AbstractButton.BORDER_PAINTED_CHANGED_PROPERTY)) { }
if (e.getPropertyName().equals(AbstractButton.CONTENT_AREA_FILLED_CHANGED_PROPERTY)) { }
if (e.getPropertyName().equals(AbstractButton.DISABLED_ICON_CHANGED_PROPERTY)) { }
if (e.getPropertyName().equals(AbstractButton.DISABLED_SELECTED_ICON_CHANGED_PROPERTY)) { }
if (e.getPropertyName().equals(AbstractButton.FOCUS_PAINTED_CHANGED_PROPERTY)) { }
if (e.getPropertyName().equals(AbstractButton.HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY)) { }
if (e.getPropertyName().equals(AbstractButton.HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY)) { }
if (e.getPropertyName().equals(AbstractButton.ICON_CHANGED_PROPERTY)) { }
if (e.getPropertyName().equals(AbstractButton.MARGIN_CHANGED_PROPERTY)) { }
if (e.getPropertyName().equals(AbstractButton.MNEMONIC_CHANGED_PROPERTY)) { }
if (e.getPropertyName().equals(AbstractButton.MODEL_CHANGED_PROPERTY)) { }
if (e.getPropertyName().equals(AbstractButton.PRESSED_ICON_CHANGED_PROPERTY)) { }
if (e.getPropertyName().equals(AbstractButton.ROLLOVER_ENABLED_CHANGED_PROPERTY)) { }
if (e.getPropertyName().equals(AbstractButton.ROLLOVER_ICON_CHANGED_PROPERTY)) { }
if (e.getPropertyName().equals(AbstractButton.ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY)) { }
if (e.getPropertyName().equals(AbstractButton.SELECTED_ICON_CHANGED_PROPERTY)) { }
if (e.getPropertyName().equals(AbstractButton.TEXT_CHANGED_PROPERTY)) { }
if (e.getPropertyName().equals(AbstractButton.VERTICAL_ALIGNMENT_CHANGED_PROPERTY)) { }
if (e.getPropertyName().equals(AbstractButton.VERTICAL_TEXT_POSITION_CHANGED_PROPERTY)) { }
}
}
/*********************************************************************
* *
* ButtonModel Interface: *
* *
* Methods: *
* addActionListener removeChangeListener *
* addChangeListener removeItemListener *
* addItemListener setActionCommand *
* getActionCommand setArmed *
* getMnemonic setEnabled *
* isArmed setGroup *
* isEnabled setMnemonic *
* isPressed setPressed *
* isRollover setRollover *
* isSelected setSelected *
* removeActionListener *
* *
*********************************************************************/
void buttonmodel() {
int i;
boolean f;
String s;
ButtonModel m = myButton.getModel();
m.setActionCommand("myButtonCmd"); // Sets the actionCommand string that gets sent as part of the event when the button is pressed
m.setArmed(false); // Marks the button as "armed"
m.setEnabled(true); // Enables or disables the button
m.setPressed(false); // Sets the button to pressed or unpressed
m.setRollover(false); // Sets or clears the button's rollover state
m.setSelected(false); // Selects or deselects the button
m.setMnemonic(0x42); // Sets the keyboard mnemonic (shortcut key or accelerator key) for this button
m.setGroup(null); // Identifies the group this button belongs to -- needed for radio buttons, which are mutually exclusive within their group
f = m.isArmed(); // Indicates partial commitment towards pressing the button
f = m.isEnabled(); // Indicates if the button can be selected or pressed by an input device (such as a mouse pointer)
f = m.isPressed(); // Indicates if button has been pressed
f = m.isRollover(); // Indicates that the mouse is over the button
f = m.isSelected(); // Indicates if the button has been selected
i = m.getMnemonic(); // Gets the keyboard mnemonic for this model
s = m.getActionCommand(); // Returns the action command for this button
ButtonModelAdapter adapt = new ButtonModelAdapter();
m.addActionListener(adapt); // Adds an ActionListener to the button
m.addChangeListener(adapt); // Adds a ChangeListener to the button
m.addItemListener(adapt); // Adds an ItemListener to the button
m.removeActionListener(adapt); // Removes an ActionListener from the button
m.removeChangeListener(adapt); // Removes a ChangeListener from the button
m.removeItemListener(adapt); // Removes an ItemListener from the button
}
class ButtonModelAdapter implements java.awt.event.ActionListener, java.awt.event.ItemListener,
javax.swing.event.ChangeListener {
public void actionPerformed(java.awt.event.ActionEvent e) { }
public void itemStateChanged(java.awt.event.ItemEvent e) { }
public void stateChanged(javax.swing.event.ChangeEvent e) { }
}
/*********************************************************************
* *
* DefaultButtonModel: *
* *
* Fields: *
* $actionCommand ARMED *
* $changeEvent ENABLED *
* $group PRESSED *
* $listenerList ROLLOVER *
* $mnemonic SELECTED *
* $stateMask *
* *
* Methods: *
* addActionListener isSelected *
* addChangeListener removeActionListener *
* addItemListener removeChangeListener *
* $fireActionPerformed removeItemListener *
* $fireItemStateChanged setActionCommand *
* $fireStateChanged setArmed *
* getActionCommand setEnabled *
* getMnemonic setGroup *
* getSelectedObjects setMnemonic *
* isArmed setPressed *
* isEnabled setRollover *
* isPressed setSelected *
* isRollover *
* *
*********************************************************************/
void defaultbuttonmodel() {
int i;
boolean f;
String s;
DefaultButtonModel m = (DefaultButtonModel)myButton.getModel();
m.setActionCommand("myButtonCmd"); // Sets the actionCommand string that gets sent as part of the event when the button is pressed
m.setArmed(false); // Marks the button as "armed"
m.setEnabled(true); // Enables or disables the button
m.setPressed(false); // Sets the button to pressed or unpressed
m.setRollover(false); // Sets or clears the button's rollover state
m.setSelected(false); // Selects or deselects the button
m.setMnemonic(0x42); // Sets the keyboard mnemonic (shortcut key or accelerator key) for this button
m.setGroup(null); // Identifies the group this button belongs to -- needed for radio buttons, which are mutually exclusive within their group
f = m.isArmed(); // Indicates partial commitment towards pressing the button
f = m.isEnabled(); // Indicates if the button can be selected or pressed by an input device (such as a mouse pointer)
f = m.isPressed(); // Indicates if button has been pressed
f = m.isRollover(); // Indicates that the mouse is over the button
f = m.isSelected(); // Indicates if the button has been selected
i = m.getMnemonic(); // Gets the keyboard mnemonic for this model
s = m.getActionCommand(); // Returns the action command for this button
DefaultButtonModelAdapter adapt = new DefaultButtonModelAdapter();
m.addActionListener(adapt); // Adds an ActionListener to the button
m.addChangeListener(adapt); // Adds a ChangeListener to the button
m.addItemListener(adapt); // Adds an ItemListener to the button
m.removeActionListener(adapt); // Removes an ActionListener from the button
m.removeChangeListener(adapt); // Removes a ChangeListener from the button
m.removeItemListener(adapt); // Removes an ItemListener from the button
}
class DefaultButtonModelAdapter implements java.awt.event.ActionListener, java.awt.event.ItemListener,
javax.swing.event.ChangeListener {
public void actionPerformed(java.awt.event.ActionEvent e) { }
public void itemStateChanged(java.awt.event.ItemEvent e) { }
public void stateChanged(javax.swing.event.ChangeEvent e) { }
}
/*********************************************************************
* *
* JToggleButton: *
* *
* Methods: *
* getAccessibleContext $paramString *
* getUIClassID updateUI *
* *
*********************************************************************/
private JToggleButton myToggleButton = new JToggleButton("Test JToggleButton");
void jtogglebutton() {
String s;
javax.accessibility.AccessibleContext a;
myToggleButton.updateUI(); // Notification from the UIFactory that the L&F has changed
s = myToggleButton.getUIClassID(); // Returns the class ID for the UI
a = myToggleButton.getAccessibleContext(); // Get the AccessibleContext associated with this JComponen
}
/*********************************************************************
* *
* JToggleButton.ToggleButtonModel: *
* *
* Methods: *
* isSelected setPressed setSelected *
* *
*********************************************************************/
void jtogglebutton_togglebuttonmodel() {
boolean f;
JToggleButton.ToggleButtonModel m = (JToggleButton.ToggleButtonModel)myToggleButton.getModel();
m.setPressed(false); // Sets the pressed state of the toggle button
m.setSelected(false); // Sets the selected state of the button
f = m.isSelected(); // Checks if the button is selected
}
/*********************************************************************
* *
* JCheckBox: *
* *
* Methods: *
* getAccessibleContext $paramString *
* getUIClassID updateUI *
* *
*********************************************************************/
private JCheckBox myCheckBox = new JCheckBox("Test JCheckBox");
void jcheckbox() {
String s;
javax.accessibility.AccessibleContext a;
myCheckBox.updateUI(); // Notification from the UIFactory that the L&F has changed
s = myCheckBox.getUIClassID(); // Returns the class ID for the UI
a = myCheckBox.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
}
/*********************************************************************
* *
* ButtonGroup: *
* *
* Methods: *
* add getSelection remove *
* getElements isSelected setSelected *
* *
*********************************************************************/
private ButtonGroup myButtonGroup = new ButtonGroup();
void buttongroup() {
boolean f;
java.util.Enumeration bx;
ButtonModel m = myRadioButton1.getModel();
myButtonGroup.add(myRadioButton0); // adds the button to the group
myButtonGroup.add(myRadioButton1);
//myButtonGroup.remove(myRadioButton1); // Removes the button from the group
myButtonGroup.setSelected(m, true); // Sets the selected value for the button
m = myButtonGroup.getSelection(); // Return the selected button model
f = myButtonGroup.isSelected(m); // Returns the selected value for the button
bx = myButtonGroup.getElements(); // Return all the buttons that are participating in this group
}
/*********************************************************************
* *
* JRadioButton: *
* *
* Methods: *
* getAccessibleContext $paramString *
* getUIClassID updateUI *
* *
*********************************************************************/
private JRadioButton myRadioButton0 = new JRadioButton("Test RadioButton #0", true);
private JRadioButton myRadioButton1 = new JRadioButton("Test RadioButton #1", false);
void jradiobutton() {
String s;
javax.accessibility.AccessibleContext a;
myRadioButton0.updateUI(); // Notification from the UIFactory that the L&F has changed
s = myRadioButton0.getUIClassID(); // Returns the class ID for the UI
a = myRadioButton0.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
}
/*********************************************************************
* *
* BoundedRangeModel Interface: *
* *
* Methods: *
* addChangeListener getValueIsAdjusting setRangeProperties *
* getExtent removeChangeListener setValue *
* getMaximum setExtent setValueIsAdjusting *
* getMinimum setMaximum *
* getValue setMinimum *
* *
*********************************************************************/
void boundedrangemodel() {
int i;
boolean f;
BoundedRangeModel m = myHScrollBar.getModel();
m.setRangeProperties(50, 10, 0, 100, false); // This method sets all of the model's data with a single method call
m.setExtent(10); // Sets the model's extent
m.setMaximum(100); // Sets the model's maximum to newMaximum
m.setMinimum(0); // Sets the model's minimum to newMinimum
m.setValue(50); // Sets the model's current value to newValue if newValue satisfies the model's constraints
m.setValueIsAdjusting(false); // This attribute indicates that any upcoming changes to the value of the model should be considered a single event
i = m.getExtent(); // Returns the model's extent, the length of the inner range that begins at the model's value
i = m.getMaximum(); // Returns the model's maximum
i = m.getMinimum(); // Returns the minimum acceptable value
i = m.getValue(); // Returns the model's current value
f = m.getValueIsAdjusting(); // Returns true if the current changes to the value property are part of a series of changes
BoundedRangeModelAdapter adapt = new BoundedRangeModelAdapter();
m.addChangeListener(adapt); // Adds a ChangeListener to the model's listener list
m.removeChangeListener(adapt); // Removes a ChangeListener from the model's listener list
}
class BoundedRangeModelAdapter implements javax.swing.event.ChangeListener {
public void stateChanged(javax.swing.event.ChangeEvent e) { }
}
/*********************************************************************
* *
* DefaultBoundedRangeModel: *
* *
* Fields: *
* $changeEvent $listenerList *
* *
* Methods: *
* addChangeListener getValue setMinimum *
* $fireStateChanged getValueIsAdjusting setRangeProperties *
* getExtent removeChangeListener setValue *
* getMaximum setExtent setValueIsAdjusting *
* getMinimum setMaximum toString *
* *
*********************************************************************/
void defaultboundedrangemodel() {
int i;
boolean f;
String s;
DefaultBoundedRangeModel m = (DefaultBoundedRangeModel)myHScrollBar.getModel();
m.setRangeProperties(50, 10, 0, 100, false); // Sets all of the BoundedRangeModel properties after forcing the arguments to obey the usual constraints: minimum <= value <= value+extent <= maximum At most, one ChangeEvent is generated
m.setExtent(10); // Sets the extent to n after ensuring that n is greater than or equal to zero and falls within the model's constraints: minimum <= value <= value+extent <= maximum
m.setMaximum(100); // Sets the maximum to n after ensuring that n that the other three properties obey the model's constraints: minimum <= value <= value+extent <= maximum
m.setMinimum(0); // Sets the minimum to n after ensuring that n that the other three properties obey the model's constraints: minimum <= value <= value+extent <= maximum
m.setValue(50); // Sets the current value of the model
m.setValueIsAdjusting(false); // Sets the valueIsAdjusting property
i = m.getExtent(); // Return the model's extent
i = m.getMaximum(); // Return the model's maximum
i = m.getMinimum(); // Return the model's minimum
i = m.getValue(); // Return the model's current value
f = m.getValueIsAdjusting(); // Returns true if the value is in the process of changing as a result of actions being taken by the user
s = m.toString(); // Returns a string that displays all of the BoundedRangeModel properties
DefaultBoundedRangeModelAdapter adapt = new DefaultBoundedRangeModelAdapter();
m.addChangeListener(adapt); // Adds a ChangeListener
m.removeChangeListener(adapt); // Removes a ChangeListener
}
class DefaultBoundedRangeModelAdapter implements javax.swing.event.ChangeListener {
public void stateChanged(javax.swing.event.ChangeEvent e) { }
}
/*********************************************************************
* *
* JScrollBar: *
* *
* Fields: *
* $blockIncrement $orientation *
* $model $unitIncrement *
* *
* Methods: *
* addAdjustmentListener getVisibleAmount *
* $fireAdjustmentValueChanged $paramString *
* getAccessibleContext removeAdjustmentListener *
* getBlockIncrement setBlockIncrement *
* getMaximum setEnabled *
* getMaximumSize setMaximum *
* getMinimum setMinimum *
* getMinimumSize setModel *
* getModel setOrientation *
* getOrientation setUnitIncrement *
* getUI setValue *
* getUIClassID setValueIsAdjusting *
* getUnitIncrement setValues *
* getValue setVisibleAmount *
* getValueIsAdjusting updateUI *
* *
*********************************************************************/
private JScrollBar myHScrollBar = new JScrollBar(JScrollBar.HORIZONTAL, 50, 10, 0, 100);
private JScrollBar myVScrollBar = new JScrollBar(JScrollBar.VERTICAL, 50, 10, 0, 100);
void jscrollbar() {
int i;
boolean f;
String s;
BoundedRangeModel m = myHScrollBar.getModel();
java.awt.Dimension d;
javax.accessibility.AccessibleContext a;
javax.swing.plaf.ScrollBarUI ui;
myHScrollBar.setValues(50, 10, 0, 100); // Sets the four BoundedRangeModel properties after forcing the arguments to obey the usual constraints: minimum <= value <= value+extent <= maximum
myHScrollBar.setBlockIncrement(10); // Sets the blockIncrement property
myHScrollBar.setMaximum(100); // Sets the model's maximum property
myHScrollBar.setMinimum(0); // Sets the model's minimum property
myHScrollBar.setOrientation(
JScrollBar.HORIZONTAL); // Set the scrollbar's orientation to either VERTICAL or HORIZONTAL
myHScrollBar.setUnitIncrement(1); // Sets the unitIncrement property
myHScrollBar.setValue(50); // Sets the scrollbar's value
myHScrollBar.setVisibleAmount(10); // Set the model's extent property
myHScrollBar.setEnabled(true); // Enables the component so that the knob position can be changed
myHScrollBar.setValueIsAdjusting(false); // Sets the model's valueIsAdjusting property
myHScrollBar.setModel(m); // Sets the model that handles the scrollbar's four fundamental properties: minimum, maximum, value, extent
myHScrollBar.updateUI(); // Overrides JComponent.updateUI
i = myHScrollBar.getBlockIncrement(); // For backwards compatibility with java.awt.Scrollbar
i = myHScrollBar.getBlockIncrement(-1); // Returns the amount to change the scrollbar's value by, given a block (usually "page") up/down request
i = myHScrollBar.getMaximum(); // The maximum value of the scrollbar is maximum - extent
i = myHScrollBar.getMinimum(); // Returns the minimum value supported by the scrollbar (usually zero)
i = myHScrollBar.getOrientation(); // Returns the component's orientation (horizontal or vertical)
i = myHScrollBar.getUnitIncrement(); // For backwards compatibility with java.awt.Scrollbar
i = myHScrollBar.getUnitIncrement(-1); // Returns the amount to change the scrollbar's value by, given a unit up/down request
i = myHScrollBar.getValue(); // Returns the scrollbar's value
i = myHScrollBar.getVisibleAmount(); // Returns the scrollbar's extent, aka its "visibleAmount"
f = myHScrollBar.getValueIsAdjusting(); // True if the scrollbar knob is being dragged
m = myHScrollBar.getModel(); // Returns data model that handles the scrollbar's four fundamental properties: minimum, maximum, value, extent
s = myHScrollBar.getUIClassID(); // Returns the name of the LookAndFeel class for this component
d = myHScrollBar.getMaximumSize(); // The scrollbar is flexible along it's scrolling axis and rigid along the other axis
d = myHScrollBar.getMinimumSize(); // The scrollbar is flexible along it's scrolling axis and rigid along the other axis
a = myHScrollBar.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
ui = myHScrollBar.getUI(); // Returns the delegate that implements the look and feel for this component
JScrollbarAdapter adapt = new JScrollbarAdapter();
myHScrollBar.addAdjustmentListener(adapt); // Adds an AdjustmentListener
myVScrollBar.addAdjustmentListener(adapt);
myHScrollBar.removeAdjustmentListener(adapt); // Removes an AdjustmentEvent listener
myVScrollBar.removeAdjustmentListener(adapt);
}
class JScrollbarAdapter implements java.awt.event.AdjustmentListener {
public void adjustmentValueChanged(java.awt.event.AdjustmentEvent e) {
if (e.getSource() == myHScrollBar) {
} else if (e.getSource() == myVScrollBar) {
}
}
}
/*********************************************************************
* *
* JSlider: *
* *
* Fields: *
* $changeEvent $orientation *
* $changeListener $sliderModel *
* $majorTickSpacing $snapToTicks *
* $minorTickSpacing *
* *
* Methods: *
* addChangeListener getValueIsAdjusting *
* $createChangeListener $paramString *
* createStandardLabels removeChangeListener *
* createStandardLabels setExtent *
* $fireStateChanged setInverted *
* getAccessibleContext setLabelTable *
* getExtent setMajorTickSpacing *
* getInverted setMaximum *
* getLabelTable setMinimum *
* getMajorTickSpacing setMinorTickSpacing *
* getMaximum setModel *
* getMinimum setOrientation *
* getMinorTickSpacing setPaintLabels *
* getModel setPaintTicks *
* getOrientation setPaintTrack *
* getPaintLabels setSnapToTicks *
* getPaintTicks setUI *
* getPaintTrack setValue *
* getSnapToTicks setValueIsAdjusting *
* getUI $updateLabelUIs *
* getUIClassID updateUI *
* getValue *
* *
*********************************************************************/
private JSlider myHSlider = new JSlider(JSlider.HORIZONTAL, 0, 100, 50);
private JSlider myVSlider = new JSlider(JSlider.VERTICAL, 0, 100, 25);
void jslider() {
int i;
boolean f;
String s;
java.util.Hashtable h;
java.util.Dictionary d;
BoundedRangeModel m = myHSlider.getModel();
javax.accessibility.AccessibleContext a;
javax.swing.plaf.SliderUI ui = new javax.swing.plaf.metal.MetalSliderUI();
myHSlider.setValue(50); // Sets the sliders current value
myHSlider.setExtent(0); // Sets the size of the range "covered" by the knob
myHSlider.setMaximum(100); // Sets the models maximum property
myHSlider.setMinimum(0); // Sets the models minimum property
myHSlider.setMajorTickSpacing(25); // This method sets the major tick spacing
myHSlider.setMinorTickSpacing(5); // This method sets the minor tick spacing
myHSlider.setOrientation(JSlider.HORIZONTAL); // Set the scrollbars orientation to either VERTICAL or HORIZONTAL
myHSlider.setInverted(false); // Specify true to reverse the value-range shown for the slider so that the maximum value is at the left end of a horizontal slider or at the bottom of a vertical one
myHSlider.setPaintLabels(true); // Determines whether labels are painted on the slider
myHSlider.setPaintTicks(true); // Determines whether tick marks are painted on the slider
myHSlider.setPaintTrack(true); // Determines whether the track is painted on the slider
myHSlider.setSnapToTicks(false); // Specifying true makes the knob (and the data value it represents) resolve to the closest tick mark next to where the user positioned the knob
myHSlider.setValueIsAdjusting(false); // Sets the models valueIsAdjusting property
myHSlider.setModel(m); // Sets the model that handles the sliders three fundamental properties: minimum, maximum, value
myHSlider.setUI(ui); // Sets the UI object which implements the L&F for this component
myHSlider.updateUI(); // Notification from the UIFactory that the L&F has changed
myHSlider.putClientProperty("JSlider.isFilled", Boolean.TRUE);
i = myHSlider.getValue(); // Returns the sliders value
i = myHSlider.getExtent(); // Returns the "extent" -- the range of values "covered" by the knob
i = myHSlider.getMaximum(); // Returns the maximum value supported by the slider
i = myHSlider.getMinimum(); // Returns the minimum value supported by the slider
i = myHSlider.getMajorTickSpacing(); // This method returns the major tick spacing
i = myHSlider.getMinorTickSpacing(); // This method returns the minor tick spacing
i = myHSlider.getOrientation(); // Return this slider's vertical or horizontal orientation
f = myHSlider.getInverted(); // Returns true if the value-range shown for the slider is reversed, with the maximum value at the left end of a horizontal slider or at the bottom of a vertical one
f = myHSlider.getPaintLabels(); // Tells if labels are to be painted
f = myHSlider.getPaintTicks(); // Tells if tick marks are to be painted
f = myHSlider.getPaintTrack(); // Tells if the track (area the slider slides in) is to be painted
f = myHSlider.getSnapToTicks(); // Returns true if the knob (and the data value it represents) resolve to the closest tick mark next to where the user positioned the knob
f = myHSlider.getValueIsAdjusting(); // True if the slider knob is being dragged
s = myHSlider.getUIClassID(); // Returns the name of the L&F class that renders this component
m = myHSlider.getModel(); // Returns data model that handles the sliders three fundamental properties: minimum, maximum, value
a = myHSlider.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
ui = myHSlider.getUI(); // Gets the UI object which implements the L&F for this component
myVSlider.setPaintLabels(true);
h = myVSlider.createStandardLabels(25); // Creates a hashtable that will draw text labels starting at the slider minimum using the increment specified
h = myVSlider.createStandardLabels(25, 0); // Creates a hashtable that will draw text labels starting at the start point specified using the increment specified
myVSlider.setLabelTable(h); // Used to specify what label will be drawn at any given value
d = myVSlider.getLabelTable(); // Returns the dictionary of what labels to draw at which values
JSliderAdapter adapt = new JSliderAdapter();
myHSlider.addChangeListener(adapt); // Adds a ChangeListener to the slider
myVSlider.addChangeListener(adapt);
myHSlider.removeChangeListener(adapt); // Removes a ChangeListener from the slider
myVSlider.removeChangeListener(adapt);
}
class JSliderAdapter implements javax.swing.event.ChangeListener {
public void stateChanged(javax.swing.event.ChangeEvent e) {
if (e.getSource() == myHSlider) {
} else if (e.getSource() == myVSlider) {
}
}
}
/*********************************************************************
* *
* JProgressBar: *
* *
* Fields: *
* $changeEvent $paintBorder *
* $changeListener $paintString *
* $model $progressString *
* $orientation *
* *
* Methods: *
* addChangeListener isStringPaited *
* $createChangeListener $paintBorder *
* $fireStateChanged $paramString *
* getAccessibleContext removeChangeListener *
* getMaximum setBorderPainted *
* getMinimum setMaximum *
* getModel setMinimum *
* getOrientation setModel *
* getPercentComplete setOrientation *
* getString setString *
* getUI setStringPainted *
* getUIClassID setUI *
* getValue setValue *
* isBorderPainted updateUI *
* *
*********************************************************************/
private JProgressBar myHProgressBar = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
private JProgressBar myVProgressBar = new JProgressBar(JProgressBar.VERTICAL, 0, 100);
void jprogressbar() {
int i;
boolean f;
double x;
String s;
BoundedRangeModel m = myHProgressBar.getModel();
javax.accessibility.AccessibleContext a;
javax.swing.plaf.ProgressBarUI ui = new javax.swing.plaf.metal.MetalProgressBarUI();
myHProgressBar.setValue(50); // Sets the model's current value to x
myHProgressBar.setMaximum(100); // Sets the model's maximum to x
myHProgressBar.setMinimum(0); // Sets the model's minimum to x
myHProgressBar.setModel(m); // Sets the data model used by the JProgressBar
myHProgressBar.setOrientation(
JProgressBar.HORIZONTAL); // Sets the progress bar's orientation to newOrientation, which must be JProgressBar.VERTICAL or JProgressBar.HORIZONTAL
myHProgressBar.setBorderPainted(true); // Sets whether the progress bar should paint its border
myHProgressBar.setStringPainted(true); // Sets whether the progress bar will render a string
myHProgressBar.setString("ProgressBar"); // Sets the value of the Progress String
myHProgressBar.setUI(ui); // Sets the L&F object that renders this component
myHProgressBar.updateUI(); // Notification from the UIFactory that the L&F has changed
i = myHProgressBar.getMaximum(); // Returns the model's maximum value
i = myHProgressBar.getMinimum(); // Returns the model's minimum value
i = myHProgressBar.getOrientation(); // Returns JProgressBar.VERTICAL or JProgressBar.HORIZONTAL, depending on the orientation of the progress bar
i = myHProgressBar.getValue(); // Returns the model's current value
f = myHProgressBar.isBorderPainted(); // Returns true if the progress bar has a border or false if it does not
f = myHProgressBar.isStringPainted(); // Returns true if the progress bar will render a string onto the representation of the progress bar
x = myHProgressBar.getPercentComplete(); // Returns the percentage/percent complete for the progress bar
s = myHProgressBar.getString(); // Returns the current value of the Progress String
s = myHProgressBar.getUIClassID(); // Returns the name of the L&F class that renders this component
a = myHProgressBar.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
m = myHProgressBar.getModel(); // Returns the data model used by the JProgressBar
ui = myHProgressBar.getUI(); // Returns the L&F object that renders this component
JProgressBarAdapter adapt = new JProgressBarAdapter();
myHProgressBar.addChangeListener(adapt); // Adds a ChangeListener to the ProgressBar
myVProgressBar.addChangeListener(adapt);
myHProgressBar.removeChangeListener(adapt); // Removes a ChangeListener from the ProgressBar
myVProgressBar.removeChangeListener(adapt);
}
class JProgressBarAdapter implements javax.swing.event.ChangeListener {
public void stateChanged(javax.swing.event.ChangeEvent e) {
if (e.getSource() == myHProgressBar) {
} else if (e.getSource() == myVProgressBar) {
}
}
}
/*********************************************************************
* *
* ProgressMonitor: *
* *
* Methods: *
* close setMaximum *
* getMaximum setMillisToDecideToPopup *
* getMillisToDecideToPopup setMillisToPopup *
* getMillisToPopup setMinimum *
* getMinimum setNote *
* getNote setProgress *
* isCanceled *
* *
*********************************************************************/
ProgressMonitor myProgressMonitor = new ProgressMonitor(myButton, "Monitor Progress", "Init...", 0, 100);
void progressmonitor() {
int i;
String s;
myProgressMonitor.setMinimum(0); // Specifies the minimum value
myProgressMonitor.setMaximum(100); // Specifies the maximum value
myProgressMonitor.setMillisToDecideToPopup(500); // Specifies the amount of time to wait before deciding whether or not to popup a progress monitor
myProgressMonitor.setMillisToPopup(2000); // Specifies the amount of time it will take for the popup to appear
for (int j = 0; j < 100; j++) {
if (myProgressMonitor.isCanceled()) break; // Returns true if the user does some UI action to cancel this operation
myProgressMonitor.setProgress(j); // Indicate the progress of the operation being monitored
myProgressMonitor.setNote(j + "% Complete"); // Specifies the additional note that is displayed along with the progress message
try { Thread.sleep(50); } catch(InterruptedException e) { }
}
i = myProgressMonitor.getMaximum(); // Returns the maximum value -- the higher end of the progress value
i = myProgressMonitor.getMillisToDecideToPopup(); // Returns the amount of time this object waits before deciding whether or not to popup a progress monitor
i = myProgressMonitor.getMillisToPopup(); // Returns the amount of time it will take for the popup to appear
i = myProgressMonitor.getMinimum(); // Returns the minimum value -- the lower end of the progress value
s = myProgressMonitor.getNote(); // Specifies the additional note that is displayed along with the progress message
myProgressMonitor.close(); // Indicate that the operation is complete
}
/*********************************************************************
* *
* ProgressMonitorInputStream: *
* *
* Methods: *
* close read skip *
* getProgressMonitor reset *
* *
*********************************************************************/
void progressmonitorinputstream() {
byte[] data = new byte[100];
java.io.FileInputStream ios;
java.io.InputStream in;
ProgressMonitorInputStream pios;
ProgressMonitor pm;
try {
ios = new java.io.FileInputStream("/java/test/chris/Syntax.java");
pios = new ProgressMonitorInputStream(myButton, "Monitor Input Stream Progress", ios);
pm = pios.getProgressMonitor(); // Get the ProgressMonitor object being used by this stream
in = new java.io.BufferedInputStream(pios);
while (in.available() > 0) {
if (pm.isCanceled()) break;
in.read(data);
try { Thread.sleep(50); } catch(InterruptedException e) { }
}
pios.close(); // close the progress monitor as well as the stream
} catch(java.io.FileNotFoundException e) {
System.out.println(e);
} catch(java.io.IOException e) {
System.out.println(e);
}
}
/*********************************************************************
* *
* JList: *
* *
* Methods: *
* addListSelectionListener getSelectionModel *
* addSelectionInterval getUI *
* clearSelection getUIClassID *
* $createSelectionModel getValueIsAdjusting *
* ensureIndexIsVisible getVisibleRowCount *
* $fireSelectionValueChanged indexToLocation *
* getAccessibleContext isSelectedIndex *
* getAnchorSelectionIndex isSelectionEmpty *
* getCellBounds locationToIndex *
* getCellRenderer $paramString *
* getFirstVisibleIndex removeList *
* getFixedCellHeight SelectionListener *
* getFixedCellWidth removeSelectionInterval *
* getLastVisibleIndex setCellRenderer *
* getLeadSelectionIndex setFixedCellHeight *
* getMaxSelectionIndex setFixedCellWidth *
* getMinSelectionIndex setListData *
* getModel setModel *
* getPreferredScrollableViewportSize setPrototypeCellValue *
* getPrototypeCellValue setSelectedIndex *
* getScrollableBlockIncrement setSelectedIndices *
* getScrollableTracksViewportHeight setSelectedValue *
* getScrollableTracksViewportWidth setSelectionBackground *
* getScrollableUnitIncrement setSelectionForeground *
* getSelectedIndex setSelectionInterval *
* getSelectedIndices setSelectionMode *
* getSelectedValue setSelectionModel *
* getSelectedValues setUI *
* getSelectionBackground setValueIsAdjusting *
* getSelectionForeground setVisibleRowCount *
* getSelectionMode updateUI *
* *
*********************************************************************/
private String[] listVals = {"Test List 0", "Test List 1", "Test List 2", "Test List 3", "Test List 4"};
private JList myList = new JList(listVals);
void jlist() {
int i;
int[] ix = {1, 3};
boolean f;
String s;
Object obj;
Object[] ox;
java.awt.Color c;
java.awt.Dimension d;
java.awt.Rectangle r;
java.awt.Point p;
javax.accessibility.AccessibleContext a;
ListModel m = myList.getModel();
ListSelectionModel n = myList.getSelectionModel();
//ListCellRenderer q = myList.getCellRenderer();
ListCellRenderer q = new CMRListCellRenderer();
javax.swing.plaf.ListUI ui = new javax.swing.plaf.basic.BasicListUI();
myList.setSelectionMode(
ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); // Determines whether single-item or multiple-item selections are allowed
myList.setModel(m); // Sets the model that represents the contents or "value" of the list and clears the list selection after notifying PropertyChangeListeners
myList.setSelectionModel(n); // Set the selectionModel for the list to a non-null ListSelectionModel implementation
myList.setCellRenderer(q); // Sets the delegate that's used to paint each cell in the list
myList.setListData(listVals); // A convenience method that constructs a ListModel from an array of Objects and then applies setModel to it
myList.clearSelection(); // Clears the selection - after calling this method isSelectionEmpty() will return true
myList.setSelectedIndex(1); // Select a single cell
myList.setSelectedIndices(ix); // Select a set of cells
myList.setSelectionInterval(1, 2); // Select the specified interval
myList.addSelectionInterval(3, 4); // Set the selection to be the union of the specified interval with current selection
myList.removeSelectionInterval(2, 3); // Set the selection to be the set difference of the specified interval and the current selection
myList.setVisibleRowCount(3); // Set the preferred number of rows in the list that can be displayed without a scollbar, as determined by the nearest JViewport ancestor, if any
myList.ensureIndexIsVisible(0); // If this JList is being displayed within a JViewport and the specified cell isn't completely visible, scroll the viewport
myList.setValueIsAdjusting(false); // Sets the data model's isAdjusting property true, so that a single event will be generated when all of the selection events have finished (for example, when the mouse is being dragged over the list in selection mode)
myList.setSelectionBackground(java.awt.Color.blue); // Set the background color for selected cells
myList.setSelectionForeground(java.awt.Color.black); // Set the foreground color for selected cells
myList.setFixedCellHeight(-1); // If this value is greater than zero it defines the height of every cell in the list
myList.setFixedCellWidth(-1); // If this value is greater than zero it defines the width of every cell in the list
myList.setUI(ui); // Sets the L&F object that renders this component
myList.updateUI(); // Set the UI property with the "ListUI" from the current default UIFactory
i = myList.getAnchorSelectionIndex(); // Returns the first index argument from the most recent addSelectionInterval or setSelectionInterval call
i = myList.getFirstVisibleIndex(); // Return the index of the cell in the upper left corner of the JList or -1 if nothing is visible or the list is empty
i = myList.getFixedCellHeight(); // Returns the fixed cell width value -- the value specified by setting the fixedCellHeight property, rather than calculated from the list elements
i = myList.getFixedCellWidth(); // Returns the fixed cell width value -- the value specified by setting the fixedCellWidth property, rather than calculated from the list elements
i = myList.getLastVisibleIndex(); // Return the index of the cell in the lower right corner of the JList or -1 if nothing is visible or the list is empty
i = myList.getLeadSelectionIndex(); // Returns the second index argument from the most recent addSelectionInterval or setSelectionInterval call
i = myList.getMaxSelectionIndex(); // Returns the largest selected cell index
i = myList.getMinSelectionIndex(); // Returns the smallest selected cell index
i = myList.getSelectedIndex(); // A convenience method that returns the first selected index
i = myList.getSelectionMode(); // Returns whether single-item or multiple-item selections are allowed
switch (i) {
case ListSelectionModel.SINGLE_SELECTION: break;
case ListSelectionModel.SINGLE_INTERVAL_SELECTION: break;
case ListSelectionModel.MULTIPLE_INTERVAL_SELECTION: break;
}
i = myList.getVisibleRowCount(); // Return the preferred number of visible rows
ix = myList.getSelectedIndices(); // Return an array of all of the selected indices in increasing order
ox = myList.getSelectedValues(); // Return an array of the values for the selected cells
obj = myList.getSelectedValue(); // A convenience method that returns the first selected value or null, if the selection is empty
myList.setSelectedValue(obj, false); // Selects the specified object from the list
obj = myList.getPrototypeCellValue(); // Returns the cell width of the "prototypical cell" -- a cell used for the calculation of cell widths, because it has the same value as all other list items, instead of forcing the calculation to inspect every item in the list
myList.setPrototypeCellValue(obj); // If this value is non-null it's used to compute fixedCellWidth and fixedCellHeight by configuring the cellRenderer at index equals zero for the specified value and then computing the renderer components preferred size
f = myList.getScrollableTracksViewportHeight(); // If this JList is displayed in a JViewport, don't change its height when the viewports height changes
f = myList.getScrollableTracksViewportWidth(); // If this JList is displayed in a JViewport, don't change its width when the viewports width changes
f = myList.getValueIsAdjusting(); // Returns the value of the data model's isAdjusting property
f = myList.isSelectedIndex(2); // Returns true if the specified index is selected
f = myList.isSelectionEmpty(); // Returns true if nothing is selected This is a convenience method that just delegates to the selectionModel
c = myList.getSelectionBackground(); // Returns the background color for selected cells
c = myList.getSelectionForeground(); // Returns the foreground color
d = myList.getPreferredScrollableViewportSize(); // Compute the size of the viewport needed to display visibleRowCount rows
r = myList.getCellBounds(1, 2); // Returns the bounds of the specified range of items in JList coordinates, null if index isn't valid
p = myList.indexToLocation(1); // Returns the origin of the specified item in JList coordinates, null if index isn't valid
i = myList.locationToIndex(p); // Convert a point in JList coordinates to the index of the cell at that location
a = myList.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
s = myList.getUIClassID(); // Returns the class ID for the UI
m = myList.getModel(); // Returns the data model that holds the list of items displayed by the JList component
n = myList.getSelectionModel(); // Returns the value of the current selection model
q = myList.getCellRenderer(); // Returns the object that renders the list items
ui = myList.getUI(); // Returns the L&F object that renders this component
ListSelectionModelAdapter adapt = new ListSelectionModelAdapter();
myList.addListSelectionListener(adapt); // Add a listener to the list that's notified each time a change to the selection occurs
myList.removeListSelectionListener(adapt); // Remove a listener from the list that's notified each time a change to the selection occurs
/*
int myList.getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction); // Returns the block increment amount
int myList.getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction); // Horizontal scrolling: return the lists font size or 1 if the font is null
*/
}
/*********************************************************************
* *
* ListModel Interface: *
* *
* Methods: *
* addListDataListener getSize *
* getElementAt removeListDataListener *
* *
*********************************************************************/
void listmodel() {
int i;
Object x;
ListModel m = myList.getModel();
i = m.getSize(); // Returns the length of the list
x = m.getElementAt(2); // Returns the value at the specified index
ListModelAdapter adapt = new ListModelAdapter();
m.addListDataListener(adapt); // Add a listener to the list that's notified each time a change to the data model occurs
m.removeListDataListener(adapt); // Remove a listener from the list that's notified each time a change to the data model occurs
}
class ListModelAdapter implements javax.swing.event.ListDataListener {
public void contentsChanged(javax.swing.event.ListDataEvent e) {
int i;
Object x;
i = e.getIndex0();
i = e.getIndex1();
i = e.getType();
x = e.getSource();
}
public void intervalAdded(javax.swing.event.ListDataEvent e) { }
public void intervalRemoved(javax.swing.event.ListDataEvent e) { }
}
/*********************************************************************
* *
* AbstractListModel: *
* *
* Methods: *
* addListDataListener $fireIntervalRemoved *
* $fireContentsChanged removeListDataListener *
* $fireIntervalAdded *
* *
*********************************************************************/
void abstractlistmodel() {
AbstractListModel m = (AbstractListModel)myList.getModel();
ListModelAdapter adapt = new ListModelAdapter();
m.addListDataListener(adapt); // Add a listener to the list that's notified each time a change to the data model occurs
m.removeListDataListener(adapt); // Remove a listener from the list that's notified each time a change to the data model occurs
}
/*********************************************************************
* *
* DefaultListModel: *
* *
* Methods: *
* add get removeElement *
* addElement getElementAt removeElementAt *
* capacity getSize removeRange *
* clear indexOf set *
* contains insertElementAt setElementAt *
* copyInto isEmpty setSize *
* elementAt lastElement size *
* elements lastIndexOf toArray *
* ensureCapacity remove toString *
* firstElement removeAllElements trimToSize *
* *
*********************************************************************/
void defaultlistmodel() {
int i;
boolean f;
String s;
Object obj;
Object[] ox;
java.util.Enumeration z;
DefaultListModel m = new DefaultListModel();
m.addElement("DList #0"); // Adds the specified component to the end of this list
m.addElement("DList #3");
m.insertElementAt("DList #1", 1); // Inserts the specified object as a component in this list at the specified index
m.add(2, "DList #2"); // Inserts the specified element at the specified position in this list
obj = m.set(1, "DList #1"); // Replaces the element at the specified position in this list with the specified element
m.setElementAt("DList #1", 1); // Sets the component at the specified index of this list to be the specified object
//m.removeAllElements(); // Removes all components from this list and sets its size to zero
//m.removeElementAt(3); // Deletes the component at the specified index
//m.removeRange(1, 2); // Deletes the components at the specified range of indexes
//f = m.removeElement(obj); // Removes the first (lowest-indexed) occurrence of the argument from this list
//obj = m.remove(0); // Removes the element at the specified position in this list
m.ensureCapacity(10); // Increases the capacity of this list, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument
m.setSize(5); // Sets the size of this list
m.trimToSize(); // Trims the capacity of this list to be the list's current size
obj = m.firstElement(); // Returns the first component of this list
obj = m.lastElement(); // Returns the last component of the list
obj = m.elementAt(1); // Returns the component at the specified index
obj = m.get(1); // Returns the element at the specified position in this list
obj = m.getElementAt(1); // Returns the component at the specified index
ox = m.toArray(); // Returns an array containing all of the elements in this list in the correct order
m.copyInto(ox); // Copies the components of this list into the specified array
z = m.elements(); // Returns an enumeration of the components of this list
i = m.capacity(); // Returns the current capacity of this list
i = m.getSize(); // Returns the number of components in this list
i = m.size(); // Returns the number of components in this list
i = m.indexOf(obj); // Searches for the first occurence of the given argument
i = m.indexOf(obj, 0); // Searches for the first occurence of the given argument, beginning the search at index
i = m.lastIndexOf(obj); // Returns the index of the last occurrence of the specified object in this list
i = m.lastIndexOf(obj, 1); // Searches backwards for the specified object, starting from the specified index, and returns an index to it
f = m.isEmpty(); // Tests if this list has no components
f = m.contains(obj); // Tests if the specified object is a component in this list
s = m.toString(); // Returns a string that displays and identifies this object's properties
//myList.setModel(m);
}
/*********************************************************************
* *
* ListSelectionModel Interface: *
* *
* Fields: *
* MULTIPLE_INTERVAL_SELECTION SINGLE_SELECTION *
* SINGLE_INTERVAL_SELECTION *
* *
* Methods: *
* addListSelectionListener isSelectedIndex *
* addSelectionInterval isSelectionEmpty *
* clearSelection removeIndexInterval *
* getAnchorSelectionIndex removeListSelectionListener *
* getLeadSelectionIndex removeSelectionInterval *
* getMaxSelectionIndex setAnchorSelectionIndex *
* getMinSelectionIndex setLeadSelectionIndex *
* getSelectionMode setSelectionInterval *
* getValueIsAdjusting setSelectionMode *
* insertIndexInterval setValueIsAdjusting *
* *
*********************************************************************/
void listselectionmodel() {
int i;
boolean f;
ListSelectionModel m = myList.getSelectionModel();
m.setSelectionMode(
ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); // Set the selection mode
m.setValueIsAdjusting(false); // This property is true if upcoming changes to the value of the model should be considered a single event
m.clearSelection(); // Change the selection to the empty set
m.setSelectionInterval(1, 2); // Change the selection to be between index0 and index1 inclusive
m.addSelectionInterval(4, 4); // Change the selection to be the set union of the current selection and the indices between index0 and index1 inclusive
m.setAnchorSelectionIndex(1); // Set the anchor selection index
m.setLeadSelectionIndex(1); // Set the lead selection index
//m.removeSelectionInterval(2, 4); // Change the selection to be the set difference of the current selection and the indices between index0 and index1 inclusive
m.insertIndexInterval(2, 1, false); // Insert length indices beginning before/after index
m.removeIndexInterval(2, 2); // Remove the indices in the interval index0,index1 (inclusive) from the selection model
f = m.isSelectedIndex(2); // Returns true if the specified index is selected
f = m.getValueIsAdjusting(); // Returns true if the value is undergoing a series of changes
f = m.isSelectionEmpty(); // Returns true if no indices are selected
i = m.getAnchorSelectionIndex(); // Return the first index argument from the most recent call to setSelectionInterval() or addSelectionInterval()
i = m.getLeadSelectionIndex(); // Return the second index argument from the most recent call to setSelectionInterval() or addSelectionInterval()
i = m.getMaxSelectionIndex(); // Returns the last selected index or -1 if the selection is empty
i = m.getMinSelectionIndex(); // Returns the first selected index or -1 if the selection is empty
i = m.getSelectionMode(); // Returns the current selection mode
switch (i) {
case ListSelectionModel.SINGLE_SELECTION:
// select one list index at a time
break;
case ListSelectionModel.SINGLE_INTERVAL_SELECTION:
// select one contiguous range of indices at a time
break;
case ListSelectionModel.MULTIPLE_INTERVAL_SELECTION:
// select one or more contiguous ranges of indices at a time
break;
}
ListSelectionModelAdapter adapt = new ListSelectionModelAdapter();
m.addListSelectionListener(adapt); // Add a listener to the list that's notified each time a change to the selection occurs
m.removeListSelectionListener(adapt); // Remove a listener from the list that's notified each time a change to the selection occurs
}
class ListSelectionModelAdapter implements javax.swing.event.ListSelectionListener {
public void valueChanged(javax.swing.event.ListSelectionEvent e) {
int i;
boolean f;
Object x;
i = e.getFirstIndex();
i = e.getLastIndex();
f = e.getValueIsAdjusting();
x = e.getSource();
}
}
/*********************************************************************
* *
* DefaultListSelectionModel: *
* *
* Methods: *
* addListSelectionListener isLeadAnchorNotificationEnabled *
* addSelectionInterval isSelectedIndex *
* clearSelection isSelectionEmpty *
* clone removeIndexInterval *
* $fireValueChanged removeListSelectionListener *
* $fireValueChanged removeSelectionInterval *
* $fireValueChanged setAnchorSelectionIndex *
* getAnchorSelectionIndex setLeadAnchorNotificationEnabled *
* getLeadSelectionIndex setLeadSelectionIndex *
* getMaxSelectionIndex setSelectionInterval *
* getMinSelectionIndex setSelectionMode *
* getSelectionMode setValueIsAdjusting *
* getValueIsAdjusting toString *
* insertIndexInterval *
* *
*********************************************************************/
void defaultlistselectionmodel() {
int i;
boolean f;
String s;
Object obj;
DefaultListSelectionModel m = (DefaultListSelectionModel)myList.getSelectionModel();
m.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
m.setValueIsAdjusting(false);
//m.clearSelection();
m.setSelectionInterval(1, 2);
m.addSelectionInterval(4, 4);
m.removeSelectionInterval(2, 4);
m.removeIndexInterval(2, 4); // Remove the indices in the interval index0,index1 (inclusive) from the selection model
m.insertIndexInterval(2, 1, false); // Insert length indices beginning before/after index
m.setAnchorSelectionIndex(1); // Set the anchor selection index, leaving all selection values unchanged
m.setLeadSelectionIndex(1); // Set the lead selection index, ensuring that values between the anchor and the new lead are either all selected or all deselected
m.setLeadAnchorNotificationEnabled(false); // Sets the value of the leadAnchorNotificationEnabled flag
i = m.getAnchorSelectionIndex();
i = m.getLeadSelectionIndex();
i = m.getMaxSelectionIndex();
i = m.getMinSelectionIndex();
i = m.getSelectionMode();
f = m.getValueIsAdjusting();
f = m.isLeadAnchorNotificationEnabled(); // Returns the value of the leadAnchorNotificationEnabled flag
f = m.isSelectedIndex(2);
f = m.isSelectionEmpty();
s = m.toString(); // Returns a string that displays and identifies this object's properties
try {
obj = m.clone(); // Returns a clone of the reciever with the same selection
} catch(CloneNotSupportedException e) {
}
ListSelectionModelAdapter adapt = new ListSelectionModelAdapter();
m.addListSelectionListener(adapt); // Add a listener to the list that's notified each time a change to the selection occurs
m.removeListSelectionListener(adapt); // Remove a listener from the list that's notified each time a change to the selection occurs
}
/*********************************************************************
* *
* ListCellRenderer Interface: *
* *
* Methods: *
* getListCellRendererComponent *
* *
*********************************************************************/
class CMRListCellRenderer extends JLabel implements ListCellRenderer {
java.awt.Color highlightColor = new java.awt.Color(0, 0, 128);
public CMRListCellRenderer() {
setOpaque(true);
}
// Return a component that has been configured to display the specified value
public java.awt.Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
if (index == -1) {
int selected = list.getSelectedIndex();
if (selected == -1) {
return this;
} else {
index = selected;
}
}
setText("Title #" + index);
setIcon(myImageIcon);
if (isSelected) {
setBackground(highlightColor);
setForeground(java.awt.Color.white);
} else {
setBackground(java.awt.Color.white);
setForeground(java.awt.Color.black);
}
return this;
}
}
/*********************************************************************
* *
* JComboBox: *
* *
* Fields: *
* $actionCommand $lightWeightPopupEnabled *
* $dataModel $maximumRowCount *
* $editor $renderer *
* $isEditable $selectedItemReminder *
* $keySelectionManager *
* *
* Methods: *
* actionPerformed isEditable *
* addActionListener isFocusTraversable *
* addItem isLightWeightPopupEnabled *
* addItemListener isPopupVisible *
* configureEditor $paramString *
* contentsChanged processKeyEvent *
* $createDefaultKeySelectionManager removeActionListener *
* $fireActionEvent removeAllItems *
* $fireItemStateChanged removeItem *
* getAccessibleContext removeItemAt *
* getActionCommand removeItemListener *
* getEditor $selectedItemChanged *
* getItemAt selectWithKeyChar *
* getItemCount setActionCommand *
* getKeySelectionManager setEditable *
* getMaximumRowCount setEditor *
* getModel setEnabled *
* getRenderer setKeySelectionManager *
* getSelectedIndex setLightWeightPopupEnabled*
* getSelectedItem setMaximumRowCount *
* getSelectedObjects setModel *
* getUI setPopupVisible *
* getUIClassID setRenderer *
* hidePopup setSelectedIndex *
* insertItemAt setSelectedItem *
* $installAncestorListener setUI *
* intervalAdded showPopup *
* intervalRemoved updateUI *
* *
*********************************************************************/
private JComboBox myComboBox = new JComboBox(listVals);
void jcombobox() {
int i;
boolean f;
String s;
Object obj = "Test List 5";
Object[] ox;
ComboBoxEditor e = myComboBox.getEditor();
ComboBoxModel m = myComboBox.getModel();
ListCellRenderer q = myComboBox.getRenderer();
JComboBox.KeySelectionManager k = new CMRKeySelectionManager();
javax.accessibility.AccessibleContext a;
javax.swing.plaf.ComboBoxUI ui = new javax.swing.plaf.metal.MetalComboBoxUI();
myComboBox.hidePopup(); // Causes the combo box to close its popup window
myComboBox.showPopup(); // Causes the combo box to display its popup window
myComboBox.setEditable(true); // Determines whether the JComboBox field is editable
myComboBox.setPopupVisible(false); // Set the visiblity of the popup
myComboBox.setEnabled(true); // Enables the combo box so that items can be selected
myComboBox.setLightWeightPopupEnabled(true); // When displaying the popup, JComboBox choose to use a light weight popup if it fits
myComboBox.setMaximumRowCount(3); // Sets the maximum number of rows the JComboBox displays
myComboBox.setActionCommand("myComboBoxCmd"); // Sets the action commnand that should be included in the event sent to action listeners
myComboBox.setEditor(e); // Sets the editor used to paint and edit the selected item in the JComboBox field
myComboBox.setModel(m); // Sets the data model that the JComboBox uses to obtain the list of items
myComboBox.setRenderer(q); // Sets the renderer that paints the item selected from the list in the JComboBox field
myComboBox.setUI(ui); // Sets the L&F object that renders this component
myComboBox.updateUI(); // Notification from the UIFactory that the L&F has changed
myComboBox.addItem(obj); // Adds an item to the item list
//myComboBox.insertItemAt(obj, 2); // Inserts an item into the item list at a given index
//myComboBox.removeAllItems(); // Removes all items from the item list
//myComboBox.removeItem(obj); // Removes an item from the item list
//myComboBox.removeItemAt(2); // Removes the item at anIndex This method works only if the JComboBox uses the default data model
myComboBox.setSelectedIndex(2); // Selects the item at index anIndex
myComboBox.setSelectedItem(obj); // Sets the selected item in the JComboBox by specifying the object in the list
myComboBox.configureEditor(e, "hello world"); // Initializes the editor with the specified item
myComboBox.setKeySelectionManager(k); // Sets the object that translates a keyboard character into a list selection
f = myComboBox.selectWithKeyChar('3'); // Selects the list item that correponds to the specified keyboard character and returns true, if there is an item corresponding to that character
i = myComboBox.getItemCount(); // Returns the number of items in the list
i = myComboBox.getMaximumRowCount(); // Returns the maximum number of items the combo box can display without a scrollbar
i = myComboBox.getSelectedIndex(); // Returns the index of the currently selected item in the list
f = myComboBox.isEditable(); // Returns true if the JComboBox is editable
f = myComboBox.isFocusTraversable(); // Returns true if the component can receive the focus
f = myComboBox.isLightWeightPopupEnabled(); // Returns true if lightweight (all-Java) popups are in use, or false if heavyweight (native peer) popups are being used
f = myComboBox.isPopupVisible(); // Determine the visibility of the popup
s = myComboBox.getActionCommand(); // Returns the action commnand that is included in the event sent to action listeners
s = myComboBox.getUIClassID(); // Returns the name of the L&F class that renders this component
obj = myComboBox.getSelectedItem(); // Returns the currently selected item
obj = myComboBox.getItemAt(2); // Returns the list item at the specified index
ox = myComboBox.getSelectedObjects(); // Returns an array containing the selected item
e = myComboBox.getEditor(); // Returns the editor used to paint and edit the selected item in the JComboBox field
m = myComboBox.getModel(); // Returns the data model currently used by the JComboBox
q = myComboBox.getRenderer(); // Returns the renderer used to display the selected item in the JComboBox field
a = myComboBox.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
ui = myComboBox.getUI(); // Returns the L&F object that renders this component
k = myComboBox.getKeySelectionManager(); // Returns the list's key-selection manager
JComboBoxAdapter adapt = new JComboBoxAdapter();
myComboBox.addActionListener(adapt); // Adds an ActionListener
myComboBox.addItemListener(adapt); // Adds an ItemListener
myComboBox.removeActionListener(adapt); // Removes an ActionListener
myComboBox.removeItemListener(adapt); // Removes an ItemListener
}
class JComboBoxAdapter implements java.awt.event.ActionListener, java.awt.event.ItemListener {
public void actionPerformed(java.awt.event.ActionEvent e) { }
public void itemStateChanged(java.awt.event.ItemEvent e) { }
}
/*********************************************************************
* *
* ComboBoxModel Interface: *
* *
* Methods: *
* getSelectedItem setSelectedItem *
* *
*********************************************************************/
void comboboxmodel() {
Object obj;
ComboBoxModel m = myComboBox.getModel();
obj = m.getSelectedItem(); // Return the selected item
m.setSelectedItem(obj); // Set the selected item
}
/*********************************************************************
* *
* DefaultComboBoxModel: *
* *
* Methods: *
* addElement getSize removeElementAt *
* getElementAt insertElementAt setSelectedItem *
* getIndexOf removeAllElements *
* getSelectedItem removeElement *
* *
*********************************************************************/
void defaultcomboboxmodel() {
int i;
Object obj = "Test List 6";
DefaultComboBoxModel m = (DefaultComboBoxModel)myComboBox.getModel();
m.addElement(obj);
//m.insertElementAt(obj, 2);
//m.removeAllElements(); // Empties the list
//m.removeElement(obj);
//m.removeElementAt(2);
m.setSelectedItem(obj);
i = m.getSize();
i = m.getIndexOf(obj); // Returns the index-position of the specified object in the list
obj = m.getSelectedItem();
obj = m.getElementAt(2);
}
/*********************************************************************
* *
* MutableComboBoxModel Interface: *
* *
* Methods: *
* addElement removeElement *
* insertElementAt removeElementAt *
* *
*********************************************************************/
void mutablecomboboxmodel() {
Object obj = "Test List 7";
MutableComboBoxModel m = (MutableComboBoxModel)myComboBox.getModel();
m.addElement(obj); // Adds an item to the end of the model
//m.insertElementAt(obj, 2); // Adds an item at a specific index
//m.removeElement(obj); // Adds an item to the end of the model
//m.removeElementAt(2); // Removes an item at a specific index
}
/*********************************************************************
* *
* ComboBoxEditor Interface: *
* *
* Methods: *
* addActionListener getItem selectAll *
* getEditorComponent removeActionListener setItem *
* *
*********************************************************************/
void comboboxeditor() {
Object obj;
java.awt.Component c;
ComboBoxEditor e = myComboBox.getEditor();
c = e.getEditorComponent(); // Return the component that should be added to the tree hierarchy for this editor
obj = e.getItem(); // Return the edited item
e.setItem(obj); // Set the item that should be edited
e.selectAll(); // Ask the editor to start editing and to select everything
ComboBoxEditorAdapter adapt = new ComboBoxEditorAdapter();
e.addActionListener(adapt); // Add an ActionListener
e.removeActionListener(adapt); // Remove an ActionListener
}
class ComboBoxEditorAdapter implements java.awt.event.ActionListener {
public void actionPerformed(java.awt.event.ActionEvent e) { System.out.println("ComboBoxEditor actionPerformed"); }
}
/*********************************************************************
* *
* JComboBox.KeySelectionManager Interface: *
* *
* Methods: *
* selectionForKey *
* *
*********************************************************************/
class CMRKeySelectionManager implements JComboBox.KeySelectionManager {
// Given aKey and the model, returns the row that should become selected
public int selectionForKey(char aKey, ComboBoxModel aModel) {
if ((aKey >= '0') && (aKey <= '9')) {
return (aKey - '0');
} else {
return -1;
}
}
}
/*********************************************************************
* *
* JPanel: *
* *
* Methods: *
* getAccessibleContext() $paramString() *
* getUIClassID() updateUI() *
* *
*********************************************************************/
private JPanel myPanel = new JPanel(new java.awt.FlowLayout());
void jpanel() {
String s;
javax.accessibility.AccessibleContext a;
myPanel.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.RAISED));
myPanel.add(new JLabel("Test JPanel"));
myPanel.updateUI(); // Notification from the UIFactory that the L&F has changed
a = myPanel.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
s = myPanel.getUIClassID(); // Returns a string that specifies the name of the L&F class that renders this component
}
/*********************************************************************
* *
* JRootPane: *
* *
* Fields: *
* $contentPane $defaultReleaseAction $layeredPane *
* $defaultButton $glassPane $menuBar *
* $defaultPressAction *
* *
* Methods: *
* $addImpl getDefaultButton removeNotify *
* addNotify getGlassPane setContentPane *
* $createContentPane getJMenuBar setDefaultButton *
* $createGlassPane getLayeredPane setGlassPane *
* $createLayeredPane getMenuBar setJMenuBar *
* $createRootLayout isFocusCycleRoot setLayeredPane *
* getAccessibleContext isValidateRoot setMenuBar *
* getContentPane $paramString *
* *
*********************************************************************/
void jrootpane() {
boolean f;
JButton b;
JMenuBar mb;
JLayeredPane lp;
java.awt.Container cp;
java.awt.Component gp;
javax.accessibility.AccessibleContext a;
JRootPane rp = myPanel.getRootPane();
f = rp.isFocusCycleRoot(); // Make JRootPane be the root of a focus cycle
f = rp.isValidateRoot(); // If a descendant of this JRootPane calls revalidate, validate from here on down
cp = rp.getContentPane(); // Returns the content pane -- the container that holds the components parented by the root pane
gp = rp.getGlassPane(); // Returns the current glass pane for this JRootPane
lp = rp.getLayeredPane(); // Get the layered pane used by the root pane
mb = rp.getJMenuBar(); // Returns the menu bar from the layered pane
b = rp.getDefaultButton(); // Returns the current default button for this JRootPane
a = rp.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
rp.setDefaultButton(myButton); // Sets the current default button for this JRootPane
rp.setContentPane(cp); // Sets the content pane -- the container that holds the components parented by the root pane
rp.setGlassPane(gp); // Sets a specified Component to be the glass pane for this root pane
rp.setLayeredPane(lp); // Set the layered pane for the root pane
rp.setJMenuBar(myMenuBar); // Adds or changes the menu bar used in the layered pane
}
/*********************************************************************
* *
* RootPaneContainer Interface: *
* *
* Methods: *
* getContentPane getRootPane setGlassPane *
* getGlassPane setContentPane setLayeredPane *
* getLayeredPane *
* *
*********************************************************************/
void rootpanecontainer() {
boolean f;
JButton b;
JLayeredPane lp;
JRootPane rp;
java.awt.Container cp;
java.awt.Component gp;
RootPaneContainer rpc = (RootPaneContainer)myFrame;
cp = rpc.getContentPane(); // Returns the contentPane
gp = rpc.getGlassPane(); // Returns the glassPane
lp = rpc.getLayeredPane(); // Returns the layeredPane
rp = rpc.getRootPane(); // Return this component's single JRootPane child
rpc.setContentPane(cp); // The "contentPane" is the primary container for application specific components
rpc.setGlassPane(gp); // The glassPane is always the first child of the rootPane and the rootPanes layout manager ensures that it's always as big as the rootPane
rpc.setLayeredPane(lp); // A Container that manages the contentPane and in some cases a menu bar
}
/*********************************************************************
* *
* JLayeredPane: *
* *
* Fields: *
* DEFAULT_LAYER MODAL_LAYER *
* DRAG_LAYER PALETTE_LAYER *
* FRAME_CONTENT_LAYER POPUP_LAYER *
* LAYER_PROPERTY *
* *
* Methods: *
* $addImpl $insertIndexForLayer *
* getAccessibleContext isOptimizedDrawingEnabled *
* getComponentCountInLayer lowestLayer *
* getComponentsInLayer moveToBack *
* $getComponentToLayer moveToFront *
* getIndexOf paint *
* getLayer $paramString *
* getLayer putLayer *
* getLayeredPaneAbove remove *
* $getObjectForLayer setLayer *
* getPosition setPosition *
* highestLayer *
* *
*********************************************************************/
void jlayeredpane() {
int i;
boolean f;
String s;
java.awt.Component[] cx;
javax.accessibility.AccessibleContext a;
JLayeredPane lp = myFrame.getLayeredPane();
JLayeredPane.putLayer(myButton, 0); // Sets the layer property on a JComponent
i = JLayeredPane.getLayer(myButton); // Gets the layer property for a JComponent, it does not cause any side effects like setLayer()
lp = JLayeredPane.getLayeredPaneAbove(myButton); // Convenience method that returns the first JLayeredPane which contains the specified component
s = JLayeredPane.LAYER_PROPERTY; // Bound property
lp.moveToBack(myButton); // Moves the component to the bottom of the components in it's current layer (position -1)
lp.moveToFront(myButton); // Moves the component to the top of the components in it's current layer (position 0)
lp.paint(myFrame.getGraphics()); // Paints this JLayeredPane within the specified graphics context
//lp.remove(0); // Remove the indexed component from this pane
lp.setLayer(myButton, 10); // Sets the layer attribute on the specified component, making it the bottommost component in that layer
lp.setPosition(myButton, 0); // Moves the component to position within it's current layer, where 0 is the topmost position within the layer and -1 is the bottommost position
lp.setLayer(myButton, 10, 0); // Sets the layer attribute for the specified component and also sets its position within that layer
f = lp.isOptimizedDrawingEnabled(); // Returns false if components in the pane can overlap, which makes optimized drawing impossible
i = lp.highestLayer(); // Returns the highest layer value from all current children
i = lp.lowestLayer(); // Returns the lowest layer value from all current children
i = lp.getIndexOf(myButton); // Returns the index of the specified Component
i = lp.getLayer(myButton); // Returns the layer attribute for the specified Component
if (i == JLayeredPane.DEFAULT_LAYER.intValue()); // 0 Convenience object defining the Default layer
if (i == JLayeredPane.DRAG_LAYER.intValue()); // 400 Convenience object defining the Drag layer
if (i == JLayeredPane.FRAME_CONTENT_LAYER.intValue());// -30000 Convenience object defining the Frame Content layer
if (i == JLayeredPane.MODAL_LAYER.intValue()); // 200 Convenience object defining the Modal layer
if (i == JLayeredPane.PALETTE_LAYER.intValue()); // 100 Convenience object defining the Palette layer
if (i == JLayeredPane.POPUP_LAYER.intValue()); // 300 Convenience object defining the Popup layer
i = lp.getPosition(myButton); // Get the relative position of the component within its layer
i = lp.getComponentCountInLayer(0); // Returns the number of children currently in the specified layer
cx = lp.getComponentsInLayer(0); // Returns an array of the components in the specified layer
a = lp.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
}
/*********************************************************************
* *
* WindowConstants Interface: *
* *
* Fields: *
* DISPOSE_ON_CLOSE DO_NOTHING_ON_CLOSE HIDE_ON_CLOSE *
* *
*********************************************************************/
void windowconstants() {
int i;
i = myFrame.getDefaultCloseOperation();
if (i == WindowConstants.DISPOSE_ON_CLOSE); // The dispose-window default window close operation
if (i == WindowConstants.DO_NOTHING_ON_CLOSE); // The do-nothing default window close operation
if (i == WindowConstants.HIDE_ON_CLOSE); // The hide-window default window close operation
}
/*********************************************************************
* *
* JWindow: *
* *
* Fields: *
* $accessibleContext $rootPaneCheckingEnabled *
* $rootPane *
* *
* Methods: *
* $addImpl $paramString *
* $createRootPane setContentPane *
* getAccessibleContext setGlassPane *
* getContentPane setLayeredPane *
* getGlassPane setLayout *
* getLayeredPane $setRootPane *
* getRootPane $setRootPaneCheckingEnabled *
* $isRootPaneCheckingEnabled $windowInit *
* *
*********************************************************************/
private JWindow myWindow = new JWindow();
void jwindow() {
JRootPane rp;
JLayeredPane lp;
java.awt.Container cp;
java.awt.Component gp;
javax.accessibility.AccessibleContext a;
myWindow.getContentPane().add(new JLabel("Splash Screen"));
myWindow.setBounds(50, 50, 250, 250);
myWindow.setVisible(true);
rp = myWindow.getRootPane(); // Returns the rootPane object for this window
lp = myWindow.getLayeredPane(); // Returns the layeredPane object for this window
cp = myWindow.getContentPane(); // Returns the contentPane object for this window
gp = myWindow.getGlassPane(); // Returns the glassPane object for this window
a = myWindow.getAccessibleContext(); // Get the AccessibleContext associated with this JWindow
myWindow.setLayeredPane(lp); // Sets the layeredPane property
myWindow.setContentPane(cp); // Sets the contentPane property
myWindow.setGlassPane(gp); // Sets the glassPane property
try { Thread.sleep(500); } catch(InterruptedException e) { }
myWindow.setVisible(false);
}
/*********************************************************************
* *
* JApplet: *
* *
* Fields: *
* $accessibleContext $rootPaneCheckingEnabled *
* $rootPane *
* *
* Methods: *
* $addImpl $processKeyEvent *
* $createRootPane setContentPane *
* getAccessibleContext setGlassPane *
* getContentPane setJMenuBar *
* getGlassPane setLayeredPane *
* getJMenuBar setLayout *
* getLayeredPane $setRootPane *
* getRootPane $setRootPaneCheckingEnabled *
* $isRootPaneCheckingEnabled update *
* $paramString *
* *
*********************************************************************/
private JApplet myApplet = new JApplet();
void japplet() {
JRootPane rp;
JLayeredPane lp;
java.awt.Container cp;
java.awt.Component gp;
JMenuBar mb;
javax.accessibility.AccessibleContext a;
myApplet.getContentPane().add(new JLabel("Applet Window"));
myApplet.setBounds(50, 50, 250, 250);
myApplet.setVisible(true);
a = myApplet.getAccessibleContext(); // Get the AccessibleContext associated with this JApplet
rp = myApplet.getRootPane(); // Returns the rootPane object for this applet
lp = myApplet.getLayeredPane(); // Returns the layeredPane object for this applet
cp = myApplet.getContentPane(); // Returns the contentPane object for this applet
gp = myApplet.getGlassPane(); // Returns the glassPane object for this applet
mb = myApplet.getJMenuBar(); // Returns the menubar set on this applet
myApplet.setContentPane(cp); // Sets the contentPane property
myApplet.setGlassPane(gp); // Sets the glassPane property
myApplet.setJMenuBar(mb); // Sets the menubar for this applet
myApplet.setLayeredPane(lp); // Sets the layeredPane property
myApplet.update(myApplet.getGraphics()); // Just calls paint(g)
try { Thread.sleep(500); } catch(InterruptedException e) { }
myApplet.setVisible(false);
}
/*********************************************************************
* *
* JDesktopPane: *
* *
* Methods: *
* getAccessibleContext isOpaque *
* getAllFrames $paramString *
* getAllFramesInLayer setDesktopManager *
* getDesktopManager setUI *
* getUI updateUI *
* getUIClassID *
* *
*********************************************************************/
private JFrame myDesktopFrame = new JFrame("Test Desktop");
private JDesktopPane myDesktopPane = new JDesktopPane();
void jdesktoppane() {
boolean f;
String s;
JInternalFrame[] jif;
DesktopManager dm = myDesktopPane.getDesktopManager();
javax.swing.plaf.DesktopPaneUI ui = new javax.swing.plaf.basic.BasicDesktopPaneUI();
javax.accessibility.AccessibleContext a;
myDesktopPane.setDesktopManager(dm); // Sets the DesktopManger that will handle desktop-specific UI actions
myDesktopPane.setUI(ui); // Sets the L&F object that renders this component
myDesktopPane.updateUI(); // Notification from the UIManager that the L&F has changed
f = myDesktopPane.isOpaque(); // Returns true to indicate that this component paints every pixel in its range
s = myDesktopPane.getUIClassID(); // Returns the name of the L&F class that renders this component
a = myDesktopPane.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
dm = myDesktopPane.getDesktopManager(); // Returns the DesktopManger that handles desktop-specific UI actions
ui = myDesktopPane.getUI(); // Returns the L&F object that renders this component
jif = myDesktopPane.getAllFrames(); // Returns all JInternalFrames currently displayed in the desktop
jif = myDesktopPane.getAllFramesInLayer(0); // Returns all JInternalFrames currently displayed in the specified layer of the desktop
myDesktopFrame.setContentPane(myDesktopPane);
myDesktopFrame.getContentPane().add(myInternalFrame);
myDesktopFrame.setVisible(true);
myDesktopFrame.pack();
myDesktopFrame.setSize(400, 400);
myDesktopFrame.setLocation(100, 100);
jinternalframe();
jinternalframe_jdesktopicon();
desktopmanager();
defaultdesktopmanager();
myDesktopFrame.show();
}
/*********************************************************************
* *
* JInternalFrame: *
* *
* Fields: *
* $closable CONTENT_PANE_PROPERTY *
* $desktopIcon FRAME_ICON_PROPERTY *
* $frameIcon GLASS_PANE_PROPERTY *
* $iconable IS_CLOSED_PROPERTY *
* $isClosed IS_ICON_PROPERTY *
* $isIcon IS_MAXIMUM_PROPERTY *
* $isMaximum IS_SELECTED_PROPERTY *
* $isSelected LAYERED_PANE_PROPERTY *
* $maximizable MENU_BAR_PROPERTY *
* $resizable ROOT_PANE_PROPERTY *
* $rootPane TITLE_PROPERTY *
* $rootPaneCheckingEnabled *
* $title *
* *
* Methods: *
* $addImpl pack *
* addInternalFrameListener $paramString *
* $createRootPane removeInternalFrameListener*
* dispose reshape *
* $fireInternalFrameEvent setBackground *
* getAccessibleContext setClosable *
* getBackground setClosed *
* getContentPane setContentPane *
* getDefaultCloseOperation setDefaultCloseOperation *
* getDesktopIcon setDesktopIcon *
* getDesktopPane setForeground *
* getForeground setFrameIcon *
* getFrameIcon setGlassPane *
* getGlassPane setIcon *
* getJMenuBar setIconifiable *
* getLayer setJMenuBar *
* getLayeredPane setLayer *
* getMenuBar setLayeredPane *
* getRootPane setLayout *
* getTitle setMaximizable *
* getUI setMaximum *
* getUIClassID setMenuBar *
* getWarningString setResizable *
* isClosable $setRootPane *
* isClosed $setRootPaneCheckingEnabled*
* isIcon setSelected *
* isIconifiable setTitle *
* isMaximizable setUI *
* isMaximum setVisible *
* isResizable show *
* $isRootPaneCheckingEnabled toBack *
* isSelected toFront *
* moveToBack updateUI *
* moveToFront *
* *
*********************************************************************/
private JInternalFrame myInternalFrame = new JInternalFrame("Test JInternalFrame", true, true, true, true);
void jinternalframe() {
int i;
boolean f;
String s;
JRootPane rp;
JDesktopPane dp;
JLayeredPane lp = myInternalFrame.getLayeredPane();
java.awt.Container cp = myInternalFrame.getContentPane();
java.awt.Component gp = myInternalFrame.getGlassPane();
JMenuBar mb = myInternalFrame.getJMenuBar();
JInternalFrame.JDesktopIcon di = myInternalFrame.getDesktopIcon();
Icon p = myImageIcon;
java.awt.Color c;
javax.accessibility.AccessibleContext a;
javax.swing.plaf.InternalFrameUI ui = new javax.swing.plaf.metal.MetalInternalFrameUI(myInternalFrame);
myInternalFrame.setBounds(0, 0, 150, 150);
myInternalFrame.getContentPane().add(myLabel);
myInternalFrame.setTitle("Test JInternalFrame"); // Sets the JInternalFrame title
myInternalFrame.reshape(10, 10, 250, 250); // Moves and resizes this component
myInternalFrame.setFrameIcon(p); // Sets an image to be displayed in the titlebar of the frame (usually in the top-left corner)
myInternalFrame.setResizable(true); // Set that the JInternalFrame can be resized by some user action
myInternalFrame.setClosable(true); // Set that this JInternalFrame can be closed by some user action
myInternalFrame.setMaximizable(true); // Set that the JInternalFrame can be maximized by some user action
myInternalFrame.setIconifiable(true); // Set that the JInternalFrame can be made an icon by some user action
myInternalFrame.setVisible(true); // Set the visible state of the object
try {
myInternalFrame.setSelected(true); // Selects and deselects the JInternalFrame
myInternalFrame.setClosed(false); // Calling this method with a value of true to close the frame
myInternalFrame.setMaximum(false); // Maximizes and restores the frame
myInternalFrame.setIcon(false); // Iconizes and deconizes the frame
} catch(java.beans.PropertyVetoException e) {
}
myInternalFrame.setBackground(java.awt.Color.white); // Set the background color of this object
myInternalFrame.setForeground(java.awt.Color.black); // Set the foreground color of this object
myInternalFrame.setDefaultCloseOperation(
myInternalFrame.HIDE_ON_CLOSE); // Sets the operation which will happen by default when the user initiates a "close" on this window
myInternalFrame.setDesktopIcon(di); // Sets the JDesktopIcon associated with this JInternalFrame
myInternalFrame.setContentPane(cp); // Sets this JInternalFrame's content pane
myInternalFrame.setLayeredPane(lp); // Sets this JInternalFrame's layeredPane property
myInternalFrame.setGlassPane(gp); // Sets this JInternalFrame's glassPane property
myInternalFrame.setJMenuBar(mb); // Sets the JMenuBar for this JInternalFrame
myInternalFrame.setLayer(new Integer(10)); // Convenience method for setting the layer attribute of this component
myInternalFrame.moveToBack(); // Convenience method that moves this component to position -1 if it's parent is a JLayeredPane
myInternalFrame.moveToFront(); // Convenience method that moves this component to position 0 if it's parent is a JLayeredPane
myInternalFrame.pack(); // Causes subcomponents of this JInternalFrame to be laid out at their preferred size
myInternalFrame.show(); // Shows this internal frame, and brings it to the front
myInternalFrame.toBack(); // Sends this internal frame to the back
myInternalFrame.toFront(); // Brings this internal frame to the front
//myInternalFrame.dispose(); // Disposes of this internal frame
//???myInternalFrame.setUI(ui); // Sets the UI delegate for this JInternalFrame
//???myInternalFrame.updateUI(); // Notification from the UIManager that the L&F has changed
s = myInternalFrame.getTitle(); // Returns the title of the JInternalFrame
s = myInternalFrame.getUIClassID(); // Returns the name of the L&F class that renders this component
s = myInternalFrame.getWarningString(); // Gets the warning string that is displayed with this window
f = myInternalFrame.isClosable(); // Returns whether this JInternalFrame be closed by some user action
f = myInternalFrame.isClosed(); // Returns whether this JInternalFrame is currently closed
f = myInternalFrame.isIcon(); // Returns whether the JInternalFrame is currently iconified
f = myInternalFrame.isIconifiable(); // Returns whether the JInternalFrame can be iconified by some user action
f = myInternalFrame.isMaximizable(); // Returns whether the JInternalFrame can be maximized by some user action
f = myInternalFrame.isMaximum(); // Returns whether the JInternalFrame is currently maximized
f = myInternalFrame.isResizable(); // Returns whether the JInternalFrame can be resized by some user action
f = myInternalFrame.isSelected(); // Returns whether the JInternalFrame is the currently "selected" or active frame
i = myInternalFrame.getLayer(); // Convenience method for getting the layer attribute of this component
i = myInternalFrame.getDefaultCloseOperation(); // Returns the default operation which occurs when the user initiates a "close" on this window
p = myInternalFrame.getFrameIcon(); // Returns the image displayed in the title bar of the frame (usually in the top-left corner)
c = myInternalFrame.getBackground(); // Get the background color of this object
c = myInternalFrame.getForeground(); // Get the foreground color of this object
dp = myInternalFrame.getDesktopPane(); // Convenience method that searchs the anscestor heirarchy for a JDesktop instance
rp = myInternalFrame.getRootPane(); // Returns the rootPane object for this frame
di = myInternalFrame.getDesktopIcon(); // Returns the JDesktopIcon used when this JInternalFrame is iconified
cp = myInternalFrame.getContentPane();
gp = myInternalFrame.getGlassPane(); // Returns the glassPane object for this frame
lp = myInternalFrame.getLayeredPane(); // Returns the layeredPane object for this frame
mb = myInternalFrame.getJMenuBar(); // Returns the current JMenuBar for this JInternalFrame, or null if no menu bar has been set
a = myInternalFrame.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
ui = myInternalFrame.getUI(); // Returns the L&F object that renders this component
myInternalFrame.getClientProperty(JInternalFrame.CONTENT_PANE_PROPERTY);// Bound property name
myInternalFrame.getClientProperty(JInternalFrame.FRAME_ICON_PROPERTY); // Bound property name
myInternalFrame.getClientProperty(JInternalFrame.GLASS_PANE_PROPERTY); // Bound property name
myInternalFrame.getClientProperty(JInternalFrame.IS_CLOSED_PROPERTY); // Constrained property name indicating that the frame is closed
myInternalFrame.getClientProperty(JInternalFrame.IS_ICON_PROPERTY); // Constrained property name indicating that the frame is iconified
myInternalFrame.getClientProperty(JInternalFrame.IS_MAXIMUM_PROPERTY); // Constrained property name indicating that the frame is maximized
myInternalFrame.getClientProperty(JInternalFrame.IS_SELECTED_PROPERTY); // Constrained property name indicated that this frame has selected status
myInternalFrame.getClientProperty(JInternalFrame.LAYERED_PANE_PROPERTY);// Bound property name
myInternalFrame.getClientProperty(JInternalFrame.MENU_BAR_PROPERTY); // Bound property name
myInternalFrame.getClientProperty(JInternalFrame.ROOT_PANE_PROPERTY); // Bound property name
myInternalFrame.getClientProperty(JInternalFrame.TITLE_PROPERTY); // Bound property name
// This property can be used in Metal L&F to remove thick borders from frame
//myInternalFrame.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
JInternalFrameAdapter adapt = new JInternalFrameAdapter();
myInternalFrame.addInternalFrameListener(adapt); // Adds the specified internal frame listener to receive internal frame events from this internal frame
myInternalFrame.removeInternalFrameListener(adapt); // Removes the specified internal frame listener so that it no longer receives internal frame events from this internal frame
}
class JInternalFrameAdapter implements javax.swing.event.InternalFrameListener {
public void internalFrameClosing(javax.swing.event.InternalFrameEvent e) { }
public void internalFrameOpened(javax.swing.event.InternalFrameEvent e) { }
public void internalFrameActivated(javax.swing.event.InternalFrameEvent e) { }
public void internalFrameClosed(javax.swing.event.InternalFrameEvent e) { }
public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent e) { }
public void internalFrameIconified(javax.swing.event.InternalFrameEvent e) { }
public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent e) { }
}
/*********************************************************************
* *
* JInternalFrame.JDesktopIcon: *
* *
* Methods: *
* getAccessibleContext getUIClassID *
* getDesktopPane setInternalFrame *
* getInternalFrame setUI *
* getUI updateUI *
* *
*********************************************************************/
void jinternalframe_jdesktopicon() {
String s;
JDesktopPane dp;
JInternalFrame fi;
javax.accessibility.AccessibleContext a;
javax.swing.plaf.DesktopIconUI ui = new javax.swing.plaf.metal.MetalDesktopIconUI();
JInternalFrame.JDesktopIcon di = myInternalFrame.getDesktopIcon();
di.setInternalFrame(myInternalFrame); // Sets the JInternalFrame that this DesktopIcon is associated with
di.setUI(ui); // Sets the L&F object that renders this component
di.updateUI(); // Notification from the UIManager that the L&F has changed
dp = di.getDesktopPane(); // Convience method to ask the icon for the Desktop object it belongs to
fi = di.getInternalFrame(); // Returns the JInternalFrame that this DesktopIcon is associated with
a = di.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
s = di.getUIClassID(); // Returns the name of the L&F class that renders this component
ui = di.getUI(); // Returns the L&F object that renders this component
}
/*********************************************************************
* *
* DesktopManager Interface: *
* *
* Methods: *
* activateFrame endResizingFrame *
* beginDraggingFrame iconifyFrame *
* beginResizingFrame maximizeFrame *
* closeFrame minimizeFrame *
* deactivateFrame openFrame *
* deiconifyFrame resizeFrame *
* dragFrame setBoundsForFrame *
* endDraggingFrame *
* *
*********************************************************************/
void desktopmanager() {
DesktopManager dm = myDesktopPane.getDesktopManager();
dm.deactivateFrame(myInternalFrame); // Generally, indicate that this frame has lost focus
dm.activateFrame(myInternalFrame); // Generally, indicate that this frame has focus
//dm.iconifyFrame(myInternalFrame); // Generally, remove this frame from it's parent and add an iconic representation
dm.deiconifyFrame(myInternalFrame); // Generally, remove any iconic representation that is present and restore the frame to it's original size and location
dm.minimizeFrame(myInternalFrame); // Generally, this indicates that the frame should be restored to it's size and position prior to a maximizeFrame() call
//dm.maximizeFrame(myInternalFrame); // Generally, the frame should be resized to match it's parents bounds
//dm.closeFrame(myInternalFrame); // Generally, this call should remove the frame from it's parent
dm.openFrame(myInternalFrame); // If possible, display this frame in an appropriate location
dm.beginResizingFrame(myInternalFrame,
SwingConstants.SOUTH); // This methods is normally called when the user has indicated that they will begin resizing the frame
dm.resizeFrame(myInternalFrame,
300, 300, 50, 50); // The user has resized the component
dm.endResizingFrame(myInternalFrame); // This method signals the end of the resize session
dm.setBoundsForFrame(myInternalFrame,
10, 10, 200, 200); // This is a primative reshape method
dm.beginDraggingFrame(myInternalFrame); // This method is normally called when the user has indicated that they will begin dragging a component around
dm.dragFrame(myInternalFrame, 10, 10); // The user has moved the frame
dm.endDraggingFrame(myInternalFrame); // This method signals the end of the dragging session
}
/*********************************************************************
* *
* DefaultDesktopManager: *
* *
* Methods: *
* activateFrame iconifyFrame *
* beginDraggingFrame maximizeFrame *
* beginResizingFrame minimizeFrame *
* closeFrame openFrame *
* deactivateFrame $removeIconFor *
* deiconifyFrame resizeFrame *
* dragFrame setBoundsForFrame *
* endDraggingFrame $setPreviousBounds *
* endResizingFrame $setWasIcon *
* $getBoundsForIconOf $wasIcon *
* $getPreviousBounds *
* *
*********************************************************************/
void defaultdesktopmanager() {
DefaultDesktopManager dm = (DefaultDesktopManager)myDesktopPane.getDesktopManager();
dm.deactivateFrame(myInternalFrame);
dm.activateFrame(myInternalFrame); // This will activate f moving it to the front
//dm.iconifyFrame(myInternalFrame); // Removes the frame from it's parent and adds it's desktopIcon to the parent
dm.deiconifyFrame(myInternalFrame); // Removes the desktopIcon from it's parent and adds it's frame to the parent
dm.minimizeFrame(myInternalFrame); // Restores the frame back to it's size and position prior to a maximizeFrame() call
//dm.maximizeFrame(myInternalFrame); // Resizes the frame to fill it's parents bounds
//dm.closeFrame(myInternalFrame); // Removes the frame, and if necessary the desktopIcon, from it's parent
dm.openFrame(myInternalFrame); // Normally this method will not be called
dm.beginResizingFrame(myInternalFrame,
SwingConstants.SOUTH);
dm.resizeFrame(myInternalFrame,
300, 300, 50, 50); // Calls setBoundsForFrame() with the new values
dm.endResizingFrame(myInternalFrame);
dm.setBoundsForFrame(myInternalFrame,
10, 10, 200, 200); // This moves the JComponent and repaints the damaged areas
dm.beginDraggingFrame(myInternalFrame);
dm.dragFrame(myInternalFrame, 10, 10); // Calls setBoundsForFrame() with the new values
dm.endDraggingFrame(myInternalFrame);
}
/*********************************************************************
* *
* JDialog: *
* *
* Fields: *
* $accessibleContext $rootPaneCheckingEnabled *
* $rootPane *
* *
* Methods: *
* $addImpl $processWindowEvent *
* $createRootPane setContentPane *
* $dialogInit setDefaultCloseOperation *
* getAccessibleContext setGlassPane *
* getContentPane setJMenuBar *
* getDefaultCloseOperation setLayeredPane *
* getGlassPane setLayout *
* getJMenuBar setLocationRelativeTo *
* getLayeredPane $setRootPane *
* getRootPane $setRootPaneCheckingEnabled *
* $isRootPaneCheckingEnabled update *
* $paramString *
* *
*********************************************************************/
private JDialog myDialog = new JDialog(new JFrame("My Dialog Frame"), "Test Dialog", true);
void jdialog() {
int i;
boolean f;
String s;
JRootPane rp;
JDesktopPane dp;
JLayeredPane lp = myDialog.getLayeredPane();
java.awt.Container cp = myDialog.getContentPane();
java.awt.Component gp = myDialog.getGlassPane();
JMenuBar mb = myDialog.getJMenuBar();
javax.accessibility.AccessibleContext a;
JButton cmrButton = new JButton("Ok");
myDialog.setLocationRelativeTo(myFrame); // Sets the location of the dialog relative to the specified component
myDialog.setDefaultCloseOperation(
myDialog.HIDE_ON_CLOSE); // Sets the operation which will happen by default when the user initiates a "close" on this dialog
myDialog.setContentPane(cp); // Sets the contentPane property
myDialog.setGlassPane(gp); // Sets the glassPane property
myDialog.setLayeredPane(lp); // Sets the layeredPane property
myDialog.setJMenuBar(mb); // Sets the menubar for this dialog
myDialog.update(myDialog.getGraphics()); // Just calls paint(g)
i = myDialog.getDefaultCloseOperation(); // Returns the operation which occurs when the user initiates a "close" on this dialog
a = myDialog.getAccessibleContext(); // Get the AccessibleContext associated with this JDialog
cp = myDialog.getContentPane(); // Returns the contentPane object for this dialog
gp = myDialog.getGlassPane(); // Returns the glassPane object for this dialog
mb = myDialog.getJMenuBar(); // Returns the menubar set on this dialog
lp = myDialog.getLayeredPane(); // Returns the layeredPane object for this dialog
rp = myDialog.getRootPane(); // Returns the rootPane object for this dialog
myDialog.setBounds(100, 50, 200, 750); // Dialog (awt) methods
myDialog.getContentPane().setLayout(new java.awt.FlowLayout());
myDialog.getContentPane().add(cmrButton);
myDialog.pack();
JDialogAdapter adapt = new JDialogAdapter();
cmrButton.addActionListener(adapt);
s = myDialog.getTitle();
f = myDialog.isModal();
f = myDialog.isResizable();
myDialog.setModal(true);
myDialog.setResizable(true);
myDialog.setTitle("My Dialog");
myDialog.show();
myDialog.toFront();
}
class JDialogAdapter implements java.awt.event.ActionListener {
public void actionPerformed(java.awt.event.ActionEvent e) {
myDialog.dispose();
}
}
/*********************************************************************
* *
* JOptionPane: *
* *
* Fields: *
* $icon $options *
* $initialSelectionValue $optionType *
* $initialValue $selectionValues *
* $inputValue $value *
* $message $wantsInput *
* $messageType *
* CANCEL_OPTION OK_OPTION *
* CLOSED_OPTION OPTION_TYPE_PROPERTY *
* DEFAULT_OPTION OPTIONS_PROPERTY *
* ERROR_MESSAGE PLAIN_MESSAGE *
* ICON_PROPERTY QUESTION_MESSAGE *
* INFORMATION_MESSAGE SELECTION_VALUES_PROPERTY *
* INITIAL_SELECTION_VALUE_PROPERTY UNINITIALIZED_VALUE *
* INITIAL_VALUE_PROPERTY VALUE_PROPERTY *
* INPUT_VALUE_PROPERTY WANTS_INPUT_PROPERTY *
* MESSAGE_PROPERTY WARNING_MESSAGE *
* MESSAGE_TYPE_PROPERTY YES_NO_CANCEL_OPTION *
* NO_OPTION YES_NO_OPTION *
* OK_CANCEL_OPTION YES_OPTION *
* *
* Methods: *
* createDialog setIcon *
* createInternalFrame setInitialSelectionValue *
* getAccessibleContext setInitialValue *
* getDesktopPaneForComponent setInputValue *
* getFrameForComponent setMessage *
* getIcon setMessageType *
* getInitialSelectionValue setOptions *
* getInitialValue setOptionType *
* getInputValue setRootFrame *
* getMaxCharactersPerLineCount setSelectionValues *
* getMessage setUI *
* getMessageType setValue *
* getOptions setWantsInput *
* getOptionType showConfirmDialog *
* getRootFrame showInputDialog *
* getSelectionValues showInternalConfirmDialog *
* getUI showInternalInputDialog *
* getUIClassID showInternalMessageDialog *
* getValue showInternalOptionDialog *
* getWantsInput showMessageDialog *
* $paramString showOptionDialog *
* selectInitialValue updateUI *
* *
*********************************************************************/
private JOptionPane myOptionPane = new JOptionPane("myMessage");
void joptionpane() {
boolean f;
int i;
String s;
Object sx;
Icon p;
int msgType;
int optType;
JDialog jd;
JInternalFrame ji;
JDesktopPane dp;
java.awt.Frame mf;
javax.accessibility.AccessibleContext a;
javax.swing.plaf.OptionPaneUI ui = new javax.swing.plaf.basic.BasicOptionPaneUI();
// message types for dialogs
msgType = JOptionPane.ERROR_MESSAGE;
msgType = JOptionPane.INFORMATION_MESSAGE;
msgType = JOptionPane.PLAIN_MESSAGE;
msgType = JOptionPane.QUESTION_MESSAGE;
msgType = JOptionPane.WARNING_MESSAGE;
// option types for dialogs
optType = JOptionPane.DEFAULT_OPTION; // ok only button
optType = JOptionPane.OK_CANCEL_OPTION;
optType = JOptionPane.YES_NO_OPTION;
optType = JOptionPane.YES_NO_CANCEL_OPTION;
// collections used for choice dialogs
Object[] vals = {"First", "Second", "Third"};
Object[] opts = { "A", "B", "C", "D" };
// message dialog
JOptionPane.showMessageDialog(myFrame, "myMessage");
JOptionPane.showMessageDialog(myFrame, "myMessage", "myTitle", msgType);
JOptionPane.showMessageDialog(myFrame, "myMessage", "myTitle", msgType, myImageIcon);
// confirm dialog
i = JOptionPane.showConfirmDialog(myFrame, "myMessage");
i = JOptionPane.showConfirmDialog(myFrame, "myMessage", "myTitle", optType);
i = JOptionPane.showConfirmDialog(myFrame, "myMessage", "myTitle", optType, msgType);
i = JOptionPane.showConfirmDialog(myFrame, "myMessage", "myTitle", optType, msgType, myImageIcon);
// return value from confirm dialog
switch (i) {
case JOptionPane.OK_OPTION: break; // OK is chosen
case JOptionPane.CANCEL_OPTION: break; // CANCEL is chosen
case JOptionPane.CLOSED_OPTION: break; // user closed window without selecting anything
}
switch (i) {
case JOptionPane.YES_OPTION: break; // YES is chosen
case JOptionPane.NO_OPTION: break; // NO is chosen
case JOptionPane.CANCEL_OPTION: break; // CANCEL is chosen
case JOptionPane.CLOSED_OPTION: break; // user closed window without selecting anything
}
// input dialog
s = JOptionPane.showInputDialog("myMessage");
s = JOptionPane.showInputDialog(myFrame, "myMessage");
s = JOptionPane.showInputDialog(myFrame, "myMessage", "myTitle", msgType);
s = (String)JOptionPane.showInputDialog(myFrame, "myMessage", "myTitle",
msgType, myImageIcon, vals, vals[1]);
// return value from input dialog
if (s == JOptionPane.UNINITIALIZED_VALUE); // Indicates that the user has not yet selected a value
// options dialog
i = JOptionPane.showOptionDialog(myFrame, "myMessage", "myTitle",
optType, msgType, myImageIcon, opts, opts[2]);
// message dialog - internal frame
JOptionPane.showInternalMessageDialog(myInternalFrame, "myMessage");
JOptionPane.showInternalMessageDialog(myInternalFrame, "myMessage", "myTitle", msgType);
JOptionPane.showInternalMessageDialog(myInternalFrame, "myMessage", "myTitle", msgType, myImageIcon);
// confirm dialog - internal frame
i = JOptionPane.showInternalConfirmDialog(myInternalFrame, "myMessage");
i = JOptionPane.showInternalConfirmDialog(myInternalFrame, "myMessage", "myTitle", optType);
i = JOptionPane.showInternalConfirmDialog(myInternalFrame, "myMessage", "myTitle", optType, msgType);
i = JOptionPane.showInternalConfirmDialog(myInternalFrame, "myMessage", "myTitle",
optType, msgType, myImageIcon);
// input dialog - internal frame
s = JOptionPane.showInternalInputDialog(myInternalFrame, "myMessage");
s = JOptionPane.showInternalInputDialog(myInternalFrame, "myMessage", "myTitle", msgType);
s = (String)JOptionPane.showInternalInputDialog(myInternalFrame, "myMessage", "myTitle",
msgType, myImageIcon, vals, vals[0]);
// options dialog - internal frame
i = JOptionPane.showInternalOptionDialog(myInternalFrame, "myMessage", "myTitle",
optType, msgType, myImageIcon, opts, opts[0]);
JOptionPane.setRootFrame(myFrame); // Sets the frame to use for class methods in which a frame is not provided
mf = JOptionPane.getRootFrame(); // Returns the Frame to use for the class methods in which a frame is not provided
mf = JOptionPane.getFrameForComponent(myOptionPane); // Returns the specified component's Frame
dp = JOptionPane.getDesktopPaneForComponent(myOptionPane); // Returns the specified component's desktop pane
myOptionPane.setMessage("myMessage"); // Sets the option pane's message-object
myOptionPane.setMessageType(msgType); // Sets the option pane's message type
myOptionPane.setOptionType(optType); // Sets the options to display
myOptionPane.setWantsInput(true); // If newValue is true, a parentComponent is provided to allow the user to input a value
myOptionPane.selectInitialValue(); // Requests that the initial value be selected, which will set focus to the initial value
myOptionPane.setIcon(myImageIcon); // Sets the icon to display
myOptionPane.setUI(ui); // Sets the UI object which implements the L&F for this component
myOptionPane.updateUI(); // Notification from the UIManager that the L&F has changed
// use these for drop down input dialog
myOptionPane.setSelectionValues(vals); // Sets the selection values for a pane that provides the user with a list of items to choose from
myOptionPane.setInitialSelectionValue(vals[1]); // Sets the initial selection value
// use this for setting option buttons
myOptionPane.setOptions(opts); // Sets the options this pane displays
myOptionPane.setInitialValue(opts[2]); // Sets the initial value that is to be enabled -- the Component that has the focus when the pane is initially displayed
//???myOptionPane.setInputValue("hank"); // Sets the user's input-value
//???myOptionPane.setValue(opts[3]); // Sets the value the user has chosen
// JComponent methods
JOptionPaneAdapter adapt = new JOptionPaneAdapter();
myOptionPane.addPropertyChangeListener(adapt);
myOptionPane.removePropertyChangeListener(adapt);
jd = myOptionPane.createDialog(myFrame, "My Title"); // Creates and returns a new JDialog wrapping this centered on the parentComponent in the parentComponent's frame
jd.show();
ji = myOptionPane.createInternalFrame(myInternalFrame, "My Title"); // Creates and returns an instance of JInternalFrame
ji.show();
f = myOptionPane.getWantsInput(); // Returns true if a parentComponent will be provided for the user to input
i = myOptionPane.getMessageType(); // Returns the message type
i = myOptionPane.getOptionType(); // Returns the type of options that are displayed
i = myOptionPane.getMaxCharactersPerLineCount(); // Returns the maximum number of characters to place on a line in a message
s = (String)myOptionPane.getInitialSelectionValue(); // Returns the initial-selection value.
s = (String)myOptionPane.getValue(); // Returns the value the user has selected
s = (String)myOptionPane.getInitialValue(); // Returns the initial value
s = (String)myOptionPane.getInputValue(); // Returns the value the user has input, if wantsInput is true
s = (String)myOptionPane.getMessage(); // Returns the message-object this pane displays
sx = myOptionPane.getSelectionValues(); // Returns the selection values
sx = myOptionPane.getOptions(); // Returns the choices the user can make
p = myOptionPane.getIcon(); // Returns the icon this pane displays
a = myOptionPane.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
s = myOptionPane.getUIClassID(); // Returns the name of the UI class that implements the L&F for this component
ui = myOptionPane.getUI(); // Returns the UI object which implements the L&F for this component
}
class JOptionPaneAdapter implements java.beans.PropertyChangeListener {
public void propertyChange(java.beans.PropertyChangeEvent e) {
// Bound property names
if (e.getPropertyName().equals(JOptionPane.ICON_PROPERTY)) {}
if (e.getPropertyName().equals(JOptionPane.INITIAL_SELECTION_VALUE_PROPERTY)){}
if (e.getPropertyName().equals(JOptionPane.INITIAL_VALUE_PROPERTY)) {}
if (e.getPropertyName().equals(JOptionPane.INPUT_VALUE_PROPERTY)) {}
if (e.getPropertyName().equals(JOptionPane.MESSAGE_PROPERTY)) {}
if (e.getPropertyName().equals(JOptionPane.MESSAGE_TYPE_PROPERTY)) {}
if (e.getPropertyName().equals(JOptionPane.OPTION_TYPE_PROPERTY)) {}
if (e.getPropertyName().equals(JOptionPane.OPTIONS_PROPERTY)) {}
if (e.getPropertyName().equals(JOptionPane.SELECTION_VALUES_PROPERTY)) {}
if (e.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) {}
if (e.getPropertyName().equals(JOptionPane.WANTS_INPUT_PROPERTY)) {}
}
}
/*********************************************************************
* *
* JSplitPane: *
* *
* Fields: *
* $continuousLayout $oneTouchExpandable *
* $dividerSize $orientation *
* $lastDividerLocation $rightComponent *
* $leftComponent *
* BOTTOM HORIZONTAL_SPLIT *
* CONTINUOUS_LAYOUT_PROPERTY LEFT *
* DIVIDER ORIENTATION_PROPERTY *
* DIVIDER_SIZE_PROPERTY RIGHT *
* LAST_DIVIDER_LOCATION_PROPERTY TOP *
* ONE_TOUCH_EXPANDABLE_PROPERTY VERTICAL_SPLIT *
* *
* Methods: *
* $addImpl $paramString *
* getAccessibleContext remove *
* getBottomComponent removeAll *
* getDividerLocation resetToPreferredSizes *
* getDividerSize setBottomComponent *
* getLastDividerLocation setContinuousLayout *
* getLeftComponent setDividerLocation *
* getMaximumDividerLocation setDividerSize *
* getMinimumDividerLocation setLastDividerLocation *
* getOrientation setLeftComponent *
* getRightComponent setOneTouchExpandable *
* getTopComponent setOrientation *
* getUI setRightComponent *
* getUIClassID setTopComponent *
* isContinuousLayout setUI *
* isOneTouchExpandable updateUI *
* $paintChildren *
* *
*********************************************************************/
private JSplitPane mySplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false);
void jsplitpane() {
int i;
boolean f;
String s;
java.awt.Component c;
javax.accessibility.AccessibleContext a;
javax.swing.plaf.SplitPaneUI ui = new javax.swing.plaf.metal.MetalSplitPaneUI();
JLabel tleft = new JLabel("Left");
JLabel bright = new JLabel("Right");
mySplitPane.setMinimumSize(new java.awt.Dimension(10, 10));
mySplitPane.setPreferredSize(new java.awt.Dimension(100, 100));
mySplitPane.setLeftComponent(tleft); // Sets the component to the left (or above) the divider
mySplitPane.setRightComponent(bright); // Sets the component to the right (or below) the divider
mySplitPane.setTopComponent(tleft); // Sets the component above, or to the left of the divider
mySplitPane.setBottomComponent(bright); // Sets the component below, or to the right of the divider
mySplitPane.setOrientation(
JSplitPane.HORIZONTAL_SPLIT); // Sets the orientation, or how the splitter is divided
mySplitPane.setContinuousLayout(false); // Sets whether or not the child components are continuously redisplayed and layed out during user intervention
mySplitPane.setOneTouchExpandable(true); // Determines whether the JSplitPane provides a UI widget on the divider to quickly expand/collapse the divider
mySplitPane.resetToPreferredSizes(); // Messaged to relayout the JSplitPane based on the preferred size of the children components
mySplitPane.setDividerSize(8); // Sets the size of the divider
mySplitPane.setDividerLocation(0.5); // Sets the divider location as a percentage of the JSplitPane's size
mySplitPane.setDividerLocation(50); // Sets the location of the divider
mySplitPane.setLastDividerLocation(50); // Sets the last location the divider was at to newLastLocation
mySplitPane.setUI(ui); // Sets the L&F object that renders this component
mySplitPane.updateUI(); // Notification from the UIManager that the L&F has changed
f = mySplitPane.isContinuousLayout(); // Returns true if the child comopnents are continuously redisplayed and layed out during user intervention
f = mySplitPane.isOneTouchExpandable(); // Returns true if the pane provides a UI widget to collapse/expand the divider
i = mySplitPane.getDividerLocation(); // Returns the location of the divider from the look and feel implementation
i = mySplitPane.getDividerSize(); // Returns the size of the divider
i = mySplitPane.getLastDividerLocation(); // Returns the last location the divider was at
i = mySplitPane.getMaximumDividerLocation(); // Returns the maximum location of the divider from the look and feel implementation
i = mySplitPane.getMinimumDividerLocation(); // Returns the minimum location of the divider from the look and feel implementation
i = mySplitPane.getOrientation(); // Returns the orientation
switch (i) {
case JSplitPane.HORIZONTAL_SPLIT: break; // Horizontal split indicates the Components are split along the x axis, eg the two Components will be split one to the left of the other
case JSplitPane.VERTICAL_SPLIT: break; // Vertical split indicates the Components are split along the y axis, eg the two Components will be split one on top of the other
}
c = mySplitPane.getBottomComponent(); // Returns the component below, or to the right of the divider
c = mySplitPane.getLeftComponent(); // Returns the component to the left (or above) the divider
c = mySplitPane.getRightComponent(); // Returns the component to the right (or below) the divider
c = mySplitPane.getTopComponent(); // Returns the component above, or to the left of the divider
a = mySplitPane.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
s = mySplitPane.getUIClassID(); // Returns the name of the L&F class that renders this component
ui = mySplitPane.getUI(); // Returns the SplitPaneUI that is providing the current look and feel
// JComponent methods
JSplitPaneAdapter adapt = new JSplitPaneAdapter();
mySplitPane.addPropertyChangeListener(adapt);
mySplitPane.removePropertyChangeListener(adapt);
/*
static String JSplitPane.LEFT // Used to add a Component to the left of the other Component
static String JSplitPane.RIGHT // Used to add a Component to the right of the other Component
static String JSplitPane.TOP // Used to add a Component above the other Component
static String JSplitPane.BOTTOM // Used to add a Component below the other Component
static String JSplitPane.DIVIDER // Used to add a Component that will represent the divider
mySplitPane.remove(Component component); // Removes the child component, component from the pane
mySplitPane.remove(int index); // Removes the Component at the specified index
mySplitPane.removeAll(); // Removes all the child components from the receiver
*/
}
class JSplitPaneAdapter implements java.beans.PropertyChangeListener {
public void propertyChange(java.beans.PropertyChangeEvent e) {
// Bound property names
if (e.getPropertyName().equals(JOptionPane.ICON_PROPERTY)) {}
if (e.getPropertyName().equals(JSplitPane.CONTINUOUS_LAYOUT_PROPERTY)) {}
if (e.getPropertyName().equals(JSplitPane.DIVIDER_SIZE_PROPERTY)) {}
if (e.getPropertyName().equals(JSplitPane.LAST_DIVIDER_LOCATION_PROPERTY)) {}
if (e.getPropertyName().equals(JSplitPane.ONE_TOUCH_EXPANDABLE_PROPERTY)) {}
if (e.getPropertyName().equals(JSplitPane.ORIENTATION_PROPERTY)) {}
}
}
/*********************************************************************
* *
* JScrollPane: *
* *
* Fields: *
* $columnHeader $upperLeft *
* $horizontalScrollBar $upperRight *
* $horizontalScrollBarPolicy $verticalScrollBar *
* $lowerLeft $verticalScrollBarPolicy *
* $lowerRight $viewport *
* $rowHeader *
* *
* Methods: *
* createHorizontalScrollBar isValidateRoot *
* createVerticalScrollBar $paramString *
* $createViewport setColumnHeader *
* getAccessibleContext setColumnHeaderView *
* getColumnHeader setCorner *
* getCorner setHorizontalScrollBar *
* getHorizontalScrollBar setHorizontalScrollBarPolicy *
* getHorizontalScrollBarPolicy setLayout *
* getRowHeader setRowHeader *
* getUI setRowHeaderView *
* getUIClassID setUI *
* getVerticalScrollBar setVerticalScrollBar *
* getVerticalScrollBarPolicy setVerticalScrollBarPolicy *
* getViewport setViewport *
* getViewportBorder setViewportBorder *
* getViewportBorderBounds setViewportView *
* isOpaque updateUI *
* *
*********************************************************************/
private JScrollPane myScrollPane = new JScrollPane();
void jscrollpane() {
int i;
boolean f;
String s;
JScrollBar bh;
JScrollBar bv;
JViewport jv;
java.awt.Component c;
java.awt.Rectangle r;
java.awt.LayoutManager lom = myScrollPane.getLayout();
javax.swing.border.Border b;
javax.accessibility.AccessibleContext a;
javax.swing.plaf.ScrollPaneUI ui = new javax.swing.plaf.metal.MetalScrollPaneUI();
String[] vals = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N"};
myScrollPane.setMinimumSize(new java.awt.Dimension(10, 10));
myScrollPane.setPreferredSize(new java.awt.Dimension(100, 100));
// setup using viewport
jv = new JViewport();
jv.setView(new JList(vals));
myScrollPane.setViewport(jv); // Remove the old viewport (if there is one), force the viewPosition of the new viewport to be in the +x,+y quadrant, sync up the row and column headers (if there are any) with the new viewport, and finally sync the scrollbars and headers with the new viewport
jv = new JViewport();
jv.setView(new JLabel("ColA"));
myScrollPane.setColumnHeader(jv); // If an old columnHeader exists, remove it
jv = new JViewport();
jv.setView(new JLabel("RowB"));
myScrollPane.setRowHeader(jv); // If an old rowHeader exists, remove it
// setup using components
myScrollPane.setViewportView(new JList(vals)); // Creates a viewport if neccessary and then sets its view
myScrollPane.setColumnHeaderView(
new JLabel("ColX")); // Creates a column-header viewport if neccessary, sets its view and then adds the column-header viewport to the scrollpane
myScrollPane.setRowHeaderView(
new JLabel("RowX")); // Creates a row-header viewport if neccessary, sets its view and then adds the row-header viewport to the scrollpane
myScrollPane.setCorner(
ScrollPaneConstants.UPPER_LEFT_CORNER,
new JLabel(myImageIcon)); // Adds a child that will appear in one of the scroll panes corners, if there's room
myScrollPane.setViewportBorder(
new javax.swing.border.EtchedBorder()); // Add a border around the viewport
bh = myScrollPane.createHorizontalScrollBar(); // Used by ScrollPaneUI implementations to create the horizontal scrollbar
bv = myScrollPane.createVerticalScrollBar(); // Used by ScrollPaneUI implementations to create the vertical scrollbar
myScrollPane.setHorizontalScrollBar(bh); // Add the scrollbar that controls the viewports horizontal view position to the scrollpane
myScrollPane.setVerticalScrollBar(bv); // Add the scrollbar that controls the viewports vertical view position to the scrollpane
myScrollPane.setHorizontalScrollBarPolicy(
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); // Determines when the horizontal scrollbar appears in the scrollpane
myScrollPane.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); // Determines when the vertical scrollbar appears in the scrollpane
myScrollPane.setLayout(lom); // Sets the layout manager for this JScrollPane
myScrollPane.setUI(ui); // Sets the ScrollPaneUI object that provides the look and feel for this component
myScrollPane.updateUI(); // To be called when the default look and feel changes
jv = myScrollPane.getViewport(); // Returns the current JViewport
jv = myScrollPane.getColumnHeader(); // Returns the column header
jv = myScrollPane.getRowHeader(); // Returns the row header
bh = myScrollPane.getHorizontalScrollBar(); // Returns the horizontal scroll bar
bv = myScrollPane.getVerticalScrollBar(); // Returns the vertical scroll bar
c = myScrollPane.getCorner(
ScrollPaneConstants.UPPER_LEFT_CORNER); // Returns the component at the specified corner
b = myScrollPane.getViewportBorder(); // Returns the value of the viewportBorder property
r = myScrollPane.getViewportBorderBounds(); // Returns the bounds of the viewport border
f = myScrollPane.isOpaque(); // Returns true if this component paints every pixel in its range
f = myScrollPane.isValidateRoot(); // Calls to revalidate() on any descendant of this JScrollPane, e.g
i = myScrollPane.getHorizontalScrollBarPolicy(); // Returns the horizontal scroll bar policy value
switch (i) {
case JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED: break;
case JScrollPane.HORIZONTAL_SCROLLBAR_NEVER: break;
case JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS: break;
}
i = myScrollPane.getVerticalScrollBarPolicy(); // Returns the vertical scroll bar policy value
switch (i) {
case JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED: break;
case JScrollPane.VERTICAL_SCROLLBAR_NEVER: break;
case JScrollPane.VERTICAL_SCROLLBAR_ALWAYS: break;
}
s = myScrollPane.getUIClassID(); // Returns the key used to look up the ScrollPaneUI class that provides the look and feel for JScrollPane
a = myScrollPane.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
ui = myScrollPane.getUI(); // Returns the L&F object that renders this component
}
/*********************************************************************
* *
* ScrollPaneConstants Interface: *
* *
* Fields: *
* COLUMN_HEADER UPPER_LEFT_CORNER *
* HORIZONTAL_SCROLLBAR UPPER_RIGHT_CORNER *
* HORIZONTAL_SCROLLBAR_ALWAYS VERTICAL_SCROLLBAR *
* HORIZONTAL_SCROLLBAR_AS_NEEDED VERTICAL_SCROLLBAR_ALWAYS *
* HORIZONTAL_SCROLLBAR_NEVER VERTICAL_SCROLLBAR_AS_NEEDED *
* HORIZONTAL_SCROLLBAR_POLICY VERTICAL_SCROLLBAR_NEVER *
* LOWER_LEFT_CORNER VERTICAL_SCROLLBAR_POLICY *
* LOWER_RIGHT_CORNER VIEWPORT *
* ROW_HEADER *
* *
*********************************************************************/
void scrollpaneconstants() {
int i;
java.awt.Component c;
ScrollPaneLayout pl = (ScrollPaneLayout)myScrollPane.getLayout();
i = myScrollPane.getHorizontalScrollBarPolicy();
switch (i) {
case ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED: break;
case ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER: break;
case ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS: break;
}
i = myScrollPane.getVerticalScrollBarPolicy();
switch (i) {
case ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED: break;
case ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER: break;
case ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS: break;
}
c = pl.getCorner(ScrollPaneConstants.UPPER_LEFT_CORNER);
c = pl.getCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER);
c = pl.getCorner(ScrollPaneConstants.LOWER_LEFT_CORNER);
c = pl.getCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER);
/*
static String COLUMN_HEADER // Identifies the area at the top the viewport between the upper left corner and the upper right corner
static String VIEWPORT // Identifies a "viewport" or display area, within which scrolled contents are visible
static String ROW_HEADER // Identifies the area along the left side of the viewport between the upper left corner and the lower left corner
static String HORIZONTAL_SCROLLBAR // Identifies a horizonal scrollbar
static String VERTICAL_SCROLLBAR // Identifies a vertical scrollbar
static String HORIZONTAL_SCROLLBAR_POLICY // Identifies the horizontal scroll bar policy property
static String VERTICAL_SCROLLBAR_POLICY // Identifies the vertical scroll bar policy property
*/
}
/*********************************************************************
* *
* ScrollPaneLayout: *
* *
* Fields: *
* $colHead $upperLeft *
* $hsb $upperRight *
* $hsbPolicy $viewport *
* $lowerLeft $vsb *
* $lowerRight $vsbPolicy *
* $rowHead *
* *
* Methods: *
* addLayoutComponent getViewport *
* $addSingletonComponent getViewportBorderBounds *
* getColumnHeader layoutContainer *
* getCorner minimumLayoutSize *
* getHorizontalScrollBar preferredLayoutSize *
* getHorizontalScrollBarPolicy removeLayoutComponent *
* getRowHeader setHorizontalScrollBarPolicy *
* getVerticalScrollBar setVerticalScrollBarPolicy *
* getVerticalScrollBarPolicy syncWithScrollPane *
* *
*********************************************************************/
void scrollpanelayout() {
int i;
JViewport jv;
java.awt.Component c;
JScrollBar b;
ScrollPaneLayout pl = (ScrollPaneLayout)myScrollPane.getLayout();
pl.setHorizontalScrollBarPolicy(
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); // Sets the horizontal scrollbar-display policy
pl.setVerticalScrollBarPolicy(
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); // Sets the vertical scrollbar-display policy
jv = pl.getViewport(); // Returns the JViewport object that displays the scrollable contents
jv = pl.getColumnHeader(); // Returns the JViewport object that is the column header
jv = pl.getRowHeader(); // Returns the JViewport object that is the row header
i = pl.getHorizontalScrollBarPolicy(); // Returns the horizontal scrollbar-display policy
i = pl.getVerticalScrollBarPolicy(); // Returns the vertical scrollbar-display policy
b = pl.getHorizontalScrollBar(); // Returns the JScrollbar object that handles horizontal scrolling
b = pl.getVerticalScrollBar(); // Returns the JScrollbar object that handles vertical scrolling
c = pl.getCorner(
ScrollPaneConstants.UPPER_LEFT_CORNER); // Returns the Component at the specified corner
/*
void addLayoutComponent(String s, Component c); // Adds the specified component to the layout
Rectangle getViewportBorderBounds(JScrollPane scrollpane); // Deprecated. As of JDK version Swing1.1 replaced by JScrollPane.getViewportBorderBounds()
Dimension minimumLayoutSize(Container parent); // The minimum size of a ScrollPane is the size of the insets plus minimum size of the viewport, plus the scrollpane's viewportBorder insets, plus the minimum size of the visible headers, plus the minimum size of the scrollbars whose displayPolicy isn't NEVER
Dimension preferredLayoutSize(Container parent); // The preferred size of a ScrollPane is the size of the insets, plus the preferred size of the viewport, plus the preferred size of the visible headers, plus the preferred size of the scrollbars that will appear given the current view and the current scrollbar displayPolicies
void layoutContainer(Container parent); // Lay out the scrollpane
void removeLayoutComponent(Component c); // Removes the specified component from the layout
void syncWithScrollPane(JScrollPane sp); // This method must be called after setting a JScrollPanes layout manager
*/
}
/*********************************************************************
* *
* Scrollable Interface: *
* *
* Methods: *
* getPreferredScrollableViewportSize *
* getScrollableBlockIncrement *
* getScrollableTracksViewportHeight *
* getScrollableTracksViewportWidth *
* getScrollableUnitIncrement *
* *
*********************************************************************/
void scrollable() {
int i;
boolean f;
java.awt.Dimension d;
Scrollable x = myList;
f = x.getScrollableTracksViewportHeight(); // Return true if a viewport should always force the height of this Scrollable to match the height of the viewport
f = x.getScrollableTracksViewportWidth(); // Return true if a viewport should always force the width of this Scrollable to match the width of the viewport
d = x.getPreferredScrollableViewportSize(); // Returns the preferred size of the viewport for a view component
/*
i = x.getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction); // Components that display logical rows or columns should compute the scroll increment that will completely expose one block of rows or columns, depending on the value of orientation
i = x.getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction); // Components that display logical rows or columns should compute the scroll increment that will completely expose one new row or column, depending on the value of orientation
*/
}
/*********************************************************************
* *
* JViewport: *
* *
* Fields: *
* $backingStore $lastPaintPosition *
* $backingStoreImage $scrollUnderway *
* $isViewSizeSet *
* *
* Methods: *
* addChangeListener paint *
* $addImpl paramString *
* $computeBlit $remove *
* $createLayoutManager removeChangeListener *
* $createViewListener repaint *
* $fireStateChanged reshape *
* getAccessibleContext scrollRectToVisible *
* getExtentSize setBackingStoreEnabled *
* getInsets setBorder *
* getView setExtentSize *
* getViewPosition setView *
* getViewRect setViewPosition *
* getViewSize setViewSize *
* isBackingStoreEnabled toViewCoordinates *
* isOptimizedDrawingEnabled *
* *
*********************************************************************/
void jviewport() {
int i;
boolean f;
java.awt.Component c;
java.awt.Rectangle r;
java.awt.Insets n;
java.awt.Point p;
java.awt.Dimension d;
javax.accessibility.AccessibleContext a;
JViewport jv = myScrollPane.getViewport();
jv.setBackingStoreEnabled(false); // If true if this viewport will maintain an offscreen image of its contents
jv.setViewPosition(
new java.awt.Point(0,0)); // Sets the view coordinates that appear in the upper left hand corner of the viewport, does nothing if there's no view
jv.setExtentSize(
new java.awt.Dimension(-55,-39)); // Set the size of the visible part of the view using view coordinates
jv.setViewSize(
new java.awt.Dimension(11,266)); // Sets the view coordinates that appear in the upper left hand corner of the viewport, and the size of the view
jv.scrollRectToVisible(
new java.awt.Rectangle(0,0,-55,-39)); // Overridden to scroll the view so that Rectangle within the view becomes visible
jv.setBorder(null); // The viewport "scrolls" it's child (called the "view") by the normal parent/child clipping (typically the view is moved in the opposite direction of the scroll)
jv.paint(jv.getGraphics()); // Depending on whether the backingStore is enabled, either paint the image through the backing store or paint just the recently exposed part, using the backing store to "blit" the remainder
f = jv.isBackingStoreEnabled(); // Returns true if this viewport is maintaining an offscreen image of its contents
f = jv.isOptimizedDrawingEnabled(); // The JViewport overrides the default implementation of this method (in JComponent) to return false
c = jv.getView(); // Returns the Viewport's one child or null
n = jv.getInsets(); // Returns the insets (border) dimensions as (0,0,0,0), since borders are not supported on a JViewPort
n = jv.getInsets(n); // Returns an Insets object containing this JViewPort's inset values
p = jv.getViewPosition(); // Returns the view coordinates that appear in the upper left hand corner of the viewport, 0,0 if there's no view
p = jv.toViewCoordinates(p); // Convert a point in pixel coordinates to view coordinates
d = jv.getExtentSize(); // Returns the size of the visible part of the view in view coordinates
d = jv.getViewSize(); // If the view's size hasn't been explicitly set, return the preferred size, otherwise return the view's current size
d = jv.toViewCoordinates(
new java.awt.Dimension(25,25)); // Convert a size in pixel coordinates to view coordinates
r = jv.getViewRect(); // Return a rectangle whose origin is getViewPosition and size is getExtentSize()
a = jv.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
JViewportAdapter adapt = new JViewportAdapter();
jv.addChangeListener(adapt); // Add a ChangeListener to the list that's notified each time the view's size, position, or the viewport's extent size has changed
jv.removeChangeListener(adapt); // Remove a ChangeListener from the list that's notified each time the views size, position, or the viewports extent size has changed
/*
jv.setView(Component view); // Sets the Viewport's one lightweight child (view), which can be null
jv.remove(Component child); // Removes the Viewport's one lightweight child
jv.repaint(long tm, int x, int y, int w, int h); // We always repaint in our parent coordinate system to make sure only one paint is performed by the RepaintManager
jv.reshape(int x, int y, int w, int h); // Sets the bounds of this viewport
*/
}
class JViewportAdapter implements javax.swing.event.ChangeListener {
public void itemStateChanged(java.awt.event.ItemEvent e) { }
public void stateChanged(javax.swing.event.ChangeEvent e) { }
}
/*********************************************************************
* *
* ViewportLayout: *
* *
* Methods: *
* addLayoutComponent preferredLayoutSize *
* layoutContainer removeLayoutComponent *
* minimumLayoutSize *
* *
*********************************************************************/
void viewportlayout() {
ViewportLayout jv = (ViewportLayout)myScrollPane.getViewport().getLayout();
/*
void addLayoutComponent(String name, Component c); // Adds the specified component to the layout
void layoutContainer(Container parent); // Called by the AWT when the specified container needs to be laid out
Dimension minimumLayoutSize(Container parent); // Returns the minimum dimensions needed to layout the components contained in the specified target container
Dimension preferredLayoutSize(Container parent); // Returns the preferred dimensions for this layout given the components in the specified target container
void removeLayoutComponent(Component c); // Removes the specified component from the layout
*/
}
/*********************************************************************
* *
* JTabbedPane: *
* *
* Fields: *
* $changeEvent $model *
* $changeListener $tabPlacement *
* *
* Methods: *
* add indexOfComponent *
* addChangeListener indexOfTab *
* addTab insertTab *
* $createChangeListener isEnabledAt *
* $fireStateChanged $paramString *
* getAccessibleContext remove *
* getBackgroundAt removeAll *
* getBoundsAt removeChangeListener *
* getComponentAt removeTabAt *
* getDisabledIconAt setBackgroundAt *
* getForegroundAt setComponentAt *
* getIconAt setDisabledIconAt *
* getModel setEnabledAt *
* getSelectedComponent setForegroundAt *
* getSelectedIndex setIconAt *
* getTabCount setModel *
* getTabPlacement setSelectedComponent *
* getTabRunCount setSelectedIndex *
* getTitleAt setTabPlacement *
* getToolTipText setTitleAt *
* getUI setUI *
* getUIClassID updateUI *
* *
*********************************************************************/
private JTabbedPane myTabbedPane = new JTabbedPane();
void jtabbedpane() {
int i;
boolean f;
String s;
Icon p;
SingleSelectionModel m = myTabbedPane.getModel();
java.awt.Component c;
java.awt.Color g;
java.awt.Rectangle r;
javax.accessibility.AccessibleContext a;
javax.swing.plaf.TabbedPaneUI ui = new javax.swing.plaf.metal.MetalTabbedPaneUI();
myTabbedPane.setMinimumSize(new java.awt.Dimension(10, 10));
myTabbedPane.setPreferredSize(new java.awt.Dimension(200, 200));
// create some components for the tabs
java.awt.Component tab0 = new JLabel("Tab0");
java.awt.Component tab1 = new JButton("Tab1");
java.awt.Component tab2 = new JCheckBox("Tab2");
java.awt.Component tab3 = new JLabel("Tab3");
java.awt.Component tab4 = new JLabel("Tab4");
java.awt.Component tab5 = new JLabel("Tab5");
myTabbedPane.add(tab0, "Tab #0"); // Adds a component to the tabbed pane
myTabbedPane.add(tab1, "Tab #1", 1); // Adds a component at the specified tab index
myTabbedPane.addTab("Tab #2", tab2); // Adds a component represented by a title and no icon
myTabbedPane.addTab("Tab #3",
myImageIcon, tab3); // Adds a component represented by a title and/or icon, either of which can be null
myTabbedPane.addTab("Tab #4",
myImageIcon, tab4, "Tip #4"); // Adds a component and tip represented by a title and/or icon, either of which can be null
myTabbedPane.insertTab("Tab #5",
myImageIcon, tab5, "Tip #5", 4); // Inserts a component, at index, represented by a title and/or icon, either of which may be null
//myTabbedPane.remove(tab5); // Removes the tab which corresponds to the specified component
//myTabbedPane.removeTabAt(4); // Removes the tab at index
//myTabbedPane.removeAll(); // Removes all the tabs from the tabbedpane
myTabbedPane.setSelectedComponent(tab4); // Sets the selected component for this tabbedpane
myTabbedPane.setSelectedIndex(4); // Sets the selected index for this tabbedpane
myTabbedPane.setTabPlacement(
SwingConstants.TOP); // Sets the tab placement for this tabbedpane
myTabbedPane.setEnabledAt(3, false); // Sets whether or not the tab at index is enabled
myTabbedPane.setForegroundAt(1,
java.awt.Color.red); // Sets the foreground color at index to foreground which can be null, in which case the tab's foreground color will default to the foreground color of this tabbedpane
myTabbedPane.setBackgroundAt(1,
java.awt.Color.green); // Sets the background color at index to background which can be null, in which case the tab's background color will default to the background color of the tabbedpane
myTabbedPane.setComponentAt(1, tab1); // Sets the component at index to component
myTabbedPane.setIconAt(1, myImageIcon); // Sets the icon at index to icon which can be null
myTabbedPane.setDisabledIconAt(2, myImageIcon); // Sets the disabled icon at index to icon which can be null
myTabbedPane.setTitleAt(1, "Tab #1"); // Sets the title at index to title which can be null
myTabbedPane.setModel(m); // Sets the model to be used with this tabbedpane
myTabbedPane.setUI(ui); // Sets the UI object which implements the L&F for this component
myTabbedPane.updateUI(); // Notification from the UIManager that the L&F has changed
f = myTabbedPane.isEnabledAt(1); // Returns whether or not the tab at index is currently enabled
i = myTabbedPane.indexOfComponent(tab1); // Returns the index of the tab for the specified component
i = myTabbedPane.indexOfTab("Tab #1"); // Returns the first tab index with a given title, Returns -1 if no tab has this title
i = myTabbedPane.getSelectedIndex(); // Returns the currently selected index for this tabbedpane
i = myTabbedPane.getTabCount(); // Returns the number of tabs in this tabbedpane
i = myTabbedPane.getTabPlacement(); // Returns the placement of the tabs for this tabbedpane
switch (i) {
case SwingConstants.TOP: break;
case SwingConstants.BOTTOM: break;
case SwingConstants.LEFT: break;
case SwingConstants.RIGHT: break;
}
i = myTabbedPane.getTabRunCount(); // Returns the number of tab runs currently used to display the tabs
s = myTabbedPane.getTitleAt(1); // Returns the tab title at index
c = myTabbedPane.getSelectedComponent(); // Returns the currently selected component for this tabbedpane
c = myTabbedPane.getComponentAt(1); // Returns the component at index
g = myTabbedPane.getBackgroundAt(1); // Returns the tab background color at index
g = myTabbedPane.getForegroundAt(1); // Returns the tab foreground color at index
r = myTabbedPane.getBoundsAt(1); // Returns the tab bounds at index
p = myTabbedPane.getDisabledIconAt(1); // Returns the tab disabled icon at index
p = myTabbedPane.getIconAt(1); // Returns the tab icon at index
m = myTabbedPane.getModel(); // Returns the model associated with this tabbedpane
a = myTabbedPane.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
s = myTabbedPane.getUIClassID(); // Returns the name of the UI class that implements the L&F for this component
ui = myTabbedPane.getUI(); // Returns the UI object which implements the L&F for this component
JTabbedPaneAdapter adapt = new JTabbedPaneAdapter();
myTabbedPane.addChangeListener(adapt); // Adds a ChangeListener to this tabbedpane
myTabbedPane.removeChangeListener(adapt); // Removes a ChangeListener from this tabbedpane
/*
s = myTabbedPane.getToolTipText(MouseEvent event); // Returns the tooltip text for the component determined by the mouse event location
c = myTabbedPane.add(Component component); // Adds a component with a tab title defaulting to the name of the component
c = myTabbedPane.add(Component component, int index); // Adds a component at the specified tab index with a tab title defaulting to the name of the component
c = myTabbedPane.add(String title, Component component); // Adds a component with the specified tab title
*/
}
class JTabbedPaneAdapter implements javax.swing.event.ChangeListener {
public void itemStateChanged(java.awt.event.ItemEvent e) { }
public void stateChanged(javax.swing.event.ChangeEvent e) { }
}
/*********************************************************************
* *
* Box: *
* *
* Fields: *
* $accessibleContext *
* *
* Methods: *
* createGlue createVerticalBox *
* createHorizontalBox createVerticalGlue *
* createHorizontalGlue createVerticalStrut *
* createHorizontalStrut getAccessibleContext *
* createRigidArea setLayout *
* *
*********************************************************************/
private Box myBox = new Box(BoxLayout.X_AXIS);
void box() {
Box b;
java.awt.Component c;
javax.accessibility.AccessibleContext a;
// same as constructor with axis predefined
b = Box.createHorizontalBox(); // Creates a Box that displays its components from left to right
b = Box.createVerticalBox(); // Creates a Box that displays its components from top to bottom
myBox.add(new JButton("Box #1"));
myBox.add(Box.createGlue()); // Creates an invisible "glue" component that can be useful in a Box whose visible components have a maximum width (for a horizontal box) or height (for a vertical box)
myBox.add(Box.createHorizontalGlue()); // Creates a horizontal glue component
myBox.add(Box.createHorizontalStrut(5)); // Creates an invisible, fixed-width component
myBox.add(Box.createRigidArea(
new java.awt.Dimension(5,5))); // Creates an invisible component that's always the specified size
myBox.add(Box.createVerticalGlue()); // Creates a vertical glue component
myBox.add(Box.createVerticalStrut(5)); // Creates an invisible, fixed-height component
a = myBox.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
myBox.add(new JButton("Box #2"));
}
/*********************************************************************
* *
* BoxLayout: *
* *
* Fields: *
* X_AXIS Y_AXIS *
* *
* Methods: *
* addLayoutComponent maximumLayoutSize *
* getLayoutAlignmentX minimumLayoutSize *
* getLayoutAlignmentY preferredLayoutSize *
* invalidateLayout removeLayoutComponent *
* layoutContainer *
* *
*********************************************************************/
void boxlayout() {
float x;
java.awt.Dimension d;
Box b;
BoxLayout bl = (BoxLayout)myBox.getLayout();
new Box(BoxLayout.X_AXIS); // Specifies that components should be laid out left to right
new Box(BoxLayout.Y_AXIS); // Specifies that components should be laid out top to buttom
bl.invalidateLayout(myBox); // Indicates that a child has changed its layout related information, and thus any cached calculations should be flushed
bl.layoutContainer(myBox); // Called by the AWT when the specified container needs to be laid out
x = bl.getLayoutAlignmentX(myBox); // Returns the alignment along the X axis for the container
x = bl.getLayoutAlignmentY(myBox); // Returns the alignment along the Y axis for the container
d = bl.maximumLayoutSize(myBox); // Returns the maximum dimensions the target container can use to lay out the components it contains
d = bl.minimumLayoutSize(myBox); // Returns the minimum dimensions needed to lay out the components contained in the specified target container
d = bl.preferredLayoutSize(myBox); // Returns the preferred dimensions for this layout, given the components in the specified target container
}
/*********************************************************************
* *
* OverlayLayout: *
* *
* Methods: *
* addLayoutComponent maximumLayoutSize *
* getLayoutAlignmentX minimumLayoutSize *
* getLayoutAlignmentY preferredLayoutSize *
* invalidateLayout removeLayoutComponent *
* layoutContainer *
* *
*********************************************************************/
private JPanel myOverlayLayout = new JPanel();
void overlaylayout() {
float x;
java.awt.Dimension d;
OverlayLayout ol = new OverlayLayout(myOverlayLayout);
myOverlayLayout.setLayout(ol);
myOverlayLayout.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.RAISED));
myOverlayLayout.add(new JLabel("Test OverlayLayout"));
ol.invalidateLayout(myOverlayLayout); // Indicates a child has changed its layout related information, which causes any cached calculations to be flushed
ol.layoutContainer(myOverlayLayout); // Called by the AWT when the specified container needs to be laid out
x = ol.getLayoutAlignmentX(myOverlayLayout); // Returns the alignment along the x axis for the container
x = ol.getLayoutAlignmentY(myOverlayLayout); // Returns the alignment along the y axis for the container
d = ol.maximumLayoutSize(myOverlayLayout); // Returns the minimum dimensions needed to lay out the components contained in the specified target container
d = ol.minimumLayoutSize(myOverlayLayout); // Returns the minimum dimensions needed to lay out the components contained in the specified target container
d = ol.preferredLayoutSize(myOverlayLayout); // Returns the preferred dimensions for this layout given the components in the specified target container
}
/*********************************************************************
* *
* SizeRequirements: *
* *
* Fields: *
* alignment minimum *
* maximum preferred *
* *
* Methods: *
* adjustSizes getAlignedSizeRequirements *
* calculateAlignedPositions getTiledSizeRequirements *
* calculateTiledPositions toString *
* *
*********************************************************************/
void sizerequirements() {
int i;
int[] ix = new int[2];
int[] jx = new int[2];
float x;
String s;
SizeRequirements sr;
SizeRequirements[] sx = new SizeRequirements[2];
jx[0] = 1;
jx[1] = 2;
sx[0] = new SizeRequirements(1, 5, 10, 0.25f);
sx[1] = new SizeRequirements(10, 50, 100, 0.5f);
ix = SizeRequirements.adjustSizes(2, sx); // Adjust a specified array of sizes by a given amount
sr = SizeRequirements.getAlignedSizeRequirements(sx); // Determines the total space necessary to align a set of components
sr = SizeRequirements.getTiledSizeRequirements(sx); // Determines the total space necessary to place a set of components end-to-end
//???SizeRequirements.calculateAlignedPositions(100, sr, sx, ix, jx); // Creates a bunch of offset/span pairs specifying how to lay out a set of components with the specified alignments
//???SizeRequirements.calculateTiledPositions(100, sr, sx, ix, jx); // Creates a bunch of offset/span pairs representing how to lay out a set of components end-to-end
i = sx[0].minimum; // The minimum size required
i = sx[0].preferred; // The preferred (natural) size
i = sx[0].maximum; // The maximum size allowed
x = sx[0].alignment; // The alignment, specified as a value between 0.0 and 1.0, inclusive
s = sx[0].toString(); // Returns a string describing the minimum, preferred, and maximum size requirements, along with the alignment
}
/*********************************************************************
* *
* JFileChooser: *
* *
* Fields: *
* ACCESSORY_CHANGED_PROPERTY *
* APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY *
* APPROVE_BUTTON_TEXT_CHANGED_PROPERTY *
* APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY *
* APPROVE_OPTION *
* APPROVE_SELECTION *
* CANCEL_OPTION *
* CANCEL_SELECTION *
* CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY *
* CUSTOM_DIALOG *
* DIALOG_TITLE_CHANGED_PROPERTY *
* DIALOG_TYPE_CHANGED_PROPERTY *
* DIRECTORIES_ONLY *
* DIRECTORY_CHANGED_PROPERTY *
* ERROR_OPTION *
* FILE_FILTER_CHANGED_PROPERTY *
* FILE_HIDING_CHANGED_PROPERTY *
* FILE_SELECTION_MODE_CHANGED_PROPERTY *
* FILE_SYSTEM_VIEW_CHANGED_PROPERTY *
* FILE_VIEW_CHANGED_PROPERTY *
* FILES_AND_DIRECTORIES *
* FILES_ONLY *
* MULTI_SELECTION_ENABLED_CHANGED_PROPERTY *
* OPEN_DIALOG *
* SAVE_DIALOG *
* SELECTED_FILE_CHANGED_PROPERTY *
* SELECTED_FILES_CHANGED_PROPERTY *
* *
* Methods: *
* accept isDirectorySelectionEnabled *
* addActionListener isFileHidingEnabled *
* addChoosableFileFilter isFileSelectionEnabled *
* approveSelection isMultiSelectionEnabled *
* cancelSelection isTraversable *
* changeToParentDirectory $paramString *
* ensureFileIsVisible removeActionListener *
* $fireActionPerformed removeChoosableFileFilter *
* getAcceptAllFileFilter rescanCurrentDirectory *
* getAccessibleContext resetChoosableFileFilters *
* getAccessory setAccessory *
* getApproveButtonMnemonic setApproveButtonMnemonic *
* getApproveButtonText setApproveButtonText *
* getApproveButtonToolTipText setApproveButtonToolTipText *
* getChoosableFileFilters setCurrentDirectory *
* getCurrentDirectory setDialogTitle *
* getDescription setDialogType *
* getDialogTitle setFileFilter *
* getDialogType setFileHidingEnabled *
* getFileFilter setFileSelectionMode *
* getFileSelectionMode setFileSystemView *
* getFileSystemView setFileView *
* getFileView setMultiSelectionEnabled *
* getIcon setSelectedFile *
* getName setSelectedFiles *
* getSelectedFile $setup *
* getSelectedFiles showDialog *
* getTypeDescription showOpenDialog *
* getUI showSaveDialog *
* getUIClassID updateUI *
* *
*********************************************************************/
private JFileChooser myFileChooser = new JFileChooser();
void jfilechooser() {
int i;
boolean f;
String s;
Icon p;
JComponent c;
java.io.File sfile;
java.io.File[] xfile = {new java.io.File("Javax_swing.java"), new java.io.File("Java_awt")};
String[] exts = {"java", "txt"};
javax.swing.filechooser.FileFilter ff;
javax.swing.filechooser.FileFilter[] fx;
javax.swing.filechooser.FileView fv = myFileChooser.getFileView();
javax.swing.filechooser.FileSystemView fs = myFileChooser.getFileSystemView();
javax.accessibility.AccessibleContext a;
javax.swing.plaf.FileChooserUI ui;
myFileChooser.setDialogTitle("My Title"); // Sets the string that goes in the FileChooser window's title bar
myFileChooser.setApproveButtonMnemonic('Y'); // Sets the approve button's mnemonic using a character
myFileChooser.setApproveButtonText("Approve Me"); // Sets the text used in the ApproveButton in the FileChooserUI
myFileChooser.setApproveButtonToolTipText("Ok Tip"); // Sets the tooltip text used in the ApproveButton
myFileChooser.setCurrentDirectory(
new java.io.File("c:/java/Test/Chris/")); // Sets the current directory
myFileChooser.setSelectedFile(
new java.io.File("Javax_swing.java")); // Sets the selected file
myFileChooser.setSelectedFiles(xfile); // Sets the list of selected files if the filechooser is set to allow multi-selection
myFileChooser.setFileFilter(
new CMRFileFilter(exts, "Source Files")); // Sets the current File Filter
myFileChooser.addChoosableFileFilter(
new CMRFileFilter("java", "*.java")); // Adds a filter to the list of user choosable file filters
myFileChooser.setDialogType(
JFileChooser.CUSTOM_DIALOG); // Sets the type of this dialog
myFileChooser.setFileSelectionMode(
JFileChooser.FILES_AND_DIRECTORIES); // Sets the FileChooser to allow the user to just select files, just select directories, or select both files and directetories
myFileChooser.setFileView(fv); // Sets the file view to used to retrieve UI information, such as the icon that represents a file or the type description of a file
myFileChooser.setFileSystemView(fs); // Sets the file system view which the JFileChooser uses to access and create file system resouces, such as finding the floppy drive and getting a list of root drives
myFileChooser.setFileHidingEnabled(false); // Sets file hiding on or off
myFileChooser.setMultiSelectionEnabled(true); // Sets the filechooser to allow multiple file selections (not implemented yet)
myFileChooser.setAccessory(myButton); // Sets the accessory component
myFileChooser.approveSelection(); // Called by the UI when the user hits the approve (AKA "Open" or "Save") button
myFileChooser.cancelSelection(); // Called by the UI when the user hits the cancel button
myFileChooser.changeToParentDirectory(); // Changes the directory to be set to the parent of the current directory
myFileChooser.rescanCurrentDirectory(); // Tells the UI to rescan it's files list from the current directory
myFileChooser.resetChoosableFileFilters(); // Resets the choosable file filter list to it's starting state
myFileChooser.updateUI(); // Notification from the UIFactory that the L&F has changed
i = myFileChooser.showDialog(myFrame, "My Text"); // Pops a custom file chooser dialog with a custom ApproveButton
i = myFileChooser.showOpenDialog(myFrame); // Pops up an "Open File" file chooser dialog
i = myFileChooser.showSaveDialog(myFrame); // Pops up a "Save File" file chooser dialog
switch (i) {
case JFileChooser.APPROVE_OPTION: break; // Return value if approve (yes, ok) is chosen
case JFileChooser.CANCEL_OPTION: break; // Return value if cancel is chosen
case JFileChooser.ERROR_OPTION: break; // Return value if an error occured
}
sfile = myFileChooser.getCurrentDirectory(); // Returns the current directory
sfile = myFileChooser.getSelectedFile(); // Returns the selected file
xfile = myFileChooser.getSelectedFiles(); // Returns a list of selected files if the filechooser is set to allow multi-selection
f = myFileChooser.accept(sfile); // Returns true if the file should be displayed
f = myFileChooser.isTraversable(sfile); // Returns true if the file (directory) can be visited
s = myFileChooser.getDescription(sfile); // Returns the file description
s = myFileChooser.getTypeDescription(sfile); // Returns the file type
s = myFileChooser.getName(sfile); // Returns the file name
myFileChooser.ensureFileIsVisible(
new java.io.File("Javax_swing.java")); // Make sure that the specified file is viewable, and not hidden
f = myFileChooser.isDirectorySelectionEnabled(); // Convenience call that determines if directories are selectable based on the current file selection mode
f = myFileChooser.isFileHidingEnabled(); // If true, hidden files are not shown in the filechooser
f = myFileChooser.isFileSelectionEnabled(); // Convenience call that determines if files are selectable based on the current file selection mode
f = myFileChooser.isMultiSelectionEnabled(); // Returns true if multiple files can be selected
i = myFileChooser.getApproveButtonMnemonic(); // Returns the approve button's mnemonic
i = myFileChooser.getDialogType(); // Returns the type of this dialog
switch (i) {
case myFileChooser.CUSTOM_DIALOG: break; // Type value indicating that the FileChooser supports a developer sepcified file operation
case myFileChooser.OPEN_DIALOG: break; // Type value indicating that the FileChooser supports an "Open" file operation
case myFileChooser.SAVE_DIALOG: break; // Type value indicating that the FileChooser supports a "Save" file operation
}
i = myFileChooser.getFileSelectionMode(); // Returns the current file-selection mode
switch (i) {
case myFileChooser.DIRECTORIES_ONLY: break; // Instruction to display only directories
case myFileChooser.FILES_AND_DIRECTORIES: break; // Instruction to display both files and directories
case myFileChooser.FILES_ONLY: break; // Instruction to display only files
}
ff = myFileChooser.getFileFilter(); // Returns the currently selected file filter
ff = myFileChooser.getAcceptAllFileFilter(); // Returns the AcceptAll file filter
fx = myFileChooser.getChoosableFileFilters(); // Gets the list of user choosable file filters
f = myFileChooser.removeChoosableFileFilter(fx[0]); // Removes a filter from the list of user choosable file filters
fs = myFileChooser.getFileSystemView(); // Returns the file system view
fv = myFileChooser.getFileView(); // Returns the current file view
p = myFileChooser.getIcon(sfile); // Returns the icon for this file or type of file, depending on the system
c = myFileChooser.getAccessory(); // Return the accessory component
s = myFileChooser.getApproveButtonText(); // Returns the text used in the ApproveButton in the FileChooserUI
s = myFileChooser.getApproveButtonToolTipText(); // Returns the tooltip text used in the ApproveButton
s = myFileChooser.getDialogTitle(); // Gets the string that goes in the FileChooser's titlebar
s = myFileChooser.getUIClassID(); // Returns a string that specifies the name of the L&F class that renders this component
a = myFileChooser.getAccessibleContext(); // Get the AccessibleContext associated with this JFileChooser
ui = myFileChooser.getUI(); // Gets the UI object which implements the L&F for this component
JFileChooserAdapter adapt = new JFileChooserAdapter();
myFileChooser.addActionListener(adapt); // adds an ActionListener to the button
myFileChooser.removeActionListener(adapt); // removes an ActionListener from the button
// JComponent methods
myFileChooser.addPropertyChangeListener(adapt);
myFileChooser.removePropertyChangeListener(adapt);
}
class CMRFileFilter extends javax.swing.filechooser.FileFilter {
private String description;
private String[] extensions;
public CMRFileFilter(String exts) {
this (new String[] {exts}, null);
}
public CMRFileFilter(String exts, String desc) {
this (new String[] {exts}, desc);
}
public CMRFileFilter(String[] exts, String desc) {
extensions = new String[exts.length];
for (int i = exts.length - 1; i >= 0; i--) extensions[i] = exts[i].toLowerCase();
description = (desc == null ? exts[0] + " files" : desc);
}
public boolean accept(java.io.File f) {
if (f.isDirectory()) { return true; }
String name = f.getName().toLowerCase();
for (int i = extensions.length - 1; i >= 0; i--) {
if (name.endsWith(extensions[i])) { return true; }
}
return false;
}
public String getDescription() {
return description;
}
}
class JFileChooserAdapter implements java.awt.event.ActionListener, java.beans.PropertyChangeListener {
public void actionPerformed(java.awt.event.ActionEvent e) {
if (e.getSource() == myFileChooser) {
if (e.getActionCommand() == JFileChooser.APPROVE_SELECTION) {} // Instruction to approve the current selection (Same as pressing yes or ok.)
if (e.getActionCommand() == JFileChooser.CANCEL_SELECTION) {} // Instruction to cancel the current selection
}
}
public void propertyChange(java.beans.PropertyChangeEvent e) {
// Bound property names
if (e.getPropertyName().equals(JFileChooser.ACCESSORY_CHANGED_PROPERTY)) {}
if (e.getPropertyName().equals(JFileChooser.APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY)) {}
if (e.getPropertyName().equals(JFileChooser.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY)) {}
if (e.getPropertyName().equals(JFileChooser.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY)) {}
if (e.getPropertyName().equals(JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY)) {}
if (e.getPropertyName().equals(JFileChooser.DIALOG_TITLE_CHANGED_PROPERTY)) {}
if (e.getPropertyName().equals(JFileChooser.DIALOG_TYPE_CHANGED_PROPERTY)) {}
if (e.getPropertyName().equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) {}
if (e.getPropertyName().equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) {}
if (e.getPropertyName().equals(JFileChooser.FILE_HIDING_CHANGED_PROPERTY)) {}
if (e.getPropertyName().equals(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY)) {}
if (e.getPropertyName().equals(JFileChooser.FILE_SYSTEM_VIEW_CHANGED_PROPERTY)) {}
if (e.getPropertyName().equals(JFileChooser.FILE_VIEW_CHANGED_PROPERTY)) {}
if (e.getPropertyName().equals(JFileChooser.MULTI_SELECTION_ENABLED_CHANGED_PROPERTY)) {}
if (e.getPropertyName().equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) {}
if (e.getPropertyName().equals(JFileChooser.SELECTED_FILES_CHANGED_PROPERTY)) {}
}
}
/*********************************************************************
* *
* JColorChooser: *
* *
* Fields: *
* $accessibleContext PREVIEW_PANEL_PROPERTY *
* CHOOSER_PANELS_PROPERTY SELECTION_MODEL_PROPERTY *
* *
* Methods: *
* addChooserPanel $paramString *
* createDialog removeChooserPanel *
* getAccessibleContext setChooserPanels *
* getChooserPanels setColor *
* getColor setPreviewPanel *
* getPreviewPanel setSelectionModel *
* getSelectionModel setUI *
* getUI showDialog *
* getUIClassID updateUI *
* *
*********************************************************************/
private JColorChooser myColorChooser = new JColorChooser();
void jcolorchooser() {
String s;
JDialog d;
JComponent p;
javax.swing.colorchooser.AbstractColorChooserPanel ccp;
javax.swing.colorchooser.AbstractColorChooserPanel[] ccx;
javax.swing.colorchooser.ColorSelectionModel csm;
java.awt.Color c;
javax.accessibility.AccessibleContext a;
javax.swing.plaf.ColorChooserUI ui = new javax.swing.plaf.basic.BasicColorChooserUI();
c = JColorChooser.showDialog(myFrame,
"My Color Chooser", java.awt.Color.red); // Shows a modal color-chooser dialog and blocks until the dialog is hidden
d = JColorChooser.createDialog(myFrame, // Creates and returns a new dialog containing the specified ColorChooser pane along with "OK", "Cancel", and "Reset" buttons
"My Color Chooser", true,
myColorChooser, null, null);
myColorChooser.setColor(java.awt.Color.blue); // Sets the current color of the color chooser to the specified color
myColorChooser.setColor(0x0000ff); // Sets the current color of the color chooser to the specified color
myColorChooser.setColor(0, 0, 255); // Sets the current color of the color chooser to the specified RGB color
myColorChooser.setUI(ui); // Sets the L&F object that renders this component
myColorChooser.updateUI(); // Notification from the UIManager that the L&F has changed
c = myColorChooser.getColor(); // Gets the current color value from the color chooser
p = myColorChooser.getPreviewPanel(); // Returns the preview panel that shows a chosen color
a = myColorChooser.getAccessibleContext(); // Get the AccessibleContext associated with this JColorChooser
s = myColorChooser.getUIClassID(); // Returns the name of the L&F class that renders this component
ui = myColorChooser.getUI(); // Returns the L&F object that renders this component
csm = myColorChooser.getSelectionModel(); // Returns the data model that handles color selections
ccx = myColorChooser.getChooserPanels(); // Returns the specified color panels
//ccp = myColorChooser.removeChooserPanel(ccx[0]);// Removes the Color Panel specified
//myColorChooser.addChooserPanel(ccp); // Adds a color chooser panel to the color chooser
myColorChooser.setChooserPanels(ccx); // Specifies the Color Panels used to choose a color value
myColorChooser.setPreviewPanel(p); // Sets the current preview panel
myColorChooser.setSelectionModel(csm); // Set the model containing the selected color
// JComponent methods
JColorChooserAdapter adapt = new JColorChooserAdapter();
myColorChooser.addPropertyChangeListener(adapt);
myColorChooser.removePropertyChangeListener(adapt);
d.setVisible(true);
}
class JColorChooserAdapter implements java.beans.PropertyChangeListener {
public void propertyChange(java.beans.PropertyChangeEvent e) {
// Bound property names
if (e.getPropertyName().equals(JColorChooser.CHOOSER_PANELS_PROPERTY)) { }
if (e.getPropertyName().equals(JColorChooser.PREVIEW_PANEL_PROPERTY)) { }
if (e.getPropertyName().equals(JColorChooser.SELECTION_MODEL_PROPERTY)) { }
}
}
/*********************************************************************
* *
* JPopupMenu: *
* *
* Methods: *
* add isVisible *
* addPopupMenuListener menuSelectionChanged *
* addSeparator pack *
* $createActionChangeListener $paintBorder *
* $firePopupMenuCanceled $paramString *
* $firePopupMenuWillBecomeInvisible processKeyEvent *
* $firePopupMenuWillBecomeVisible processMouseEvent *
* getAccessibleContext remove *
* getComponent removePopupMenuListener *
* getComponentAtIndex setBorderPainted *
* getComponentIndex setDefaultLightWeight *
* getDefaultLightWeight PopupEnabled *
* PopupEnabled setInvoker *
* getInvoker setLabel *
* getLabel setLightWeightPopupEnabled*
* getMargin setLocation *
* getSelectionModel setPopupSize *
* getSubElements setSelected *
* getUI setSelectionModel *
* getUIClassID setUI *
* insert setVisible *
* isBorderPainted show *
* isLightWeightPopupEnabled updateUI *
* *
*********************************************************************/
private JPopupMenu myPopupMenu = new JPopupMenu("TestPopupMenu");
void jpopupmenu() {
int i;
boolean f;
String s;
JMenuItem mi;
MenuElement[] mex;
java.awt.Component c;
java.awt.Insets n;
javax.accessibility.AccessibleContext a;
SingleSelectionModel ssm = myPopupMenu.getSelectionModel();
javax.swing.plaf.PopupMenuUI ui = new javax.swing.plaf.basic.BasicPopupMenuUI();
myPopupMenu.setDefaultLightWeightPopupEnabled(true); // Set the default value for the lightWeightPopupEnabled property.
f = myPopupMenu.getDefaultLightWeightPopupEnabled(); // Return the default value for the lightWeightPopupEnabled property.
mi = myPopupMenu.add(myAbstractAction); // Append a new menuitem to the end of the menu which dispatches the specified Action object.
mi = myPopupMenu.add(
new JMenuItem("Test Item", myImageIcon)); // Appends the specified menu item to the end of this menu.
c = mi;
myPopupMenu.addSeparator(); // Appends a new separator at the end of the menu.
mi = myPopupMenu.add("StringMenuItem"); // Creates a new menuitem with the specified text and appends it to the end of this menu
myPopupMenu.insert(new JMenuItem("Test ItemX"), 2); // Inserts the specified component into the menu at a given position.
myPopupMenu.setLabel("Popup Label"); // Sets the popup menu's label.
myPopupMenu.setLightWeightPopupEnabled(true); // When displaying the popup, JPopupMenu choose to use a light weight popup if it fits.
myPopupMenu.menuSelectionChanged(true);
myPopupMenu.pack(); // Layout the container so that it uses the minimum space needed to display its contents.
myPopupMenu.setLocation(0, 0); // Set the location of the upper left corner of the popup menu using x, y coordinates.
myPopupMenu.setBorderPainted(true); // Sets whether the border should be painted.
myPopupMenu.setVisible(false); // Set the visibility of the popup menu.
myPopupMenu.setPopupSize(155, 72); // Sets the size of the Popup window to the specified width and height.
myPopupMenu.setPopupSize(
new java.awt.Dimension(155, 72)); // Sets the size of the Popup window using a Dimension object.
myPopupMenu.setInvoker(myFrame); // Sets the invoker of this popupmenu -- the component in which the popupmenu menu is to be displayed.
myPopupMenu.setSelected(c); // Sets the currently selected component, This will result in a change to the selection model.
//myPopupMenu.remove(c); // Removes the specified component from this popup menu.
myPopupMenu.setSelectionModel(ssm); // Set the model object to handle single selections.
myPopupMenu.setUI(ui); // Sets the L&F object that renders this component.
myPopupMenu.updateUI(); // Notification from the UIFactory that the L&F has changed.
f = myPopupMenu.isBorderPainted(); // Checks whether the border should be painted.
f = myPopupMenu.isLightWeightPopupEnabled(); // Returns true if lightweight (all-Java) popups are in use, or false if heavyweight (native peer) popups are being used.
f = myPopupMenu.isVisible(); // Returns true if the popupmenu is visible (currently being displayed).
s = myPopupMenu.getLabel(); // Returns the popup menu's label
n = myPopupMenu.getMargin(); // Returns the margin between the popupmenu's border and its containees.
c = myPopupMenu.getInvoker(); // Returns the component which is the 'invoker' of this popup menu.
c = myPopupMenu.getComponent();
c = myPopupMenu.getComponentAtIndex(0); // Returns the component at the specified index.
i = myPopupMenu.getComponentIndex(c); // Returns the index of the specified component.
ssm = myPopupMenu.getSelectionModel(); // Returns the model object that handles single selections.
mex = myPopupMenu.getSubElements();
a = myPopupMenu.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
s = myPopupMenu.getUIClassID(); // Returns the name of the L&F class that renders this component.
ui = myPopupMenu.getUI(); // Returns the L&F object that renders this component.
JPopupMenuAdapter adapt = new JPopupMenuAdapter();
myFrame.addMouseListener(adapt);
myPopupMenu.addPopupMenuListener(adapt); // Add a PopupMenu listener param l the PopupMenuListener to add
myPopupMenu.removePopupMenuListener(adapt); // Remove a PopupMenu listener param l the PopupMenuListener to remove
/*
myPopupMenu.processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager manager);
myPopupMenu.processMouseEvent(MouseEvent event, MenuElement[] path, MenuSelectionManager manager);
*/
}
class JPopupMenuAdapter implements java.awt.event.MouseListener, javax.swing.event.PopupMenuListener {
public void mousePressed(java.awt.event.MouseEvent e) {
if (e.isPopupTrigger()) {
myPopupMenu.show(myFrame, e.getX(), e.getY()); // Display popupmenu at position
}
}
public void mouseClicked(java.awt.event.MouseEvent e) {
if (e.isPopupTrigger()) {
myPopupMenu.show(myFrame, e.getX(), e.getY());
}
}
public void mouseReleased(java.awt.event.MouseEvent e) {
if (e.isPopupTrigger()) {
myPopupMenu.show(myFrame, e.getX(), e.getY());
}
}
public void mouseEntered(java.awt.event.MouseEvent e) { }
public void mouseExited(java.awt.event.MouseEvent e) { }
public void popupMenuCanceled(javax.swing.event.PopupMenuEvent e) { }
public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent e) { }
public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent e) { }
}
/*********************************************************************
* *
* JMenu: *
* *
* Methods: *
* add insert *
* addMenuListener insertSeparator *
* addSeparator isMenuComponent *
* $createActionChangeListener isPopupMenuVisible *
* $createWinListener isSelected *
* doClick isTearOff *
* $fireMenuCanceled isTopLevelMenu *
* $fireMenuDeselected menuSelectionChanged *
* $fireMenuSelected $paramString *
* getAccessibleContext $processKeyEvent *
* getComponent remove *
* getDelay removeAll *
* getItem removeMenuListener *
* getItemCount setAccelerator *
* getMenuComponent setDelay *
* getMenuComponentCount setMenuLocation *
* getMenuComponents setModel *
* getPopupMenu setPopupMenuVisible *
* getSubElements setSelected *
* getUIClassID updateUI *
* *
*********************************************************************/
private JMenu myMenu = new JMenu("TestMenu");
void jmenu() {
int i;
boolean f;
String s;
JMenuItem mi;
JPopupMenu pop;
MenuElement[] mex;
java.awt.Component c;
java.awt.Component[] cx;
javax.accessibility.AccessibleContext a;
mi = myMenu.add(myAbstractAction); // Creates a new menuitem attached to the specified Action object and appends it to the end of this menu
mi = myMenu.add(myMenuItem); // Appends a menuitem to the end of this menu
myMenu.addSeparator(); // Append a new separator to the end of the menu
mi = myMenu.add("StringMenuItem"); // Creates a new menuitem with the specified text and appends it to the end of this menu
c = myMenu.add(new JButton("a button")); // Appends a component to the end of this menu
myMenu.insert("InsertX", 2); // Insert a new menuitem with the specified text at a given position
mi = myMenu.insert(
new CMRAbstractAction("Test AbstractX"), 2); // Insert a new menuitem attached to the specified Action object at a given position
mi = myMenu.insert(new JMenuItem("Test ItemX"), 2);// Insert the specified JMenuitem at a given position
myMenu.insertSeparator(3); // Inserts a separator at the specified position
myMenu.setSelected(false); // Sets the selection status of the menu
myMenu.menuSelectionChanged(true); // Messaged when the menubar selection changes to activate or deactivate this menu
myMenu.setPopupMenuVisible(false); // Set the visibility of the Menu's popup portion
myMenu.setDelay(200); // Sets the suggested delay before the menu's PopupMenu is popped up or down
myMenu.setMenuLocation(0, 0); // Set the location of the popup component
//??? myMenu.setModel(new DefaultButtonModel()); // Set the data model for the "menu button" -- the label that the user clicks to open or close the menu
//??? myMenu.doClick(1000); // Programatically perform a "click"
myMenu.updateUI(); // Notification from the UIFactory that the L&F has changed
f = myMenu.isPopupMenuVisible(); // Returns true if the menu's popup window is visible
f = myMenu.isSelected(); // Returns true if the menu is currently selected (popped up)
//??? f = myMenu.isTearOff(); // not implemented - test if menu can be torn off
f = myMenu.isTopLevelMenu(); // Returns true if the menu is a 'top-level menu', that is, if it is the direct child of a menubar
f = myMenu.isMenuComponent(myMenuItem); // Returns true if the specified component exists in the submenu hierarchy
i = myMenu.getDelay(); // Returns the suggested delay before the menu's PopupMenu is popped up or down
i = myMenu.getItemCount(); // Returns the number of items on the menu, including separators
i = myMenu.getMenuComponentCount(); // Returns the number of components on the menu
c = myMenu.getComponent(); // This method returns the java.awt.Component used to paint this MenuElement
c = myMenu.getMenuComponent(0); // Returns the component at position n
cx = myMenu.getMenuComponents(); // Returns an array of the menu's subcomponents
mi = myMenu.getItem(0); // Returns the JMenuItem at the specified position
mex = myMenu.getSubElements(); // Returns an array containing the sub-menu components for this menu component
pop = myMenu.getPopupMenu(); // Returns the popupmenu associated with this menu
a = myMenu.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
s = myMenu.getUIClassID(); // Returns the name of the L&F class that renders this component
JMenuAdapter adapt = new JMenuAdapter();
myMenu.addMenuListener(adapt); // Add a listener for menu events
myMenu.removeMenuListener(adapt); // Remove a listener for menu events
/*
myMenu.remove(c); // Removes the Component from this menu
myMenu.remove(mi); // Removes the specified menu item from this menu
myMenu.removeAll(); // Remove all menu items from this menu
*/
}
class JMenuAdapter implements javax.swing.event.MenuListener {
public void menuCanceled(javax.swing.event.MenuEvent e) { }
public void menuDeselected(javax.swing.event.MenuEvent e) { }
public void menuSelected(javax.swing.event.MenuEvent e) { }
}
/*********************************************************************
* *
* AbstractAction: *
* *
* Fields: *
* $changeSupport $enabled *
* *
* Methods: *
* addPropertyChangeListener isEnabled *
* $clone putValue *
* $firePropertyChange removePropertyChangeListener *
* getValue setEnabled *
* *
*********************************************************************/
private AbstractAction myAbstractAction = new CMRAbstractAction("Test Abstract Action");
class CMRAbstractAction extends AbstractAction {
CMRAbstractAction(String text) {
super(text);
this.setEnabled(true); // enables or disables the action
boolean f = this.isEnabled(); // true if the action is enabled
this.putValue("myKey", "myProp"); // Sets the Value associated with the specified key
String s = (String)this.getValue("myKey"); // Gets the Object associated with the specified key
AbstractActionAdapter adapt = new AbstractActionAdapter();
this.addPropertyChangeListener(adapt); // Add a PropertyChangeListener to the listener list
this.removePropertyChangeListener(adapt); // Remove a PropertyChangeListener from the listener list
}
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("AbstractAction=" + e.getActionCommand());
}
}
class AbstractActionAdapter implements java.beans.PropertyChangeListener {
public void propertyChange(java.beans.PropertyChangeEvent e) { }
}
/*********************************************************************
* *
* JMenuBar: *
* *
* Methods: *
* add isManagingFocus *
* addNotify isSelected *
* getAccessibleContext menuSelectionChanged *
* getComponent $paintBorder *
* getComponentAtIndex $paramString *
* getComponentIndex processKeyEvent *
* getHelpMenu processMouseEvent *
* getMargin removeNotify *
* getMenu setBorderPainted *
* getMenuCount setHelpMenu *
* getSelectionModel setMargin *
* getSubElements setSelected *
* getUI setSelectionModel *
* getUIClassID setUI *
* isBorderPainted updateUI *
* *
*********************************************************************/
private JMenuBar myMenuBar = new JMenuBar();
void jmenubar() {
int i;
boolean f;
String s;
JMenu m;
java.awt.Component c;
java.awt.Insets n;
MenuElement[] mex;
javax.accessibility.AccessibleContext a;
SingleSelectionModel ssm = myMenuBar.getSelectionModel();
javax.swing.plaf.MenuBarUI ui = new javax.swing.plaf.basic.BasicMenuBarUI();
myMenuBar.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.RAISED));
myMenuBar.add(myMenu); // Appends the specified menu to the end of the menu bar
myMenuBar.setBorderPainted(true); // Determines whether the MenuBar's current border will be painted
myMenuBar.menuSelectionChanged(true); // Implemented to be a MenuElement -- does nothing
myMenuBar.setMargin(
new java.awt.Insets(0, 0, 0, 0)); // Sets the margin between the menubar's border and its menus
myMenuBar.setSelected(myMenuItem); // Sets the currently selected component, producing a a change to the selection model
myMenuBar.setSelectionModel(ssm); // Set the model object to handle single selections
myMenuBar.setUI(ui); // Sets the L&F object that renders this component
myMenuBar.updateUI(); // Notification from the UIFactory that the L&F has changed
f = myMenuBar.isBorderPainted(); // Returns true if a the Menubar's border should be painted
f = myMenuBar.isManagingFocus(); // Returns true to indicate that this component manages focus events internally
f = myMenuBar.isSelected(); // Returns true if the MenuBar currently has a component selected
i = myMenuBar.getComponentIndex(myMenu); // Returns the index of the specified component
i = myMenuBar.getMenuCount(); // Returns the number of items in the menu bar
m = myMenuBar.getMenu(0); // Gets the menu at the specified position in the menu bar
mex = myMenuBar.getSubElements(); // Implemented to be a MenuElement -- returns the menus in this menu bar
ssm = myMenuBar.getSelectionModel(); // Returns the model object that handles single selections
c = myMenuBar.getComponent(); // Implemented to be a MenuElement
c = myMenuBar.getComponentAtIndex(0); // Returns the component at the specified index
n = myMenuBar.getMargin(); // Returns the margin between the menubar's border and its menus
a = myMenuBar.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
s = myMenuBar.getUIClassID(); // Returns the name of the L&F class that renders this component
ui = myMenuBar.getUI(); // Returns the menubar's current UI
/*
void addNotify(); // Overrides JComponent.addNotify to register this menu bar with the current KeyboardManager
void removeNotify(); // Overrides JComponent.removeNotify to unregister this menu bar with the current KeyboardManager
*/
}
/*********************************************************************
* *
* JMenuItem: *
* *
* Methods: *
* addMenuDragMouseListener isArmed *
* addMenuKeyListener menuSelectionChanged *
* $fireMenuDragMouseDragged $paramString *
* $fireMenuDragMouseEntered processKeyEvent *
* $fireMenuDragMouseExited processMenuDragMouseEvent *
* $fireMenuDragMouseReleased processMenuKeyEvent *
* $fireMenuKeyPressed processMouseEvent *
* $fireMenuKeyReleased removeMenuDragMouseListener *
* $fireMenuKeyTyped removeMenuKeyListener *
* getAccelerator setAccelerator *
* getAccessibleContext setArmed *
* getComponent setEnabled *
* getSubElements setUI *
* getUIClassID updateUI *
* $init *
* *
*********************************************************************/
private JMenuItem myMenuItem = new JMenuItem("Test JMenuItem", myImageIcon);
private JMenuItem mySubMenuItem = new JMenuItem("Test Sub JMenuItem");
void jmenuitem() {
boolean f;
String s;
KeyStroke k;
MenuElement[] mex;
java.awt.Component c;
javax.accessibility.AccessibleContext a;
javax.swing.plaf.MenuItemUI ui = new javax.swing.plaf.basic.BasicMenuItemUI();
myMenuItem.setArmed(true); // Identifies the menu item as "armed"
myMenuItem.setEnabled(true); // Enable or disable the menu item
myMenuItem.menuSelectionChanged(true); // Called by the MenuSelectionManager when the MenuElement is selected or unselected
myMenuItem.setAccelerator(
KeyStroke.getKeyStroke('T',
java.awt.Event.CTRL_MASK, false)); // Set the key combination which invokes the Menu Item's action listeners without navigating the menu hierarchy
myMenuItem.setUI(ui); // Sets the L&F object that renders this component
myMenuItem.updateUI(); // Notification from the UIFactory that the L&F has changed
f = myMenuItem.isArmed(); // Returns whether the menu item is "armed"
mex = myMenuItem.getSubElements(); // This method returns an array containing the sub-menu components for this menu component
k = myMenuItem.getAccelerator(); // Returns the KeyStroke which serves as an accelerator for the menu item
c = myMenuItem.getComponent(); // This method returns the java.awt.Component used to paint this object
s = myMenuItem.getUIClassID(); // Returns the name of the L&F class that renders this component
a = myMenuItem.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
JMenuItemAdapter adapt = new JMenuItemAdapter();
myMenuItem.addMenuDragMouseListener(adapt); // Adds a MenuDragMouseListener to the menu item
myMenuItem.addMenuKeyListener(adapt); // Adds a MenuKeyListener to the menu item
myMenuItem.removeMenuDragMouseListener(adapt); // Removes a MenuDragMouseListener from the menu item
myMenuItem.removeMenuKeyListener(adapt); // Removes a MenuKeyListener from the menu item
/*
myMenuItem.processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager manager); // Process a key event forwarded from the MenuSelectionManager
myMenuItem.processMenuDragMouseEvent(MenuDragMouseEvent e); // Handle mouse drag in a menu
myMenuItem.processMenuKeyEvent(MenuKeyEvent e); // Hanlde a keystroke in a menu
myMenuItem.processMouseEvent(MouseEvent e, MenuElement[] path, MenuSelectionManager manager); // Process a mouse event forwarded from the MenuSelectionManager
*/
}
class JMenuItemAdapter implements javax.swing.event.MenuDragMouseListener,
javax.swing.event.MenuKeyListener {
public void menuDragMouseDragged(javax.swing.event.MenuDragMouseEvent e) { }
public void menuDragMouseEntered(javax.swing.event.MenuDragMouseEvent e) { }
public void menuDragMouseExited(javax.swing.event.MenuDragMouseEvent e) { }
public void menuDragMouseReleased(javax.swing.event.MenuDragMouseEvent e) { }
public void menuKeyPressed(javax.swing.event.MenuKeyEvent e) { }
public void menuKeyReleased(javax.swing.event.MenuKeyEvent e) { }
public void menuKeyTyped(javax.swing.event.MenuKeyEvent e) { }
}
/*********************************************************************
* *
* JSeparator: *
* *
* Methods: *
* getAccessibleContext getUIClassID setOrientation *
* getOrientation isFocusTraversable setUI *
* getUI $paramString updateUI *
* *
*********************************************************************/
private JSeparator mySeparator = new JSeparator(SwingConstants.HORIZONTAL);
void jseparator() {
int i;
boolean f;
String s;
javax.accessibility.AccessibleContext a;
javax.swing.plaf.SeparatorUI ui = new javax.swing.plaf.metal.MetalSeparatorUI();
myMenu.add(mySeparator);
mySeparator.setOrientation(
SwingConstants.HORIZONTAL); // Sets the orientation of the separator.
mySeparator.setUI(ui); // Sets the L&F object that renders this component.
mySeparator.updateUI(); // Notification from the UIFactory that the L&F has changed.
i = mySeparator.getOrientation(); // Returns the orientation of this separator.
f = mySeparator.isFocusTraversable(); // Identifies whether or not this component can receive the focus.
s = mySeparator.getUIClassID(); // Returns the name of the L&F class that renders this component.
a = mySeparator.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
ui = mySeparator.getUI(); // /** Returns the L&F object that renders this component.
}
/*********************************************************************
* *
* JCheckBoxMenuItem: *
* *
* Methods: *
* getAccessibleContext getUIClassID requestFocus *
* getSelectedObjects $init setState *
* getState $paramString updateUI *
* *
*********************************************************************/
private JCheckBoxMenuItem myCheckBoxMenuItem = new JCheckBoxMenuItem("CheckBoxMenuItem", true);
void jcheckboxmenuitem() {
boolean f;
String s;
Object[] ox;
javax.accessibility.AccessibleContext a;
myMenu.add(myCheckBoxMenuItem);
myCheckBoxMenuItem.requestFocus(); // Override JComponent.requestFocus() to prevent grabbing the focus.
myCheckBoxMenuItem.setState(true); // Sets the selected-state of the item.
myCheckBoxMenuItem.updateUI(); // Notification from the UIFactory that the L&F has changed.
a = myCheckBoxMenuItem.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
f = myCheckBoxMenuItem.getState(); // Returns the selected-state of the item.
s = myCheckBoxMenuItem.getUIClassID(); // Returns the name of the L&F class that renders this component.
ox = myCheckBoxMenuItem.getSelectedObjects(); // Returns an array (length 1) containing the checkbox menu item label or null if the checkbox is not selected.
}
/*********************************************************************
* *
* JRadioButtonMenuItem: *
* *
* Methods: *
* getAccessibleContext $init requestFocus *
* getUIClassID $paramString updateUI *
* *
*********************************************************************/
private JRadioButtonMenuItem myRadioButtonMenuItem0 = new JRadioButtonMenuItem("RadioButton #0", true);
private JRadioButtonMenuItem myRadioButtonMenuItem1 = new JRadioButtonMenuItem("RadioButton #1", false);
private ButtonGroup myButtonMenuItemGroup = new ButtonGroup();
void jradiobuttonmenuitem() {
String s;
javax.accessibility.AccessibleContext a;
myButtonGroup.add(myRadioButtonMenuItem0);
myButtonGroup.add(myRadioButtonMenuItem1);
myMenu.add(myRadioButtonMenuItem0);
myMenu.add(myRadioButtonMenuItem1);
myRadioButtonMenuItem0.requestFocus(); // Override Component.requestFocus() to not grab focus.
myRadioButtonMenuItem0.updateUI(); // Notification from the UIFactory that the L&F has changed.
a = myRadioButtonMenuItem0.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
s = myRadioButtonMenuItem0.getUIClassID(); // Returns the name of the L&F class that renders this component.
}
/*********************************************************************
* *
* MenuElement Interface: *
* *
* Methods: *
* getComponent menuSelectionChanged processMouseEvent *
* getSubElements processKeyEvent *
* *
*********************************************************************/
void menuelement() {
myMenu.add(new SliderMenuItem());
}
class SliderMenuItem extends JSlider implements MenuElement {
public SliderMenuItem() {
setBorder(new javax.swing.border.CompoundBorder(new javax.swing.border.TitledBorder("Control"),
new javax.swing.border.EmptyBorder(10, 10, 10, 10)));
setMajorTickSpacing(20);
setMinorTickSpacing(10);
}
// Call by the MenuSelection when the MenuElement is added or remove from the menu selection.
public void menuSelectionChanged(boolean isIncluded) { }
// Process a key event.
public void processKeyEvent(java.awt.event.KeyEvent e, MenuElement[] path, MenuSelectionManager mgr) { }
// Process a mouse event.
public void processMouseEvent(java.awt.event.MouseEvent e, MenuElement[] path, MenuSelectionManager mgr) { }
// This method should return the java.awt.Component used to paint the receiving element.
public java.awt.Component getComponent() { return this; }
// This method should return an array containing the sub-elements for the receiving menu element
public MenuElement[] getSubElements() { return new MenuElement[0]; }
}
/*********************************************************************
* *
* KeyStroke: *
* *
* Methods: *
* equals getKeyStroke hashCode *
* getKeyChar getKeyStrokeForEvent isOnKeyRelease *
* getKeyCode getModifiers toString *
* *
*********************************************************************/
void keystroke() {
int i;
char c;
String s;
boolean f;
KeyStroke k = myMenuItem.getAccelerator();
f = k.equals(myMenuItem.getAccelerator()); // Returns true if this object is identical to the specified object.
f = k.isOnKeyRelease(); // Returns true if this keystroke is active on key release.
c = k.getKeyChar(); // Returns the character defined by this KeyStroke object.
i = k.getKeyCode(); // Returns the numeric keycode defined by this KeyStroke object.
i = k.getModifiers(); // Returns the modifier keys defined by this KeyStroke object.
i = k.hashCode(); // Returns a numeric value for this object that is likely to be reasonably unique, so it can be used as the index value in a Hashtable.
s = k.toString(); // Returns a string that displays and identifies this object's properties.
k = KeyStroke.getKeyStroke('T'); // Return a shared instance of a key stroke that is activated when the key is pressed (i.e.
k = KeyStroke.getKeyStroke(
java.awt.event.KeyEvent.VK_T,
java.awt.Event.CTRL_MASK); // Return a shared instance of a key stroke given a char code and a set of modifiers -- the key is activated when it is pressed.
k = KeyStroke.getKeyStroke(
java.awt.event.KeyEvent.VK_T,
java.awt.Event.CTRL_MASK, false); // Return a shared instance of a key stroke given a numeric keycode and a set of modifiers, specifying whether the key is activated when it is pressed or released.
/*
static KeyStroke getKeyStrokeForEvent(KeyEvent anEvent); // Return a keystroke from an event.
*/
}
/*********************************************************************
* *
* SingleSelectionModel Interface: *
* *
* Methods: *
* addChangeListener getSelectedIndex removeChangeListener *
* clearSelection isSelected setSelectedIndex *
* *
*********************************************************************/
void singleselectionmodel() {
int i;
boolean f;
SingleSelectionModel ssm = myMenuBar.getSelectionModel();
ssm.clearSelection(); // Clears the selection (to -1).
ssm.setSelectedIndex(0); // Sets the model's selected index to index.
f = ssm.isSelected(); // Returns true if the selection model currently has a selected value.
i = ssm.getSelectedIndex(); // Returns the model's selection.
SingleSelectionModelAdapter adapt = new SingleSelectionModelAdapter();
ssm.addChangeListener(adapt); // Adds listener as a listener to changes in the model.
ssm.removeChangeListener(adapt); // Removes listener as a listener to changes in the model.
}
class SingleSelectionModelAdapter implements javax.swing.event.ChangeListener {
public void stateChanged(javax.swing.event.ChangeEvent e) { }
}
/*********************************************************************
* *
* DefaultSingleSelectionModel: *
* *
* Fields: *
* $changeEvent $listenerList *
* *
* Methods: *
* addChangeListener getSelectedIndex setSelectedIndex *
* clearSelection isSelected *
* $fireStateChanged removeChangeListener *
* *
*********************************************************************/
void defaultsingleselectionmodel() {
int i;
boolean f;
DefaultSingleSelectionModel ssm = (DefaultSingleSelectionModel)myMenuBar.getSelectionModel();
ssm.clearSelection();
ssm.setSelectedIndex(0);
f = ssm.isSelected();
i = ssm.getSelectedIndex();
SingleSelectionModelAdapter adapt = new SingleSelectionModelAdapter();
ssm.addChangeListener(adapt); // Adds a ChangeListener to the button.
ssm.removeChangeListener(adapt); // Removes a ChangeListener from the button.
}
/*********************************************************************
* *
* JToolBar: *
* *
* Methods: *
* add isBorderPainted *
* $addImpl isFloatable *
* addSeparator $paintBorder *
* $createActionChangeListener $paramString *
* getAccessibleContext remove *
* getComponentAtIndex setBorderPainted *
* getComponentIndex setFloatable *
* getMargin setMargin *
* getOrientation setOrientation *
* getUI setUI *
* getUIClassID updateUI *
* *
*********************************************************************/
private JToolBar myToolBar = new JToolBar(SwingConstants.HORIZONTAL);
void jtoolbar() {
int i;
boolean f;
String s;
JButton b;
java.awt.Component c;
java.awt.Insets n;
javax.accessibility.AccessibleContext a;
javax.swing.plaf.ToolBarUI ui = new javax.swing.plaf.metal.MetalToolBarUI();
b = myToolBar.add(
new CMRAbstractAction("ToolBar #0")); // Add a new JButton which dispatches the action.
myToolBar.addSeparator(); // Appends a toolbar separator of default size to the end of the toolbar.
myToolBar.add(new CMRAbstractAction("ToolBar #1"));
myToolBar.addSeparator(
new java.awt.Dimension(5, 5)); // Appends a toolbar separator to the end of the toolbar.
myToolBar.add(new CMRAbstractAction("ToolBar #2"));
//myToolBar.remove(b); // Remove the Component from the tool bar.
myToolBar.setBorderPainted(true); // Sets whether the border should be painted.
myToolBar.setFloatable(true); // Sets whether the toolbar can be made to float
myToolBar.setOrientation(
SwingConstants.HORIZONTAL); // Set the orientation of the toolbar
myToolBar.setMargin(
new java.awt.Insets(0, 0, 0, 0)); // Sets the margin between the toolbar's border and its buttons.
myToolBar.setUI(ui); // Sets the L&F object that renders this component.
myToolBar.updateUI(); // Notification from the UIFactory that the L&F has changed.
f = myToolBar.isBorderPainted(); // Checks whether the border should be painted.
f = myToolBar.isFloatable(); // Return true if the Toolbar can be dragged out by the user.
i = myToolBar.getOrientation(); // Returns the current orientation of the toolbar
c = myToolBar.getComponentAtIndex(0); // Returns the component at the specified index.
i = myToolBar.getComponentIndex(c); // Returns the index of the specified component.
n = myToolBar.getMargin(); // Returns the margin between the toolbar's border and its buttons.
a = myToolBar.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
s = myToolBar.getUIClassID(); // Returns the name of the L&F class that renders this component.
ui = myToolBar.getUI(); // Returns the toolbar's current UI.
// for metal l&f, borders will appear with mouseover
myToolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
}
/*********************************************************************
* *
* JToolBar.Separator: *
* *
* Methods: *
* getMaximumSize getPreferredSize getUIClassID *
* getMinimumSize getSeparatorSize setSeparatorSize *
* *
*********************************************************************/
void jtoolbar_separator() {
String s;
java.awt.Dimension d;
JToolBar.Separator jts = new JToolBar.Separator(new java.awt.Dimension(10,10));
myToolBar.add(jts);
jts.setSeparatorSize(new java.awt.Dimension(10,10)); // Set the size of the separator
d = jts.getMaximumSize(); // Return the maximum size for the separator
d = jts.getMinimumSize(); // Return the minimum size for the separator
d = jts.getPreferredSize(); // Return the preferred size for the separator
d = jts.getSeparatorSize(); // Return the size of the separator
s = jts.getUIClassID(); // Returns the name of the L&F class that renders this component.
}
/*********************************************************************
* *
* MenuSelectionManager: *
* *
* Fields: *
* $changeEvent $listenerList *
* *
* Methods: *
* addChangeListener isComponentPartOfCurrentMenu *
* clearSelectedPath processKeyEvent *
* componentForPoint processMouseEvent *
* defaultManager removeChangeListener *
* $fireStateChanged setSelectedPath *
* getSelectedPath *
* *
*********************************************************************/
void menuselectionmanager() {
boolean f;
MenuElement[] mex;
MenuSelectionManager msm;
msm = MenuSelectionManager.defaultManager(); // Returns the default menu selection manager.
/*
f = msm.isComponentPartOfCurrentMenu(Component c); // Return true if c is part of the currently used menu
Component componentForPoint(Component source, Point sourcePoint); // Returns the component in the currently selected path which contains sourcePoint.
mex = msm.getSelectedPath(); // Returns the path to the currently selected menu item
msm.clearSelectedPath(); // Tell the menu selection to close and unselect all the menu components.
msm.processKeyEvent(KeyEvent e); // When a MenuElement receives an event from a KeyListener, it should never process the event directly.
msm.processMouseEvent(MouseEvent event); // When a MenuElement receives an event from a MouseListener, it should never process the event directly.
msm.setSelectedPath(MenuElement[] path); // Change the selection in the menu hierarchy.
msm.addChangeListener(ChangeListener l); // Adds a ChangeListener to the button.
msm.removeChangeListener(ChangeListener l); // Removes a ChangeListener from the button.
*/
}
/*********************************************************************
* *
* JTable: *
* *
* Fields: *
* AUTO_RESIZE_ALL_COLUMNS AUTO_RESIZE_OFF *
* AUTO_RESIZE_LAST_COLUMN AUTO_RESIZE_SUBSEQUENT_COLUMNS*
* AUTO_RESIZE_NEXT_COLUMN *
* $autoCreateColumnsFromModel $gridColor *
* $autoResizeMode $preferredViewportSize *
* $cellEditor $rowHeight *
* $cellSelectionEnabled $rowMargin *
* $columnModel $rowSelectionAllowed *
* $dataModel $selectionBackground *
* $defaultEditorsByColumnClass $selectionForeground *
* $defaultRenderersByColumnClass $selectionModel *
* $editingColumn $showHorizontalLines *
* $editingRow $showVerticalLines *
* $editorComp $tableHeader *
* *
* Methods: *
* addColumn getSelectionBackground *
* addColumnSelectionInterval getSelectionForeground *
* addNotify getSelectionModel *
* addRowSelectionInterval getShowHorizontalLines *
* clearSelection getShowVerticalLines *
* columnAdded getTableHeader *
* columnAtPoint getToolTipText *
* columnMarginChanged getUI *
* columnMoved getUIClassID *
* columnRemoved getValueAt *
* columnSelectionChanged $initializeLocalVars *
* $configureEnclosingScrollPane isCellEditable *
* convertColumnIndexToModel isCellSelected *
* convertColumnIndexToView isColumnSelected *
* $createDefaultColumnModel isEditing *
* createDefaultColumnsFromModel isManagingFocus *
* $createDefaultDataModel isRowSelected *
* $createDefaultEditors moveColumn *
* $createDefaultRenderers $paramString *
* $createDefaultSelectionModel prepareEditor *
* $createDefaultTableHeader prepareRenderer *
* createScrollPaneForTable removeColumn *
* editCellAt removeColumnSelectionInterval*
* editingCanceled removeEditor *
* editingStopped removeRowSelectionInterval *
* getAccessibleContext reshape *
* getAutoCreateColumnsFromModel $resizeAndRepaint *
* getAutoResizeMode rowAtPoint *
* getCellEditor selectAll *
* getCellRect setAutoCreateColumnsFromModel*
* getCellRenderer setAutoResizeMode *
* getCellSelectionEnabled setCellEditor *
* getColumn setCellSelectionEnabled *
* getColumnClass setColumnModel *
* getColumnCount setColumnSelectionAllowed *
* getColumnModel setColumnSelectionInterval *
* getColumnName setDefaultEditor *
* getColumnSelectionAllowed setDefaultRenderer *
* getDefaultEditor setEditingColumn *
* getDefaultRenderer setEditingRow *
* getEditingColumn setGridColor *
* getEditingRow setIntercellSpacing *
* getEditorComponent setModel *
* getGridColor setPreferredScrollable *
* getIntercellSpacing ViewportSize *
* getModel setRowHeight *
* getPreferredScrollable setRowMargin *
* ViewportSize setRowSelectionAllowed *
* getRowCount setRowSelectionInterval *
* getRowHeight setSelectionBackground *
* getRowMargin setSelectionMode *
* getRowSelectionAllowed setSelectionModel *
* getScrollableBlockIncrement setShowGrid *
* getScrollableTracks setShowHorizontalLines *
* ViewportHeight setShowVerticalLines *
* getScrollableTracks setTableHeader *
* ViewportWidth setUI *
* getScrollableUnitIncrement setValueAt *
* getSelectedColumn sizeColumnsToFit *
* getSelectedColumnCount tableChanged *
* getSelectedColumns updateUI *
* getSelectedRow valueChanged *
* getSelectedRowCount *
* getSelectedRows *
* *
*********************************************************************/
private JTable myTable = new JTable(new String[][] {{"This", "is"}, {"a", "Test"}},
new String[] {"Column", "Header"});
void jtable() {
boolean f;
int i;
int[] ix;
String s;
java.awt.Color g;
java.awt.Dimension d;
java.awt.Component c;
javax.accessibility.AccessibleContext a;
ListSelectionModel lsm;
javax.swing.table.TableModel tm;
javax.swing.table.TableColumnModel tcm;
javax.swing.table.TableCellEditor tce;
javax.swing.table.JTableHeader jth;
javax.swing.plaf.TableUI ui = new javax.swing.plaf.basic.BasicTableUI();
myTable.setValueAt("New Value", 1, 1); // Sets the value for the cell at row and column.
myTable.clearSelection(); // Deselects all selected columns and rows.
myTable.selectAll(); // Select all rows, columns and cells in the table.
myTable.setAutoCreateColumnsFromModel(true); // Sets the table's autoCreateColumnsFromModel flag.
myTable.setCellSelectionEnabled(true); // Sets whether this table allows both a column selection and a row selection to exist at the same time.
myTable.setColumnSelectionAllowed(true); // Sets whether the columns in this model can be selected.
myTable.setRowSelectionAllowed(true); // Sets whether the rows in this model can be selected.
myTable.setShowHorizontalLines(true); // Sets whether the receiver draws horizontal lines between cells.
myTable.setShowVerticalLines(true); // Sets whether the receiver draws vertical lines between cells.
myTable.setShowGrid(true); // Sets whether the receiver draws grid lines around cells.
myTable.setAutoResizeMode(
JTable.AUTO_RESIZE_ALL_COLUMNS); // Sets the table's auto resize mode when the table is resized.
myTable.setEditingColumn(1); // Set the editingColumn variable.
myTable.setEditingRow(1); // Set the editingRow variable.
f = myTable.editCellAt(1, 1); // Programmatically starts editing the cell at row and column, if the cell is editable.
myTable.createDefaultColumnsFromModel(); // This method will create default columns for the table from the data model using the getColumnCount() and getColumnClass() methods defined in the TableModel interface.
myTable.setRowHeight(16); // Sets the height for rows to newRowHeight and invokes tile
myTable.setRowMargin(1); // Sets the amount of emtpy space between rows.
myTable.setGridColor(java.awt.Color.black); // Sets the color used to draw grid lines to color and redisplays the receiver.
myTable.setSelectionBackground(java.awt.Color.red); // Set the background color for selected cells.
myTable.setSelectionForeground(java.awt.Color.blue); // Set the foreground color for selected cells.
myTable.moveColumn(1, 0); // Moves the column column to the position currently occupied by the column targetColumn.
myTable.setUI(ui); // Sets the L&F object that renders this component.
myTable.updateUI(); // Notification from the UIManager that the L&F has changed.
f = myTable.getAutoCreateColumnsFromModel(); // Returns whether the table will create default columns from the model.
f = myTable.getCellSelectionEnabled(); // Returns true if simultaneous row and column selections are allowed
f = myTable.getColumnSelectionAllowed(); // Returns true if columns can be selected.
f = myTable.getRowSelectionAllowed(); // Returns true if rows can be selected.
f = myTable.getScrollableTracksViewportHeight(); // Returns false to indicate that the height of the viewport does not determine the height of the table.
f = myTable.getScrollableTracksViewportWidth(); // Returns false to indicate that the width of the viewport does not determine the width of the table.
f = myTable.getShowHorizontalLines(); // Returns true if the receiver draws horizontal lines between cells, false if it doesn't.
f = myTable.getShowVerticalLines(); // Returns true if the receiver draws vertical lines between cells, false if it doesn't.
f = myTable.isEditing(); // Returns true is the table is editing a cell.
f = myTable.isManagingFocus(); // We override this method, whose implementation in JComponent returns false, to return true.
f = myTable.isColumnSelected(1); // Returns true if the column at the specified index is selected
f = myTable.isRowSelected(1); // Returns true if the row at the specified index is selected
f = myTable.isCellEditable(1, 1); // Returns true if the cell at row and column is editable.
f = myTable.isCellSelected(1, 1); // Returns true if the cell at the specified position is selected.
i = myTable.getColumnCount(); // Returns the number of columns in the column model, note this may be different to the number of columns in the table model.
i = myTable.getEditingColumn(); // This returns the index of the editing column.
i = myTable.getEditingRow(); // Returns the index of the editing row.
i = myTable.getAutoResizeMode(); // Returns auto resize mode of the table.
switch (i) {
case JTable.AUTO_RESIZE_ALL_COLUMNS: break; // During all resize operations, proportionately resize all columns
case JTable.AUTO_RESIZE_LAST_COLUMN: break; // During all resize operations, apply adjustments to the last column only
case JTable.AUTO_RESIZE_NEXT_COLUMN: break; // When a column is adjusted in the UI, adjust the next column the opposite way
case JTable.AUTO_RESIZE_OFF: break; // Do not adjust column widths automatically, use a scrollbar
case JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS: break; // During UI adjustment, change subsequent columns to preserve the total width
}
i = myTable.getRowCount(); // Returns the number of rows in the table.
i = myTable.getRowHeight(); // Returns the height of a table row in the receiver.
i = myTable.getRowMargin(); // Gets the amount of emtpy space between rows.
i = myTable.getSelectedColumn(); // Returns the index of the last column selected or added to the selection.
i = myTable.getSelectedColumnCount(); // Returns the number of selected columns.
i = myTable.getSelectedRow(); // Returns the index of the last row selected or added to the selection.
i = myTable.getSelectedRowCount(); // Returns the number of selected rows.
ix = myTable.getSelectedColumns(); // Returns the indices of all selected columns.
ix = myTable.getSelectedRows(); // Returns the indices of all selected rows.
g = myTable.getGridColor(); // Returns the color used to draw grid lines.
g = myTable.getSelectionBackground(); // Returns the background color for selected cells.
g = myTable.getSelectionForeground(); // Returns the foreground color for selected cells.
d = myTable.getIntercellSpacing(); // Returns the horizontal and vertical spacing between cells.
d = myTable.getPreferredScrollableViewportSize(); // Returns the preferred size of the viewport for this table.
s = myTable.getColumnName(1); // Returns the name of the column at the specified view position.
s = myTable.getUIClassID(); // Returns the name of the L&F class that renders this component.
s = (String)myTable.getValueAt(1, 1); // Returns the cell value at row and column.
c = myTable.getEditorComponent(); // If the receiver is currently editing this will return the Component that was returned from the CellEditor.
tm = myTable.getModel(); // Returns the TableModel that provides the data displayed by the receiver.
tcm = myTable.getColumnModel(); // Returns the TableColumnModel that contains all column inforamtion of this table.
tce = myTable.getCellEditor(); // Return the cellEditor.
lsm = myTable.getSelectionModel(); // Returns the ListSelectionModel that is used to maintain row selection state.
jth = myTable.getTableHeader(); // Returns the tableHeader working with this JTable.
ui = myTable.getUI(); // Returns the L&F object that renders this component.
a = myTable.getAccessibleContext(); // Get the AccessibleContext associated with this JComponent
/*
static JScrollPane createScrollPaneForTable(JTable aTable); // Deprecated. As of Swing version 1.0.2, replaced by new JScrollPane(aTable).
int myTable.columnAtPoint(Point point); // Returns the index of the column that point lies in, or -1 if it lies outside the receiver's bounds.
int myTable.convertColumnIndexToModel(int viewColumnIndex); // Return the index of the column in the model whose data is being displayed in the column viewColumnIndex in the display.
int myTable.convertColumnIndexToView(int modelColumnIndex); // Return the index of the column in the view which is displaying the data from the column modelColumnIndex in the model.
boolean myTable.editCellAt(int row, int column, EventObject e); // Programmatically starts editing the cell at row and column, if the cell is editable.
TableCellEditor myTable.getCellEditor(int row, int column); // Return an appropriate editor for the cell specified by this this row and column.
Rectangle myTable.getCellRect(int row, int column, boolean includeSpacing); // Returns a rectangle locating the cell that lies at the intersection of row and column.
TableCellRenderer myTable.getCellRenderer(int row, int column); // Return an appropriate renderer for the cell specified by this this row and column.
TableColumn myTable.getColumn(Object identifier); // Returns the TableColumn object for the column in the table whose identifier is equal to identifier, when compared using equals().
Class myTable.getColumnClass(int column); // Returns the type of the column at the specified view position.
TableCellEditor myTable.getDefaultEditor(Class columnClass); // Returns the editor to be used when no editor has been set in a TableColumn.
TableCellRenderer myTable.getDefaultRenderer(Class columnClass); // Returns the renderer to be used when no renderer has been set in a TableColumn.
int myTable.getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction); // Returns The visibleRect.height or visibleRect.width, depending on the table's orientation.
int myTable.getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction); // Returns the scroll increment that completely exposes one new row or column (depending on the orientation).
String myTable.getToolTipText(MouseEvent event); // Overrides JComponent's setToolTipText method to allow use of the renderer's tips (if the renderer has text set).
Component myTable.prepareEditor(TableCellEditor editor, int row, int column); // Prepares the specified editor using the value at the specified cell.
Component myTable.prepareRenderer(TableCellRenderer renderer, int row, int column); // Prepares the specified renderer with an appropriate value from the dataModel, and an appropriate selection value from the selection models.
int myTable.rowAtPoint(Point point); // Returns the index of the row that point lies in, or -1 if is not in the range [0, getRowCount()-1].
myTable.setColumnSelectionInterval(int index0, int index1); // Selects the columns from index0 to index1 inclusive.
myTable.setRowSelectionInterval(int index0, int index1); // Selects the rows from index0 to index1 inclusive.
myTable.setSelectionMode(int selectionMode); // Sets the table's selection mode to allow only single selections, a single contiguous interval, or multiple intervals.
myTable.addColumn(new javax.swing.table.TableColumn()); // Appends aColumn to the end of the array of columns held by the JTable's column model.
myTable.removeColumn(TableColumn aColumn); // Removes aColumn from the JTable's array of columns.
myTable.addColumnSelectionInterval(int index0, int index1); // Adds the columns from index0 to index0 inclusive to the current selection.
myTable.removeColumnSelectionInterval(int index0, int index1); // Deselects the columns from index0 to index0 inclusive.
myTable.addNotify(); // Calls configureEnclosingScrollPane.
myTable.addRowSelectionInterval(int index0, int index1); // Adds the rows from index0 to index0 inclusive to the current selection.
myTable.columnAdded(TableColumnModelEvent e); // Tells listeners that a column was added to the model.
myTable.columnMarginChanged(ChangeEvent e); // Tells listeners that a column was moved due to a margin change.
myTable.columnMoved(TableColumnModelEvent e); // Tells listeners that a column was repositioned.
myTable.columnRemoved(TableColumnModelEvent e); // Tells listeners that a column was removed from the model.
myTable.columnSelectionChanged(ListSelectionEvent e); // Tells listeners that the selection model of the TableColumnModel changed.
myTable.editingCanceled(ChangeEvent e); // Invoked when editing is canceled.
myTable.editingStopped(ChangeEvent e); // Invoked when editing is finished.
myTable.removeEditor(); // Discard the editor object and return the real estate it used to cell rendering.
myTable.removeRowSelectionInterval(int index0, int index1); // Deselects the rows from index0 to index0 inclusive.
myTable.reshape(int x, int y, int width, int height); // Calls super.reshape(), and is overridden simply to detect changes in our bounds.
myTable.setCellEditor(TableCellEditor anEditor); // Set the cellEditor variable.
myTable.setColumnModel(TableColumnModel newModel); // Sets the column model for this table to newModel and registers with for listner notifications from the new column model.
myTable.setDefaultEditor(Class columnClass, TableCellEditor editor); // Set a default editor to be used if no editor has been set in a TableColumn.
myTable.setDefaultRenderer(Class columnClass, TableCellRenderer renderer); // Set a default renderer to be used if no renderer has been set in a TableColumn.
myTable.setIntercellSpacing(Dimension newSpacing); // Sets the width and height between cells to newSpacing and redisplays the receiver.
myTable.setModel(TableModel newModel); // Sets the data model for this table to newModel and registers with for listner notifications from the new data model.
myTable.setPreferredScrollableViewportSize(Dimension size); // Sets the preferred size of the viewport for this table.
myTable.setSelectionModel(ListSelectionModel newModel); // Sets the row selection model for this table to newModel and registers with for listner notifications from the new selection model.
myTable.setTableHeader(JTableHeader newHeader); // Sets the tableHeader working with this JTable to newHeader.
myTable.sizeColumnsToFit(int resizingColumn); // This method will resize one or more ot the columns in the table so that the total width of all of the JTable's columns will be equal to the width of the table.
myTable.tableChanged(TableModelEvent e); // The TableModelEvent should be constructed in the co-ordinate system of the model, the appropriate mapping to the view co-ordinate system is performed by the JTable when it recieves the event.
myTable.valueChanged(ListSelectionEvent e); // Invoked when the selection changes -- repaints to show the new selection.
*/
}
/*********************************************************************
* *
* JTextField: Text component - allows editing line of text *
* *
* Fields: *
* notifyAction *
* *
* Methods: *
* addActionListener getUIClassID *
* $createDefaultModel isValidateRoot *
* $fireActionPerformed $paramString *
* getAccessibleContext postActionEvent *
* getActions removeActionListener *
* getColumns scrollRectToVisible *
* $getColumnWidth setActionCommand *
* getHorizontalAlignment setColumns *
* getHorizontalVisibility setFont *
* getPreferredSize setHorizontalAlignment *
* getScrollOffset setScrollOffset *
* *
*********************************************************************/
private JTextField myTextField = new JTextField(20);
void jtextfield() {
int i;
String s;
boolean f;
BoundedRangeModel m;
java.awt.Dimension d;
javax.accessibility.AccessibleContext a;
java.awt.Font font = new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12);
s = JTextField.notifyAction; // name of action to send notification
myTextField.setColumns(20); // sets number of columns
myTextField.setFont(font); // Sets the current font
myTextField.setHorizontalAlignment(
JTextField.LEFT); // Sets the horizontal alignment of the text
i = myTextField.getColumns(); // gets number of columns
d = myTextField.getPreferredSize(); // gets preferred size of this text field
f = myTextField.isValidateRoot(); // Calls to revalidate that come from within the textfield itself will be handled by validating the textfield
i = myTextField.getHorizontalAlignment(); // Returns the horizontal alignment of the text
i = myTextField.getScrollOffset(); // Gets the scroll offset
s = myTextField.getUIClassID(); // Gets the class ID for a UI
a = myTextField.getAccessibleContext(); // Get the AccessibleContext associated with this JTextField
m = myTextField.getHorizontalVisibility(); // Gets the visibility of the text field
JTextFieldAdapter adapt = new JTextFieldAdapter();
myTextField.addActionListener(adapt); // recieve action events from this text field
//myTextField.removeActionListener(adapt); // removes the specified action listener
/*
Action[] getActions() // Fetches the command list for the editor
void postActionEvent() // Processes action events occurring on this textfield by dispatching them to any registered ActionListener objects
void scrollRectToVisible(Rectangle r) // Scrolls the field left or right
void setActionCommand(String command) // Sets the command string used for action events
void setScrollOffset(int scrollOffset) // Sets the scroll offset
*/
}
class JTextFieldAdapter implements java.awt.event.ActionListener, java.awt.event.TextListener {
public void actionPerformed(java.awt.event.ActionEvent e) {
if (e.getSource() == myTextField) { System.out.println("JTextField actionPerformed"); }
}
public void textValueChanged(java.awt.event.TextEvent e) {
if (e.getSource() == myTextField) { System.out.println("JTextField textValueChanged"); }
}
}
/*********************************************************************
* *
* JTextArea: Multi-line region that displays text (can allow edit) *
* *
* Methods: *
* append getScrollableUnitIncrement*
* $createDefaultModel getTabSize *
* getAccessibleContext getUIClassID *
* getColumns getWrapStyleWord *
* $getColumnWidth insert *
* getLineCount isManagingFocus *
* getLineEndOffset $paramString *
* getLineOfOffset $processComponentKeyEvent *
* getLineStartOffset replaceRange *
* getLineWrap setColumns *
* getPreferredScrollableViewportSize setFont *
* getPreferredSize setLineWrap *
* $getRowHeight setRows *
* getRows setTabSize *
* getScrollableTracksViewportWidth setWrapStyleWord *
* *
*********************************************************************/
private JTextArea myTextArea = new JTextArea(5, 20);
void jtextarea() {
int i;
boolean f;
String s;
java.awt.Dimension d;
myTextArea.append("Hello world"); // appends the given text to the text area's current text
myTextArea.insert(" to my ", 6); // inserts text at the specified position in text area
myTextArea.replaceRange("J",0,1); // replaces text b/t start and end with replacement text
myTextArea.setRows(5); // sets the number of rows for this text area
myTextArea.setColumns(20); // sets the number of columns for this text area
i = myTextArea.getRows(); // gets the number of rows in the text area
i = myTextArea.getColumns(); // gets the number of columns in this text area
s = myTextArea.getUIClassID(); // Returns the class ID for the UI
f = myTextArea.getLineWrap(); // Gets the line-wrapping policy of the text area
f = myTextArea.getScrollableTracksViewportWidth(); // Returns true if a viewport should always force the width of this Scrollable to match the width of the viewport
f = myTextArea.getWrapStyleWord(); // Get the style of wrapping used if the text area is wrapping lines
f = myTextArea.isManagingFocus(); // Turns off tab traversal once focus gained
i = myTextArea.getLineCount(); // Determines the number of lines contained in the area
i = myTextArea.getTabSize(); // Gets the number of characters used to expand tabs
d = myTextArea.getPreferredSize(); // determines the preferred size of this text area
try {
i = myTextArea.getLineOfOffset(1); // Translates an offset into the components text to a line number
//i = myTextArea.getLineEndOffset(1); // Determines the offset of the end of the given line
//i = myTextArea.getLineStartOffset(1); // Determines the offset of the start of the given line
} catch(javax.swing.text.BadLocationException e) {
System.out.println(e);
}
/*
i = myTextArea.getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction); // Components that display logical rows or columns should compute the scroll increment that will completely expose one new row or column, depending on the value of orientation
AccessibleContext getAccessibleContext(); // Get the AccessibleContext associated with this JTextArea
Dimension getPreferredScrollableViewportSize(); // Returns the preferred size of the viewport if this component is embedded in a JScrollPane
void setFont(Font f); // Sets the current font
void setLineWrap(boolean wrap); // Sets the line-wrapping policy of the text area
void setTabSize(int size); // Sets the number of characters to expand tabs to
void setWrapStyleWord(boolean word); // Set the style of wrapping used if the text area is wrapping lines
*/
}
/*********************************************************************
* *
* javax.swing.text.JTextComponent: *
* *
* Desc: Superclass of components that allow text editing *
* *
* Fields: *
* DEFAULT_KEYMAP FOCUS_ACCELERATOR_KEY *
* *
* Methods: *
* addCaretListener moveCaretPosition *
* addKeymap $paramString *
* copy paste *
* cut $processComponentKeyEvent *
* $fireCaretUpdate $processInputMethodEvent *
* getAccessibleContext read *
* getActions removeCaretListener *
* getCaret removeKeymap *
* getCaretColor removeNotify *
* getCaretPosition replaceSelection *
* getDisabledTextColor select *
* getDocument selectAll *
* getFocusAccelerator setCaret *
* getHighlighter setCaretColor *
* getInputMethodRequests setCaretPosition *
* getKeymap setDisabledTextColor *
* getMargin setDocument *
* getPreferredScrollableViewportSize setEditable *
* getScrollableBlockIncrement setEnabled *
* getScrollableTracksViewportHeight setFocusAccelerator *
* getScrollableTracksViewportWidth setHighlighter *
* getScrollableUnitIncrement setKeymap *
* getSelectedText setMargin *
* getSelectedTextColor setOpaque *
* getSelectionColor setSelectedTextColor *
* getSelectionEnd setSelectionColor *
* getSelectionStart setSelectionEnd *
* getText setSelectionStart *
* getUI setText *
* isEditable setUI *
* isFocusTraversable updateUI *
* isOpaque viewToModel *
* loadKeymap write *
* modelToView *
* *
*********************************************************************/
void jtextcomponent() {
int i;
boolean f;
String s;
myTextField.setText("Chris"); // sets text that is presented by this text component
myTextField.setEditable(true); // sets flag that determines whether or not editable
myTextField.selectAll(); // selects all the text
myTextField.setSelectionStart(1); // sets selection start
myTextField.setSelectionEnd(3); // sets selection end
myTextField.setCaretPosition(4); // sets position of the text insertion caret
s = myTextField.getText(); // gets the text
f = myTextField.isEditable(); // indicates whether or not this text component is editable
s = myTextField.getSelectedText(); // gets selected text
i = myTextField.getSelectionEnd(); // gets the end position of the selected text
i = myTextField.getSelectionStart(); // gets the start position of the selected text
i = myTextField.getCaretPosition(); // gets the position of the text insertion caret
/*
static String DEFAULT_KEYMAP // This is the name of the default keymap that will be shared by all JTextComponent instances unless they have had a different keymap set
static String FOCUS_ACCELERATOR_KEY // The bound property name for the focus accelerator
void addCaretListener(CaretListener listener); // Adds a caret listener for notification of any changes to the caret
static Keymap addKeymap(String nm, Keymap parent); // Adds a new keymap into the keymap hierarchy
void copy(); // Transfers the currently selected range in the associated text model to the system clipboard, leaving the contents in the text model
void cut(); // Transfers the currently selected range in the associated text model to the system clipboard, removing the contents from the model
AccessibleContext getAccessibleContext(); // Gets the AccessibleContext associated with this JComponent
Action[] getActions(); // Fetches the command list for the editor
Caret getCaret(); // Fetches the caret that allows text-oriented navigation over the view
Color getCaretColor(); // Fetches the current color used to render the caret
Color getDisabledTextColor(); // Fetches the current color used to render the selected text
Document getDocument(); // Fetches the model associated with the editor
char getFocusAccelerator(); // Returns the key accelerator that will cause the receiving text component to get the focus
Highlighter getHighlighter(); // Fetches the object responsible for making highlights
InputMethodRequests getInputMethodRequests(); //
Keymap getKeymap(); // Fetches the keymap currently active in this text component
static Keymap getKeymap(String nm); // Fetches a named keymap previously added to the document
Insets getMargin(); // Returns the margin between the text component's border and its text
Dimension getPreferredScrollableViewportSize(); // Returns the preferred size of the viewport for a view component
int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction); // Components that display logical rows or columns should compute the scroll increment that will completely expose one block of rows or columns, depending on the value of orientation
boolean getScrollableTracksViewportHeight(); // Return true if a viewport should always force the height of this Scrollable to match the height of the viewport
boolean getScrollableTracksViewportWidth(); // Return true if a viewport should always force the width of this Scrollable to match the width of the viewport
int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction); // Components that display logical rows or columns should compute the scroll increment that will completely expose one new row or column, depending on the value of orientation
Color getSelectedTextColor(); // Fetches the current color used to render the selected text
Color getSelectionColor(); // Fetches the current color used to render the selection
String getText(int offs, int len); // Fetches a portion of the text represented by the component
TextUI getUI(); // Fetches the user-interface factory for this text-oriented editor
boolean isFocusTraversable(); // Returns true if the focus can be traversed
boolean isOpaque(); // Returns true if this component is completely opaque
static void loadKeymap(Keymap map, JTextComponent.KeyBinding[] bindings, Action[] actions); // Loads a keymap with a bunch of bindings
Rectangle modelToView(int pos); // Converts the given location in the model to a place in the view coordinate system
void moveCaretPosition(int pos); // Moves the caret to a new position, leaving behind a mark defined by the last time setCaretPosition was called
void paste(); // Transfers the contents of the system clipboard into the associated text model
void read(Reader in, Object desc); // Initializes from a stream
void removeCaretListener(CaretListener listener); // Removes a caret listener
static Keymap removeKeymap(String nm); // Removes a named keymap previously added to the document
void removeNotify(); // Notifies this component that it has been removed from its container
void replaceSelection(String content); // Replaces the currently selected content with new content represented by the given string
void select(int selectionStart, int selectionEnd); // Selects the text found between the specified start and end locations
void setCaret(Caret c); // Sets the caret to be used
void setCaretColor(Color c); // Sets the current color used to render the caret
void setDisabledTextColor(Color c); // Sets the current color used to render the disabled text
void setDocument(Document doc); // Associates the editor with a text document
void setEnabled(boolean b); // Enables or disables this component, depending on the value of the parameter b
void setFocusAccelerator(char aKey); // Sets the key accelerator that will cause the receiving text component to get the focus
void setHighlighter(Highlighter h); // Sets the highlighter to be used
void setKeymap(Keymap map); // Sets the keymap to use for binding events to actions
void setMargin(Insets m); // Sets margin space between the text component's border and its text
void setOpaque(boolean o); // Sets whether or not the UI should render a background
void setSelectedTextColor(Color c); // Sets the current color used to render the selected text
void setSelectionColor(Color c); // Sets the current color used to render the selection
void setUI(TextUI ui); // Sets the user-interface factory for this text-oriented edito
void updateUI(); // Reloads the pluggable UI
int viewToModel(Point pt); // Converts the given place in the view coordinate system to the nearest representative location in the model
void write(Writer out); // Stores the contents of the model into the given stream
*/
}
/*********************************************************************
* *
* BorderFactory: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void borderfactory() {
/*
*/
}
/*********************************************************************
* *
* DebugGraphics: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void debuggraphics() {
/*
*/
}
/*********************************************************************
* *
* DefaultFocusManager: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void defaultfocusmanager() {
/*
*/
}
/*********************************************************************
* *
* FocusManager: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void focusmanager() {
/*
*/
}
/*********************************************************************
* *
* GrayFilter: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void grayfilter() {
/*
*/
}
/*********************************************************************
* *
* JEditorPane: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void jeditorpane() {
/*
*/
}
/*********************************************************************
* *
* JPasswordField: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void jpasswordfield() {
/*
*/
}
/*********************************************************************
* *
* JTextPane: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void jtextpane() {
/*
*/
}
/*********************************************************************
* *
* JToolTip: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void jtooltip() {
/*
*/
}
/*********************************************************************
* *
* LookAndFeel: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void lookandfeel() {
/*
*/
}
/*********************************************************************
* *
* RepaintManager: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void repaintmanager() {
/*
*/
}
/*********************************************************************
* *
* SwingUtilities: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void swingutilities() {
/*
*/
}
/*********************************************************************
* *
* Timer: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void timer() {
/*
*/
}
/*********************************************************************
* *
* ToolTipManager: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void tooltipmanager() {
/*
*/
}
/*********************************************************************
* *
* UIDefaults: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void uidefaults() {
/*
*/
}
/*********************************************************************
* *
* UIManager: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void uimanager() {
/*
*/
}
/*********************************************************************
* *
* UIManager.LookAndFeelInfo: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void uimanager_lookandfeelinfo() {
/*
*/
}
/*********************************************************************
* *
* Action Interface: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void action() {
/*
*/
}
/*********************************************************************
* *
* Renderer Interface: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void renderer() {
/*
*/
}
/*********************************************************************
* *
* UIDefaults.ActiveValue Interface: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void uidefaults_activevalue() {
/*
*/
}
/*********************************************************************
* *
* UIDefaults.LazyValue Interface: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void uidefaults_lazyvalue() {
/*
*/
}
/*********************************************************************
* *
* CellEditor Interface: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void celleditor() {
/*
*/
}
/*********************************************************************
* *
* CellRendererPane: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void cellrendererpane() {
/*
*/
}
/*********************************************************************
* *
* DefaultCellEditor: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void defaultcelleditor() {
/*
*/
}
/*********************************************************************
* *
* JTree: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void jtree() {
/*
*/
}
/*********************************************************************
* *
* JTree.DynamicUtilTreeNode: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void jtree_dynamicutiltreenode() {
/*
*/
}
/*********************************************************************
* *
* JTree.EmptySelectionModel: *
* *
* Desc: *
* *
* Methods: *
* x y z *
* *
*********************************************************************/
void jtree_emptyselectionmodel() {
/*
*/
}
}