Imported GNU Classpath 0.90

Imported GNU Classpath 0.90
       * scripts/makemake.tcl: Set gnu/java/awt/peer/swing to ignore.
       * gnu/classpath/jdwp/VMFrame.java (SIZE): New constant.
       * java/lang/VMCompiler.java: Use gnu.java.security.hash.MD5.
       * java/lang/Math.java: New override file.
       * java/lang/Character.java: Merged from Classpath.
       (start, end): Now 'int's.
       (canonicalName): New field.
       (CANONICAL_NAME, NO_SPACES_NAME, CONSTANT_NAME): New constants.
       (UnicodeBlock): Added argument.
       (of): New overload.
       (forName): New method.
       Updated unicode blocks.
       (sets): Updated.
       * sources.am: Regenerated.
       * Makefile.in: Likewise.

From-SVN: r111942
This commit is contained in:
Mark Wielaard
2006-03-10 21:46:48 +00:00
parent 27079765d0
commit 8aa540d2f7
1367 changed files with 188789 additions and 22762 deletions
+4 -1
View File
@@ -95,7 +95,10 @@ $(EXAMPLE_ZIP): $(EXAMPLE_JAVA_FILES)
mkdir -p classes/gnu/classpath/examples/icons
cp $(EXAMPLE_ICONS) classes/gnu/classpath/examples/icons
$(JCOMPILER) -d classes $(EXAMPLE_JAVA_FILES)
cd classes; $(ZIP) -r ../$(EXAMPLE_ZIP) .; cd ..
(cd classes; \
if test "$(ZIP)" != ""; then $(ZIP) -r ../$(EXAMPLE_ZIP) .; fi; \
if test "$(FASTJAR)" != ""; then $(FASTJAR) cf ../$(EXAMPLE_ZIP) .; fi; \
cd ..)
rm -rf classes
# Zip file be gone! (and make sure the classes are gone too)
+11 -1
View File
@@ -82,6 +82,7 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CLASSPATH_INCLUDES = @CLASSPATH_INCLUDES@
CLASSPATH_MODULE = @CLASSPATH_MODULE@
COLLECTIONS_PREFIX = @COLLECTIONS_PREFIX@
CP = @CP@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
@@ -89,6 +90,8 @@ CREATE_ALSA_LIBRARIES_FALSE = @CREATE_ALSA_LIBRARIES_FALSE@
CREATE_ALSA_LIBRARIES_TRUE = @CREATE_ALSA_LIBRARIES_TRUE@
CREATE_API_DOCS_FALSE = @CREATE_API_DOCS_FALSE@
CREATE_API_DOCS_TRUE = @CREATE_API_DOCS_TRUE@
CREATE_COLLECTIONS_FALSE = @CREATE_COLLECTIONS_FALSE@
CREATE_COLLECTIONS_TRUE = @CREATE_COLLECTIONS_TRUE@
CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
@@ -119,6 +122,7 @@ EGREP = @EGREP@
ERROR_CFLAGS = @ERROR_CFLAGS@
EXAMPLESDIR = @EXAMPLESDIR@
EXEEXT = @EXEEXT@
FASTJAR = @FASTJAR@
FIND = @FIND@
FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
@@ -130,6 +134,8 @@ FOUND_JIKES_FALSE = @FOUND_JIKES_FALSE@
FOUND_JIKES_TRUE = @FOUND_JIKES_TRUE@
FOUND_KJC_FALSE = @FOUND_KJC_FALSE@
FOUND_KJC_TRUE = @FOUND_KJC_TRUE@
FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
FREETYPE2_LIBS = @FREETYPE2_LIBS@
GCJ = @GCJ@
GCJX = @GCJX@
GJDOC = @GJDOC@
@@ -180,6 +186,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
PANGOFT2_LIBS = @PANGOFT2_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
QT_CFLAGS = @QT_CFLAGS@
QT_LIBS = @QT_LIBS@
@@ -532,7 +539,10 @@ $(EXAMPLE_ZIP): $(EXAMPLE_JAVA_FILES)
mkdir -p classes/gnu/classpath/examples/icons
cp $(EXAMPLE_ICONS) classes/gnu/classpath/examples/icons
$(JCOMPILER) -d classes $(EXAMPLE_JAVA_FILES)
cd classes; $(ZIP) -r ../$(EXAMPLE_ZIP) .; cd ..
(cd classes; \
if test "$(ZIP)" != ""; then $(ZIP) -r ../$(EXAMPLE_ZIP) .; fi; \
if test "$(FASTJAR)" != ""; then $(FASTJAR) cf ../$(EXAMPLE_ZIP) .; fi; \
cd ..)
rm -rf classes
# Zip file be gone! (and make sure the classes are gone too)
@@ -433,7 +433,6 @@ public class PlayingDesk
else
{
blacks.add(new Point(x, y));
repaint();
if (victory != null)
{
@@ -447,7 +446,8 @@ public class PlayingDesk
frame.talk(Color.black, "Partner goes " + x + "-" + y
+ ". Your move?");
player.set_current_state(I_THINK);
}
}
repaint();
}
}
catch (RemoteException rex)
@@ -57,13 +57,8 @@ import org.omg.PortableServer.Servant;
* Tie on the client side. The Game Manager methods contain the code for remote
* invocation.
*
* This class is normally generated with rmic from the {@link GameManagerImpl}:
*
* <pre>
* rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.GameManagerImpl
* </pre>
*
* (the compiled package must be present in the current folder).
* This class is normally generated with rmic or grmic from the
* {@link GameManagerImpl}. See tools/gnu/classpath/tools/giop/README.
*
* In this example the class was manually edited and commented for better
* understanding of functionality.
@@ -58,11 +58,8 @@ import org.omg.PortableServer.Servant;
* rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.PlayerImpl
* (the compiled package must be present in the current folder).
*
* This class is normally generated with rmic from the {@link PlayerImpl}:
* <pre>
* rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.PlayerImpl
* </pre>
* (the compiled package must be present in the current folder).
* This class is normally generated with rmic or grmic from the
* {@link PlayerImpl}. See tools/gnu/classpath/tools/giop/README.
*
* In this example the class was manually edited and commented for better
* understanding of functionality.
@@ -1,5 +1,5 @@
/* ButtonDemo.java -- An example showing various buttons in Swing.
Copyright (C) 2005, Free Software Foundation, Inc.
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath examples.
@@ -46,6 +46,8 @@ public class ButtonDemo
implements ActionListener
{
private JPanel content;
private JCheckBox buttonState;
private JButton button1;
private JButton button2;
@@ -77,6 +79,19 @@ public class ButtonDemo
{
super(title);
JPanel content = createContent();
// initFrameContent() is only called (from main) when running this app
// standalone
}
/**
* When the demo is run independently, the frame is displayed, so we should
* initialise the content panel (including the demo content and a close
* button). But when the demo is run as part of the Swing activity board,
* only the demo content panel is used, the frame itself is never displayed,
* so we can avoid this step.
*/
public void initFrameContent()
{
JPanel closePanel = new JPanel();
JButton closeButton = new JButton("Close");
closeButton.setActionCommand("CLOSE");
@@ -95,13 +110,16 @@ public class ButtonDemo
*/
JPanel createContent()
{
JPanel content = new JPanel(new BorderLayout());
JPanel panel = new JPanel(new GridLayout(4, 1));
panel.add(createButtonPanel());
panel.add(createTogglePanel());
panel.add(createCheckBoxPanel());
panel.add(createRadioPanel());
content.add(panel);
if (content == null)
{
content = new JPanel(new BorderLayout());
JPanel panel = new JPanel(new GridLayout(4, 1));
panel.add(createButtonPanel());
panel.add(createTogglePanel());
panel.add(createCheckBoxPanel());
panel.add(createRadioPanel());
content.add(panel);
}
return content;
}
@@ -277,6 +295,7 @@ public class ButtonDemo
public static void main(String[] args)
{
ButtonDemo app = new ButtonDemo("Button Demo");
app.initFrameContent();
app.pack();
app.setVisible(true);
}
@@ -1,5 +1,5 @@
/* ComboBoxDemo.java -- An example showing various combo boxes in Swing.
Copyright (C) 2005, Free Software Foundation, Inc.
Copyright (C) 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath examples.
@@ -69,6 +69,7 @@ public class ComboBoxDemo
}
}
private JPanel content;
private JCheckBox comboState1;
private JComboBox combo1;
private JComboBox combo2;
@@ -102,6 +103,19 @@ public class ComboBoxDemo
{
super(title);
JPanel content = createContent();
// initFrameContent() is only called (from main) when running this app
// standalone
}
/**
* When the demo is run independently, the frame is displayed, so we should
* initialise the content panel (including the demo content and a close
* button). But when the demo is run as part of the Swing activity board,
* only the demo content panel is used, the frame itself is never displayed,
* so we can avoid this step.
*/
public void initFrameContent()
{
JPanel closePanel = new JPanel();
JButton closeButton = new JButton("Close");
closeButton.setActionCommand("CLOSE");
@@ -120,15 +134,18 @@ public class ComboBoxDemo
*/
JPanel createContent()
{
JPanel content = new JPanel(new BorderLayout());
JPanel panel = new JPanel(new GridLayout(6, 1));
panel.add(createPanel1());
panel.add(createPanel2());
panel.add(createPanel3());
panel.add(createPanel4());
panel.add(createPanel5());
panel.add(createPanel6());
content.add(panel);
if (content == null)
{
content = new JPanel(new BorderLayout());
JPanel panel = new JPanel(new GridLayout(6, 1));
panel.add(createPanel1());
panel.add(createPanel2());
panel.add(createPanel3());
panel.add(createPanel4());
panel.add(createPanel5());
panel.add(createPanel6());
content.add(panel);
}
return content;
}
@@ -353,6 +370,7 @@ public class ComboBoxDemo
e.printStackTrace();
}
ComboBoxDemo app = new ComboBoxDemo("ComboBox Demo");
app.initFrameContent();
app.pack();
app.setVisible(true);
}
@@ -1,5 +1,5 @@
/* SwingDemo.java -- An example of using the javax.swing UI.
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath examples.
@@ -163,18 +163,6 @@ public class Demo
new PopUpAction("Buttons",
(new ButtonDemo("Button Demo")).createContent(),
examples);
new PopUpAction("Toggles",
mkToggle("cool and refreshing"),
examples);
new PopUpAction("Checkbox",
mkCheckbox("ice cold"),
examples);
new PopUpAction("Radio",
mkRadio("delicious"),
examples);
new PopUpAction("Slider",
(new SliderDemo("Slider Demo")).createContent(),
@@ -214,8 +202,7 @@ public class Demo
examples);
new PopUpAction("Spinner",
mkSpinner(),
examples);
new SpinnerDemo("Spinner Demo").createContent(), examples);
new PopUpAction("TextField",
(new TextFieldDemo("TextField Demo")).createContent(),
@@ -715,6 +702,7 @@ public class Demo
main.add(mkButtonBar());
component.add(main, BorderLayout.CENTER);
frame.pack();
frame.setSize(800, 600);
frame.show();
}
@@ -732,26 +720,6 @@ public class Demo
SwingUtilities.invokeLater(new LaterMain());
}
public static JCheckBox mkCheckbox(String label)
{
JCheckBox c = new JCheckBox(label);
c.setFont(new Font("Luxi", Font.PLAIN, 14));
return c;
}
public static JPanel mkRadio(String label)
{
JPanel p = new JPanel();
JRadioButton c = new JRadioButton(label);
JRadioButton d = new JRadioButton("not " + label);
ButtonGroup bg = new ButtonGroup();
bg.add(c);
bg.add(d);
p.add(c);
p.add(d);
return p;
}
public static JList mkList(Object[] elts)
{
JList list = new JList(elts);
@@ -775,12 +743,6 @@ public class Demo
return box;
}
public static JSpinner mkSpinner()
{
JSpinner spinner = new JSpinner();
return spinner;
}
public static JButton mkBigButton(String title)
{
JButton b = new JButton(title);
@@ -789,14 +751,6 @@ public class Demo
return b;
}
public static JToggleButton mkToggle(String title)
{
JToggleButton b = new JToggleButton(title);
b.setMargin(new Insets(5,5,5,5));
b.setFont(new Font("Luxi", Font.PLAIN, 14));
return b;
}
public static JPanel mkPanel(JComponent[] inners)
{
JPanel p = new JPanel();
@@ -947,37 +901,16 @@ public class Demo
return editorPane;
}
private static JTree mkTree()
/**
* Create the tree.
*
* @return thr scroll pane, containing the tree.
*/
private static JComponent mkTree()
{
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root node");
DefaultMutableTreeNode child1 = new DefaultMutableTreeNode("Child node 1");
DefaultMutableTreeNode child11 =
new DefaultMutableTreeNode("Child node 1.1");
DefaultMutableTreeNode child12 =
new DefaultMutableTreeNode("Child node 1.2");
DefaultMutableTreeNode child13 =
new DefaultMutableTreeNode("Child node 1.3");
DefaultMutableTreeNode child2 = new DefaultMutableTreeNode("Child node 2");
DefaultMutableTreeNode child21 =
new DefaultMutableTreeNode("Child node 2.1");
DefaultMutableTreeNode child22 =
new DefaultMutableTreeNode("Child node 2.2");
DefaultMutableTreeNode child23 =
new DefaultMutableTreeNode("Child node 2.3");
DefaultMutableTreeNode child24 =
new DefaultMutableTreeNode("Child node 2.4");
DefaultMutableTreeNode child3 = new DefaultMutableTreeNode("Child node 3");
root.add(child1);
root.add(child2);
root.add(child3);
child1.add(child11);
child1.add(child12);
child1.add(child13);
child2.add(child21);
child2.add(child22);
child2.add(child23);
child2.add(child24);
addChildren("Node", root, 12);
JTree tree = new JTree(root);
tree.setLargeModel(true);
@@ -985,60 +918,58 @@ public class Demo
dtsm.setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
tree.setSelectionModel(dtsm);
return tree;
// Make it editable.
tree.setEditable(true);
JComponent t = mkScrollPane(tree);
t.setPreferredSize(new Dimension(200,200));
return t;
}
private static JTable mkTable()
/**
* Add the specified number of children to this parent node. For each
* child, the method is called recursively adding the nChildren-3 number of
* grandchildren.
*
* @param parent the parent node
* @param nChildren the number of children
*/
private static void addChildren(String name, DefaultMutableTreeNode parent,
int nChildren)
{
Object[][] tableData = new Object[][] {
for (int i = 0; i < nChildren; i++)
{
"Field 1", "Field 2" , "Field 3"
},
{
"Field 4", "Field 5" , "Field 6"
},
{
"Field 7", "Field 8" , "Field 9"
},
{
"Field 10", "Field 11" , "Field 12"
String child_name = parent+"."+i;
DefaultMutableTreeNode child = new DefaultMutableTreeNode
(child_name);
parent.add(child);
addChildren(child_name, child, nChildren-3);
}
};
Object[] columnNames = new Object[] {"Column 1", "Column 2", "Column 3"};
JTable table = new JTable(tableData, columnNames);
return table;
}
/**
* Make a sample table component.
*/
private static JPanel mkTable()
{
return new TableDemo("Table demo, double click to edit")
.createContent();
}
private JPanel mkButtonBar()
{
JPanel panel = new JPanel (new GridLayout(2, 1));
JPanel panelA = new JPanel(new FlowLayout());
JPanel panelB = new JPanel(new FlowLayout());
JPanel panel = new JPanel(new FlowLayout());
new PopUpAction("Buttons",
(new ButtonDemo("Button Demo")).createContent(),
panelA);
new PopUpAction("Toggles",
mkToggle("cool and refreshing"),
panelA);
new PopUpAction("Checkbox",
mkCheckbox("ice cold"),
panelA);
new PopUpAction("Radio",
mkRadio("delicious"),
panelA);
panel);
new PopUpAction("Slider",
(new SliderDemo("Slider Demo")).createContent(),
panelA);
panel);
new PopUpAction("ProgressBar",
ProgressBarDemo.createContent(),
panelA);
panel);
new PopUpAction("List",
@@ -1050,60 +981,59 @@ public class Demo
"that",
"wraps",
"over"}),
panelA);
panel);
new PopUpAction("Scrollbar",
(new ScrollBarDemo("ScrollBar Demo")).createContent(),
panelA);
panel);
new PopUpAction("Viewport",
mkViewportBox(mkBigButton("View Me!")),
panelA);
panel);
new PopUpAction("ScrollPane",
mkScrollPane(mkBigButton("Scroll Me!")),
panelA);
panel);
new PopUpAction("TabPane",
mkTabs(new String[] {"happy",
"sad",
"indifferent"}),
panelB);
panel);
new PopUpAction("Spinner",
mkSpinner(),
panelB);
new PopUpAction("Spinner",
new SpinnerDemo("Spinner Demo").createContent(), panel);
new PopUpAction("TextField",
(new TextFieldDemo("TextField Demo")).createContent(),
panelB);
panel);
new PopUpAction("FileChooser",
(new FileChooserDemo("FileChooser Demo")).createContent(),
panelB);
panel);
new PopUpAction("ColorChooser",
mkColorChooser(),
panelB);
panel);
new PopUpAction("ComboBox",
(new ComboBoxDemo("ComboBox Demo")).createContent(),
panelB);
panel);
new PopUpAction("Editor",
mkEditorPane(),
panelB);
panel);
new PopUpAction("Tree",
mkTree(),
panelB);
panel);
new PopUpAction("Table",
mkTable(),
panelB);
panel);
JButton exitDisposer = mkDisposerButton(frame);
panelB.add(exitDisposer);
panel.add(exitDisposer);
exitDisposer.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
@@ -1111,8 +1041,6 @@ public class Demo
System.exit(1);
}
});
panel.add(panelA);
panel.add(panelB);
return panel;
}
}
@@ -1,5 +1,5 @@
/* FileChooserDemo.java -- An example showing file choosers in Swing.
Copyright (C) 2005, Free Software Foundation, Inc.
Copyright (C) 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath examples.
@@ -63,7 +63,9 @@ public class FileChooserDemo extends JFrame implements ActionListener
return false;
}
}
private JPanel content;
/** A label to display the selected file. */
JLabel selectedFileLabel;
@@ -85,6 +87,19 @@ public class FileChooserDemo extends JFrame implements ActionListener
{
super(frameTitle);
JPanel content = createContent();
// initFrameContent() is only called (from main) when running this app
// standalone
}
/**
* When the demo is run independently, the frame is displayed, so we should
* initialise the content panel (including the demo content and a close
* button). But when the demo is run as part of the Swing activity board,
* only the demo content panel is used, the frame itself is never displayed,
* so we can avoid this step.
*/
public void initFrameContent()
{
JPanel closePanel = new JPanel();
JButton closeButton = new JButton("Close");
closeButton.setActionCommand("CLOSE");
@@ -102,52 +117,56 @@ public class FileChooserDemo extends JFrame implements ActionListener
* added if this demo is being run as a standalone demo).
*/
JPanel createContent()
{
JPanel panel = new JPanel(new BorderLayout());
// create a panel of buttons to select the different styles of file
// chooser...
JPanel buttonPanel = new JPanel(new GridLayout(5, 1));
JButton openButton = new JButton("Open...");
openButton.setActionCommand("OPEN");
openButton.addActionListener(this);
buttonPanel.add(openButton);
JButton saveButton = new JButton("Save...");
saveButton.setActionCommand("SAVE");
saveButton.addActionListener(this);
buttonPanel.add(saveButton);
JButton queryButton = new JButton("Select Directory...");
queryButton.setActionCommand("SELECT_DIRECTORY");
queryButton.addActionListener(this);
buttonPanel.add(queryButton);
JButton openJavaButton = new JButton("Open Java file...");
openJavaButton.setActionCommand("OPEN_JAVA");
openJavaButton.addActionListener(this);
buttonPanel.add(openJavaButton);
JButton openMultiButton = new JButton("Open multiple files...");
openMultiButton.setActionCommand("OPEN_MULTI");
openMultiButton.addActionListener(this);
buttonPanel.add(openMultiButton);
panel.add(buttonPanel, BorderLayout.WEST);
// create a panel to display the selected file(s) and the return code
JPanel displayPanel = new JPanel(new BorderLayout());
selectedFileLabel = new JLabel("-");
selectedFileLabel.setBorder(BorderFactory.createTitledBorder("Selected File/Directory: "));
displayPanel.add(selectedFileLabel, BorderLayout.NORTH);
{
if (content == null)
{
JPanel panel = new JPanel(new BorderLayout());
selectedFilesList = new JList();
JScrollPane sp = new JScrollPane(selectedFilesList);
sp.setBorder(BorderFactory.createTitledBorder("Selected Files: "));
displayPanel.add(sp);
returnCodeLabel = new JLabel("0");
returnCodeLabel.setBorder(BorderFactory.createTitledBorder("Return Code:"));
displayPanel.add(returnCodeLabel, BorderLayout.SOUTH);
// create a panel of buttons to select the different styles of file
// chooser...
JPanel buttonPanel = new JPanel(new GridLayout(5, 1));
JButton openButton = new JButton("Open...");
openButton.setActionCommand("OPEN");
openButton.addActionListener(this);
buttonPanel.add(openButton);
JButton saveButton = new JButton("Save...");
saveButton.setActionCommand("SAVE");
saveButton.addActionListener(this);
buttonPanel.add(saveButton);
JButton queryButton = new JButton("Select Directory...");
queryButton.setActionCommand("SELECT_DIRECTORY");
queryButton.addActionListener(this);
buttonPanel.add(queryButton);
JButton openJavaButton = new JButton("Open Java file...");
openJavaButton.setActionCommand("OPEN_JAVA");
openJavaButton.addActionListener(this);
buttonPanel.add(openJavaButton);
JButton openMultiButton = new JButton("Open multiple files...");
openMultiButton.setActionCommand("OPEN_MULTI");
openMultiButton.addActionListener(this);
buttonPanel.add(openMultiButton);
panel.add(buttonPanel, BorderLayout.WEST);
panel.add(displayPanel);
return panel;
// create a panel to display the selected file(s) and the return code
JPanel displayPanel = new JPanel(new BorderLayout());
selectedFileLabel = new JLabel("-");
selectedFileLabel.setBorder(BorderFactory.createTitledBorder("Selected File/Directory: "));
displayPanel.add(selectedFileLabel, BorderLayout.NORTH);
selectedFilesList = new JList();
JScrollPane sp = new JScrollPane(selectedFilesList);
sp.setBorder(BorderFactory.createTitledBorder("Selected Files: "));
displayPanel.add(sp);
returnCodeLabel = new JLabel("0");
returnCodeLabel.setBorder(BorderFactory.createTitledBorder("Return Code:"));
displayPanel.add(returnCodeLabel, BorderLayout.SOUTH);
panel.add(displayPanel);
content = panel;
}
return content;
}
/**
@@ -221,6 +240,7 @@ public class FileChooserDemo extends JFrame implements ActionListener
public static void main(String[] args)
{
FileChooserDemo app = new FileChooserDemo("File Chooser Demo");
app.initFrameContent();
app.pack();
app.setVisible(true);
}
@@ -0,0 +1,233 @@
/* MiniDemo.java -- A Swing demo suitable for embedded environments
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.classpath.examples.swing;
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalIconFactory;
import javax.swing.plaf.metal.MetalLookAndFeel;
/**
* A Swing demo suitable for embedded environments (e.g. small display,
* b/w graphics etc).
*
* @author Roman Kennke (kennke@aicas.com)
*/
public class MiniDemo extends JFrame
{
/**
* Creates a new MiniDemo instance.
*/
MiniDemo()
{
createGUI();
}
private void createGUI()
{
JTabbedPane tabPane = new JTabbedPane(JTabbedPane.TOP,
JTabbedPane.SCROLL_TAB_LAYOUT);
// Setup scrolling list in first tab.
Object[] listData = new Object[]{"Milk", "Beer", "Wine", "Water",
"Orange juice", "Tea", "Coffee", "Whiskey",
"Lemonade", "Apple juice", "Gin Tonic",
"Pangalactic Garleblaster", "Coke"};
JList list = new JList(listData);
JScrollPane sp = new JScrollPane(list);
tabPane.addTab("List", sp);
// Setup some buttons in the second tab.
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new GridLayout(4, 1));
// JButtons
JPanel jButtonPanel = new JPanel();
jButtonPanel.setLayout(new BorderLayout());
final JCheckBox buttonState1 = new JCheckBox("Enabled", true);
jButtonPanel.add(buttonState1, BorderLayout.EAST);
JPanel jButtonContainer = new JPanel();
final JButton jButton1 = new JButton("JButton");
final JButton jButton2 =
new JButton(MetalIconFactory.getInternalFrameDefaultMenuIcon());
jButtonContainer.add(jButton1);
jButtonContainer.add(jButton2);
jButtonPanel.add(jButtonContainer, BorderLayout.CENTER);
buttonState1.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent ev)
{
boolean enabled = buttonState1.isSelected();
jButton1.setEnabled(enabled);
jButton2.setEnabled(enabled);
}
});
buttonPanel.add(jButtonPanel);
// JToggleButtons
JPanel jToggleButtonPanel = new JPanel();
jToggleButtonPanel.setLayout(new BorderLayout());
final JCheckBox buttonState2 = new JCheckBox("Enabled", true);
jToggleButtonPanel.add(buttonState2, BorderLayout.EAST);
JPanel jToggleButtonContainer = new JPanel();
final JButton jToggleButton1 = new JButton("JToggleButton");
final JButton jToggleButton2 =
new JButton(MetalIconFactory.getInternalFrameDefaultMenuIcon());
jToggleButtonContainer.add(jToggleButton1);
jToggleButtonContainer.add(jToggleButton2);
jToggleButtonPanel.add(jToggleButtonContainer, BorderLayout.CENTER);
buttonState2.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent ev)
{
boolean enabled = buttonState2.isSelected();
jToggleButton1.setEnabled(enabled);
jToggleButton2.setEnabled(enabled);
}
});
buttonPanel.add(jToggleButtonPanel);
tabPane.addTab("Buttons", buttonPanel);
// ComboBoxes
JPanel comboBoxPanel = new JPanel();
JComboBox comboBox = new JComboBox(listData);
comboBoxPanel.add(comboBox);
tabPane.add("ComboBox", comboBoxPanel);
// TextFields
JPanel textFieldPanel = new JPanel();
textFieldPanel.setLayout(new BoxLayout(textFieldPanel, BoxLayout.Y_AXIS));
textFieldPanel.add(Box.createVerticalStrut(70));
JPanel leftAlignedPanel = new JPanel(new BorderLayout());
JPanel textFieldPanel1 = new JPanel();
textFieldPanel1.setLayout(new BoxLayout(textFieldPanel1,
BoxLayout.X_AXIS));
final JTextField textfield1 = new JTextField("Hello World!");
textfield1.setHorizontalAlignment(JTextField.LEFT);
textfield1.setFont(new Font("Dialog", Font.PLAIN, 8));
textFieldPanel1.add(textfield1);
final JTextField textfield2 = new JTextField("Hello World!");
textfield2.setHorizontalAlignment(JTextField.LEFT);
textfield2.setFont(new Font("Dialog", Font.ITALIC, 12));
textFieldPanel1.add(textfield2);
final JTextField textfield3 = new JTextField("Hello World!");
textfield3.setHorizontalAlignment(JTextField.LEFT);
textfield3.setFont(new Font("Dialog", Font.BOLD, 14));
textFieldPanel1.add(textfield3);
leftAlignedPanel.add(textFieldPanel1);
JPanel statePanel = new JPanel();
statePanel.setLayout(new BoxLayout(statePanel, BoxLayout.Y_AXIS));
statePanel.add(Box.createVerticalGlue());
final JCheckBox enabled1 = new JCheckBox("enabled");
enabled1.setSelected(true);
enabled1.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent ev)
{
boolean enabled = enabled1.isSelected();
textfield1.setEnabled(enabled);
textfield2.setEnabled(enabled);
textfield3.setEnabled(enabled);
}
});
statePanel.add(enabled1);
final JCheckBox editable1 = new JCheckBox("editable");
editable1.setSelected(true);
editable1.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent ev)
{
boolean editable = editable1.isSelected();
textfield1.setEditable(editable);
textfield2.setEditable(editable);
textfield3.setEditable(editable);
}
});
statePanel.add(editable1);
statePanel.add(Box.createVerticalGlue());
leftAlignedPanel.add(statePanel, BorderLayout.EAST);
textFieldPanel.add(leftAlignedPanel);
System.err.println(leftAlignedPanel.getPreferredSize());
textFieldPanel.add(Box.createVerticalStrut(70));
//panel.add(rightAlignedPanel);
tabPane.add("TextField", textFieldPanel);
setContentPane(tabPane);
}
/**
* Starts the demo application.
*
* @param args the command line arguments (ignored)
*/
public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable() {
public void run()
{
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
MiniDemo demo = new MiniDemo();
demo.setSize(320, 200);
demo.setUndecorated(true);
demo.setVisible(true);
demo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
});
}
}
@@ -1,5 +1,5 @@
/* ScrollBarDemo.java -- An example showing scroll bars in Swing.
Copyright (C) 2005, Free Software Foundation, Inc.
Copyright (C) 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath examples.
@@ -40,6 +40,8 @@ public class ScrollBarDemo
implements ActionListener
{
private JPanel content;
/**
* Creates a new demo instance.
*
@@ -49,6 +51,19 @@ public class ScrollBarDemo
{
super(title);
JPanel content = createContent();
// initFrameContent() is only called (from main) when running this app
// standalone
}
/**
* When the demo is run independently, the frame is displayed, so we should
* initialise the content panel (including the demo content and a close
* button). But when the demo is run as part of the Swing activity board,
* only the demo content panel is used, the frame itself is never displayed,
* so we can avoid this step.
*/
public void initFrameContent()
{
JPanel closePanel = new JPanel();
JButton closeButton = new JButton("Close");
closeButton.setActionCommand("CLOSE");
@@ -67,9 +82,12 @@ public class ScrollBarDemo
*/
JPanel createContent()
{
JPanel content = new JPanel(new BorderLayout());
JPanel panel = createScrollBarPanel();
content.add(panel);
if (content == null)
{
content = new JPanel(new BorderLayout());
JPanel panel = createScrollBarPanel();
content.add(panel);
}
return content;
}
@@ -134,6 +152,7 @@ public class ScrollBarDemo
public static void main(String[] args)
{
ScrollBarDemo app = new ScrollBarDemo("ScrollBar Demo");
app.initFrameContent();
app.pack();
app.setVisible(true);
}
@@ -1,5 +1,5 @@
/* SliderDemo.java -- An example showing JSlider in various configurations.
Copyright (C) 2005, Free Software Foundation, Inc.
Copyright (C) 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath examples.
@@ -35,7 +35,9 @@ import javax.swing.JSlider;
public class SliderDemo extends JFrame implements ActionListener
{
private JPanel content;
JSlider hslider1;
JSlider hslider2;
JSlider hslider3;
@@ -59,7 +61,20 @@ public class SliderDemo extends JFrame implements ActionListener
public SliderDemo(String frameTitle)
{
super(frameTitle);
JPanel content = createContent();
content = createContent();
// initFrameContent() is only called (from main) when running this app
// standalone
}
/**
* When the demo is run independently, the frame is displayed, so we should
* initialise the content panel (including the demo content and a close
* button). But when the demo is run as part of the Swing activity board,
* only the demo content panel is used, the frame itself is never displayed,
* so we can avoid this step.
*/
public void initFrameContent()
{
JPanel closePanel = new JPanel();
JButton closeButton = new JButton("Close");
closeButton.setActionCommand("CLOSE");
@@ -78,20 +93,23 @@ public class SliderDemo extends JFrame implements ActionListener
*/
JPanel createContent()
{
JPanel content = new JPanel(new BorderLayout());
JPanel panel = new JPanel(new GridLayout(1, 2));
panel.add(createHorizontalPanel());
panel.add(createVerticalPanel());
enabledCheckBox = new JCheckBox("Enabled");
enabledCheckBox.setSelected(true);
enabledCheckBox.setActionCommand("TOGGLE_ENABLED");
enabledCheckBox.addActionListener(this);
JPanel checkBoxPanel = new JPanel();
checkBoxPanel.add(enabledCheckBox);
JPanel panel2 = new JPanel(new BorderLayout());
panel2.add(panel);
panel2.add(checkBoxPanel, BorderLayout.SOUTH);
content.add(panel2);
if (content == null)
{
content = new JPanel(new BorderLayout());
JPanel panel = new JPanel(new GridLayout(1, 2));
panel.add(createHorizontalPanel());
panel.add(createVerticalPanel());
enabledCheckBox = new JCheckBox("Enabled");
enabledCheckBox.setSelected(true);
enabledCheckBox.setActionCommand("TOGGLE_ENABLED");
enabledCheckBox.addActionListener(this);
JPanel checkBoxPanel = new JPanel();
checkBoxPanel.add(enabledCheckBox);
JPanel panel2 = new JPanel(new BorderLayout());
panel2.add(panel);
panel2.add(checkBoxPanel, BorderLayout.SOUTH);
content.add(panel2);
}
return content;
}
@@ -242,6 +260,7 @@ public class SliderDemo extends JFrame implements ActionListener
public static void main(String[] args)
{
SliderDemo app = new SliderDemo("Slider Demo");
app.initFrameContent();
app.pack();
app.setVisible(true);
}
@@ -0,0 +1,230 @@
/* SpinnerDemo.java -- An example showing various spinners in Swing.
Copyright (C) 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath examples.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
package gnu.classpath.examples.swing;
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Calendar;
import java.util.Date;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SpinnerDateModel;
import javax.swing.SpinnerListModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.UIManager;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalLookAndFeel;
/**
* A simple demo showing various spinners in different states.
*/
public class SpinnerDemo
extends JFrame
implements ActionListener
{
private JPanel content;
private JCheckBox spinnerState1;
private JSpinner spinner1;
private JSpinner spinner2;
private JCheckBox spinnerState2;
private JSpinner spinner3;
private JSpinner spinner4;
private JCheckBox spinnerState3;
private JSpinner spinner5;
private JSpinner spinner6;
/**
* Creates a new demo instance.
*
* @param title the frame title.
*/
public SpinnerDemo(String title)
{
super(title);
JPanel content = createContent();
// initFrameContent() is only called (from main) when running this app
// standalone
}
/**
* When the demo is run independently, the frame is displayed, so we should
* initialise the content panel (including the demo content and a close
* button). But when the demo is run as part of the Swing activity board,
* only the demo content panel is used, the frame itself is never displayed,
* so we can avoid this step.
*/
public void initFrameContent()
{
JPanel closePanel = new JPanel();
JButton closeButton = new JButton("Close");
closeButton.setActionCommand("CLOSE");
closeButton.addActionListener(this);
closePanel.add(closeButton);
content.add(closePanel, BorderLayout.SOUTH);
getContentPane().add(content);
}
/**
* Returns a panel with the demo content. The panel
* uses a BorderLayout(), and the BorderLayout.SOUTH area
* is empty, to allow callers to add controls to the
* bottom of the panel if they want to (a close button is
* added if this demo is being run as a standalone demo).
*/
JPanel createContent()
{
if (content == null)
{
content = new JPanel(new BorderLayout());
JPanel panel = new JPanel(new GridLayout(3, 1));
panel.add(createPanel1());
panel.add(createPanel2());
panel.add(createPanel3());
content.add(panel);
}
return content;
}
private JPanel createPanel1()
{
JPanel panel = new JPanel(new BorderLayout());
this.spinnerState1 = new JCheckBox("Enabled", true);
this.spinnerState1.setActionCommand("COMBO_STATE1");
this.spinnerState1.addActionListener(this);
panel.add(this.spinnerState1, BorderLayout.EAST);
JPanel controlPanel = new JPanel();
controlPanel.setBorder(BorderFactory.createTitledBorder(
"Number Spinner: "));
this.spinner1 = new JSpinner(new SpinnerNumberModel(5.0, 0.0, 10.0, 0.5));
this.spinner2 = new JSpinner(new SpinnerNumberModel(50, 0, 100, 5));
this.spinner2.setFont(new Font("Dialog", Font.PLAIN, 20));
controlPanel.add(this.spinner1);
controlPanel.add(this.spinner2);
panel.add(controlPanel);
return panel;
}
private JPanel createPanel2()
{
JPanel panel = new JPanel(new BorderLayout());
this.spinnerState2 = new JCheckBox("Enabled", true);
this.spinnerState2.setActionCommand("COMBO_STATE2");
this.spinnerState2.addActionListener(this);
panel.add(this.spinnerState2, BorderLayout.EAST);
JPanel controlPanel = new JPanel();
controlPanel.setBorder(BorderFactory.createTitledBorder("Date Spinner: "));
this.spinner3 = new JSpinner(new SpinnerDateModel(new Date(), null, null,
Calendar.DATE));
this.spinner4 = new JSpinner(new SpinnerDateModel(new Date(), null, null,
Calendar.YEAR));
this.spinner4.setFont(new Font("Dialog", Font.PLAIN, 20));
controlPanel.add(this.spinner3);
controlPanel.add(this.spinner4);
panel.add(controlPanel);
return panel;
}
private JPanel createPanel3()
{
JPanel panel = new JPanel(new BorderLayout());
this.spinnerState3 = new JCheckBox("Enabled", true);
this.spinnerState3.setActionCommand("COMBO_STATE3");
this.spinnerState3.addActionListener(this);
panel.add(this.spinnerState3, BorderLayout.EAST);
JPanel controlPanel = new JPanel();
controlPanel.setBorder(BorderFactory.createTitledBorder("List Spinner: "));
this.spinner5 = new JSpinner(new SpinnerListModel(new Object[] {"Red",
"Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"}));
this.spinner6 = new JSpinner(new SpinnerListModel(new Object[] {"Red",
"Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"}));
this.spinner6.setValue("Yellow");
this.spinner6.setFont(new Font("Dialog", Font.PLAIN, 20));
controlPanel.add(this.spinner5);
controlPanel.add(this.spinner6);
panel.add(controlPanel);
return panel;
}
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand().equals("COMBO_STATE1"))
{
spinner1.setEnabled(spinnerState1.isSelected());
spinner2.setEnabled(spinnerState1.isSelected());
}
else if (e.getActionCommand().equals("COMBO_STATE2"))
{
spinner3.setEnabled(spinnerState2.isSelected());
spinner4.setEnabled(spinnerState2.isSelected());
}
else if (e.getActionCommand().equals("COMBO_STATE3"))
{
spinner5.setEnabled(spinnerState3.isSelected());
spinner6.setEnabled(spinnerState3.isSelected());
}
else if (e.getActionCommand().equals("CLOSE"))
{
System.exit(0);
}
}
public static void main(String[] args)
{
try
{
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
}
catch (Exception e) {
e.printStackTrace();
}
SpinnerDemo app = new SpinnerDemo("Spinner Demo");
app.initFrameContent();
app.pack();
app.setVisible(true);
}
}
@@ -0,0 +1,236 @@
/* TableDemo.java -- Demonstrates the use of JTable.
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.classpath.examples.swing;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableColumnModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
/**
* Displays the editable table. The first column consists of check boxes.
*
* @author Audrius Meskauskas (audriusa@bioinformatics.org)
*/
public class TableDemo extends JFrame
{
/**
* The initial row count for this table.
*/
static int rows = 32;
/**
* The initial column count for this table.
*/
static int cols = 7;
/**
* The table model.
*/
class TModel extends DefaultTableModel
{
/**
* Return true if the cell is editable. All cells are editable.
*/
public boolean isCellEditable(int parm1, int parm2)
{
return true;
}
/**
* Get the number of the table rows.
*/
public int getRowCount()
{
return rows;
}
/**
* Get the number of the table columns.
*/
public int getColumnCount()
{
return cols;
}
/**
* Set the value at the given position
*/
public void setValueAt(Object aValue, int aRow, int aColumn)
{
values[aRow][aColumn] = aValue;
}
/**
* Get the value at the given position.
*/
public Object getValueAt(int aRow, int aColumn)
{
return values[aRow][aColumn];
}
/**
* The column name, as suggested by model. This header should not be
* visible, as it is overridden by setting the header name with
* {@link TableColumn#setHeaderValue} in {@link TableDemo#createContent}.
*/
public String getColumnName(int column)
{
return "Error "+column;
}
/**
* The first column contains booleans, others - default class.
*/
public Class getColumnClass(int column)
{
if (column == 0)
return Boolean.class;
else
return super.getColumnClass(column);
}
}
private JPanel content;
/**
* The table being displayed.
*/
JTable table = new JTable();
/**
* The table model.
*/
TModel model = new TModel();
/**
* The table value array.
*/
Object[][] values;
/**
* Create the table demo with the given titel.
*
* @param title the frame title.
*/
public TableDemo(String title)
{
super(title);
getContentPane().add(createContent(), BorderLayout.CENTER);
}
/**
* Returns a panel with the demo content. The panel uses a BorderLayout(), and
* the BorderLayout.SOUTH area is empty, to allow callers to add controls to
* the bottom of the panel if they want to (a close button is added if this
* demo is being run as a standalone demo).
*/
JPanel createContent()
{
if (content == null)
{
JPanel p = new JPanel();
p.setLayout(new BorderLayout());
values = new Object[rows][];
for (int i = 0; i < values.length; i++)
{
values[i] = new Object[cols];
for (int j = 1; j < cols; j++)
{
values[i][j] = "" + ((char) ('a' + j)) + i;
}
values [i][0] = i % 2 == 0? Boolean.TRUE : Boolean.FALSE;
}
table.setModel(model);
// Make the columns with gradually increasing width:
DefaultTableColumnModel cm = new DefaultTableColumnModel();
for (int i = 0; i < cols; i++)
{
TableColumn column = new TableColumn(i);
// Showing the variable width columns.
int width = 100+20*i;
column.setPreferredWidth(width);
// If we do not set the header value here, the value, returned
// by model, is used.
column.setHeaderValue("Width +"+(20*i));
cm.addColumn(column);
}
table.setColumnModel(cm);
// Create the table, place it into scroll pane and place
// the pane into this frame.
JScrollPane scroll = new JScrollPane();
// The horizontal scroll bar is never needed.
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scroll.getViewport().add(table);
p.add(scroll, BorderLayout.CENTER);
content = p;
}
return content;
}
/**
* The executable method to display the editable table.
*
* @param args
* unused.
*/
public static void main(String[] args)
{
TableDemo frame = new TableDemo("Table double click on the cell to edit.");
frame.setSize(new Dimension(640, 100));
frame.validate();
frame.setVisible(true);
}
}
@@ -1,5 +1,5 @@
/* TextFieldDemo.java -- An example showing various textfields in Swing.
Copyright (C) 2005, Free Software Foundation, Inc.
Copyright (C) 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath examples.
@@ -107,6 +107,8 @@ public class TextFieldDemo
}
}
private JPanel content;
/**
* The left aligned textfields and state buttons.
*/
@@ -115,7 +117,7 @@ public class TextFieldDemo
JTextField textfield3;
JCheckBox enabled1;
JCheckBox editable1;
JPanel textFieldPanel1;
JPanel textFieldPanel1;
/**
* The right aligned textfields and state buttons.
*/
@@ -162,6 +164,19 @@ JPanel textFieldPanel1;
{
super(title);
JPanel content = createContent();
// initFrameContent() is only called (from main) when running this app
// standalone
}
/**
* When the demo is run independently, the frame is displayed, so we should
* initialise the content panel (including the demo content and a close
* button). But when the demo is run as part of the Swing activity board,
* only the demo content panel is used, the frame itself is never displayed,
* so we can avoid this step.
*/
public void initFrameContent()
{
JPanel closePanel = new JPanel();
JButton closeButton = new JButton("Close");
closeButton.setActionCommand("CLOSE");
@@ -180,15 +195,18 @@ JPanel textFieldPanel1;
*/
JPanel createContent()
{
JPanel content = new JPanel(new BorderLayout());
JPanel panel = new JPanel(new GridLayout(5, 1));
panel.add(createLeftAlignedPanel());
panel.add(createRightAlignedPanel());
panel.add(createCenteredPanel());
panel.add(createCustomColoredPanel());
panel.add(createMiscPanel());
content.add(panel);
//content.setPreferredSize(new Dimension(400, 300));
if (content == null)
{
content = new JPanel(new BorderLayout());
JPanel panel = new JPanel(new GridLayout(5, 1));
panel.add(createLeftAlignedPanel());
panel.add(createRightAlignedPanel());
panel.add(createCenteredPanel());
panel.add(createCustomColoredPanel());
panel.add(createMiscPanel());
content.add(panel);
//content.setPreferredSize(new Dimension(400, 300));
}
return content;
}
@@ -481,6 +499,7 @@ JPanel textFieldPanel1;
public static void main(String[] args)
{
TextFieldDemo app = new TextFieldDemo("TextField Demo");
app.initFrameContent();
app.pack();
app.setVisible(true);
}