<%@ Language=JavaScript %> SwingBits
Support This Project ZipStream.SourceForge.net

SwingBits is a library of commonly used Swing extensions and codebits that make Swing GUI development simpler and faster.

SwingBits component suite (downloads)
  • AboutDialog
  • ApplicationFrame
  • ComponentTitledBorder
  • GridLayout2
  • IconCache
  • InitialFocusSetter
  • IntroDialog
  • LocationWindowListener
  • MinimumSizeListener
  • MultiLineJLabel
  • NorthPanel
  • SingleSelectionModel
  • StatusBar
  • TitledMnemonicBorder
  • TitledMnemonicPanel
  • ToggleSelectionModel
  • WarningListener
AboutDialog

The AboutDialog with a title, description, icon and license details:

Usage example:

String title = "ApplicationFrame Demo";
String desc = "SwingBits is a library of commonly used Swing extensions and codebits that make Swing GUI development simpler and faster.";
Icon icon = IconCache.getIcon("/image/dukewaving.gif");
AboutDialog aboutDialog = new AboutDialog(frame, "About", true, title, desc, icon, BorderLayout.EAST);
aboutDialog.setVersion("1.0.0");
aboutDialog.setBuild("345");
aboutDialog.setCopyright("(C) 2007 Michael Hjembæk");
aboutDialog.setLicense(new File("gpl.txt"));
aboutDialog.pack();
aboutDialog.setLocationRelativeTo(frame);

 

GridLayout2

The GridLayout2 layout manager lays out its components in cells. Added components are displayed using their preferred size, with anchor in the northwest location of the cell. The column width is sized to match the widest component in the column. The row height is sized to match the highest component in the row.

The following is an example that uses the GridLayout2 layout manager.

Usage example:

final JDialog dialog = new JDialog(parent, "GridLayout2", true);

JPanel gridPanel = new JPanel(new GridLayout2(2,3));
gridPanel.setBorder(BorderFactory.createTitledBorder("Enter username and password"));

gridPanel.add(new JLabel("Username:"));
gridPanel.add(new JTextField(6));
gridPanel.add(new JPanel());
gridPanel.add(new JLabel("Password:"));
gridPanel.add(new JScrollPane(new JTextArea(5,10)));
gridPanel.add(new JTextField("enter 2"));

dialog.getContentPane().add(gridPanel);
dialog.pack();
dialog.setLocationRelativeTo(parent);
 

IconCache

The IconCache is a cache for fast retrieval of icons. Each icon is only read once from slow I/O, any subsequent access to the same resource will be directly from the cache.

Usage example:

Icon icon = IconCache.getIcon("/image/dukewaving.gif");
 

This page was last updated: 05-04-2007 by Michael Hjembæk