├── www ├── articles │ ├── TableLayoutTutorialPart2 │ │ ├── MakePagesJar.bat │ │ ├── apps │ │ │ ├── Example2.jar │ │ │ ├── grid.jnlp │ │ │ ├── multicell.jnlp │ │ │ ├── toggle1.jnlp │ │ │ ├── toggle2.jnlp │ │ │ ├── borderSimple.jnlp │ │ │ ├── bidi.jnlp │ │ │ ├── scrolling1.jnlp │ │ │ ├── scrolling2.jnlp │ │ │ ├── borderLeftMenu.jnlp │ │ │ ├── multicellJustify.jnlp │ │ │ └── borderStatus.jnlp │ │ ├── images │ │ │ ├── Multicell.gif │ │ │ ├── ExampleGrid.gif │ │ │ ├── ExampleBorder1.gif │ │ │ ├── ExampleBorder2.gif │ │ │ ├── ExampleBorder3.gif │ │ │ ├── ExampleToggle1.gif │ │ │ ├── ExampleToggle2.gif │ │ │ ├── LaunchExample.gif │ │ │ ├── MulticellGrid.gif │ │ │ └── TableLayout-Part2.gif │ │ ├── pages │ │ │ ├── example2 │ │ │ │ ├── Bidi.class │ │ │ │ ├── Grid.class │ │ │ │ ├── Multicell.class │ │ │ │ ├── Toggle1.class │ │ │ │ ├── Toggle2.class │ │ │ │ ├── Scrolling1.class │ │ │ │ ├── Scrolling2.class │ │ │ │ ├── BorderLeftMenu.class │ │ │ │ ├── BorderSimple.class │ │ │ │ ├── BorderStatus.class │ │ │ │ ├── MulticellJustify.class │ │ │ │ ├── Scrolling2$Heading.class │ │ │ │ ├── BorderStatus$Heading.class │ │ │ │ ├── Scrolling2$StatusBar.class │ │ │ │ ├── BorderLeftMenu$Heading.class │ │ │ │ ├── BorderLeftMenu$StatusBar.class │ │ │ │ └── BorderStatus$StatusBar.class │ │ │ ├── itox_files │ │ │ │ ├── info.gif │ │ │ │ ├── emailMath.gif │ │ │ │ ├── itoxGraph.gif │ │ │ │ ├── itoxProof.gif │ │ │ │ └── background.htm │ │ │ ├── hypercube_files │ │ │ │ ├── info.gif │ │ │ │ ├── image01.gif │ │ │ │ ├── image02.gif │ │ │ │ ├── image03.gif │ │ │ │ ├── image04.gif │ │ │ │ ├── image05.gif │ │ │ │ ├── image06.gif │ │ │ │ ├── image07.gif │ │ │ │ ├── image08.gif │ │ │ │ ├── image09.gif │ │ │ │ ├── image10.gif │ │ │ │ ├── image11.gif │ │ │ │ ├── image12.gif │ │ │ │ ├── image13.gif │ │ │ │ ├── image14.gif │ │ │ │ ├── image15.gif │ │ │ │ ├── image16.gif │ │ │ │ └── image17.gif │ │ │ ├── TableLayout_files │ │ │ │ ├── info.gif │ │ │ │ ├── Header.gif │ │ │ │ ├── background.gif │ │ │ │ └── EmailTableLayout.jpg │ │ │ ├── feedback_files │ │ │ │ ├── Header.gif │ │ │ │ └── background.gif │ │ │ ├── info │ │ │ │ └── clearthought │ │ │ │ │ └── layout │ │ │ │ │ ├── TableLayout.class │ │ │ │ │ ├── SingleFiledLayout.class │ │ │ │ │ ├── TableLayout$Entry.class │ │ │ │ │ ├── TableLayoutConstants.class │ │ │ │ │ └── TableLayoutConstraints.class │ │ │ ├── sample.html │ │ │ ├── itox.html │ │ │ └── hypercube.html │ │ └── TableLayoutTutorialPart2.doc │ ├── TableLayoutTutorialPart1 │ │ ├── apps │ │ │ ├── Example1.jar │ │ │ ├── simple.jnlp │ │ │ ├── grid.jnlp │ │ │ ├── preferred.jnlp │ │ │ ├── typical.jnlp │ │ │ ├── gridbag.jnlp │ │ │ └── rad.jnlp │ │ ├── images │ │ │ ├── BlueBall.gif │ │ │ ├── FrameGrid.gif │ │ │ ├── Preferred.gif │ │ │ ├── RadAfter.gif │ │ │ ├── RadBefore.gif │ │ │ ├── TypicalGui.gif │ │ │ ├── LaunchExample.gif │ │ │ ├── RadOnStartup.gif │ │ │ ├── SimpleSnapshot.gif │ │ │ ├── GridVersusTable.gif │ │ │ ├── GridBagVersusTable1.gif │ │ │ ├── GridBagVersusTable2.gif │ │ │ ├── GridBagVersusTable3.gif │ │ │ ├── SimpleLineDiagram.gif │ │ │ └── TableLayout-Part1.gif │ │ └── TableLayoutTutorialPart1.doc │ └── JComboBoxFixed │ │ └── JComboBoxFixed.html ├── images │ ├── download.jpg │ ├── history.jpg │ ├── license.jpg │ ├── petition.jpg │ ├── discussion.jpg │ ├── tableDancer.jpg │ ├── tablelayout.gif │ ├── testimonies.jpg │ ├── JComboBoxFixed.jpg │ ├── totallyGridbag.gif │ └── tableDancerLarge.jpg ├── index.html └── general │ ├── history.html │ └── testimonies.html ├── extensions ├── info │ └── clearthought │ │ └── layout │ │ └── TableLayoutPersistenceDelegate.java └── example │ └── Persistent.java ├── .classpath ├── README.md ├── .project ├── .settings └── org.eclipse.jdt.core.prefs └── src ├── example ├── Simple.java ├── Launch.java ├── Preferred.java ├── GridVersusTable.java ├── TestAddition.java ├── GridBagVersusTable.java ├── TypicalGui.java └── BidiTest.java ├── exampleSupport ├── BlankPanel.java ├── BufferedPanel.java ├── BufferedFrame.java └── BlankLabel.java ├── example2 ├── Multicell.java ├── Scrolling1.java ├── MulticellJustify.java ├── Grid.java ├── Toggle1.java ├── Bidi.java ├── BorderSimple.java └── Toggle2.java └── info └── clearthought └── layout └── TableLayoutConstants.java /www/articles/TableLayoutTutorialPart2/MakePagesJar.bat: -------------------------------------------------------------------------------- 1 | cd pages 2 | jar -cf ../pages.jar * 3 | cd .. -------------------------------------------------------------------------------- /www/images/download.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/images/download.jpg -------------------------------------------------------------------------------- /www/images/history.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/images/history.jpg -------------------------------------------------------------------------------- /www/images/license.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/images/license.jpg -------------------------------------------------------------------------------- /www/images/petition.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/images/petition.jpg -------------------------------------------------------------------------------- /www/images/discussion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/images/discussion.jpg -------------------------------------------------------------------------------- /www/images/tableDancer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/images/tableDancer.jpg -------------------------------------------------------------------------------- /www/images/tablelayout.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/images/tablelayout.gif -------------------------------------------------------------------------------- /www/images/testimonies.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/images/testimonies.jpg -------------------------------------------------------------------------------- /www/images/JComboBoxFixed.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/images/JComboBoxFixed.jpg -------------------------------------------------------------------------------- /www/images/totallyGridbag.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/images/totallyGridbag.gif -------------------------------------------------------------------------------- /www/images/tableDancerLarge.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/images/tableDancerLarge.jpg -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/apps/Example1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart1/apps/Example1.jar -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/apps/Example2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/apps/Example2.jar -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/images/BlueBall.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart1/images/BlueBall.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/images/FrameGrid.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart1/images/FrameGrid.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/images/Preferred.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart1/images/Preferred.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/images/RadAfter.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart1/images/RadAfter.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/images/RadBefore.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart1/images/RadBefore.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/images/Multicell.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/images/Multicell.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/images/TypicalGui.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart1/images/TypicalGui.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/images/ExampleGrid.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/images/ExampleGrid.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/images/LaunchExample.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart1/images/LaunchExample.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/images/RadOnStartup.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart1/images/RadOnStartup.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/images/SimpleSnapshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart1/images/SimpleSnapshot.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/images/ExampleBorder1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/images/ExampleBorder1.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/images/ExampleBorder2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/images/ExampleBorder2.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/images/ExampleBorder3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/images/ExampleBorder3.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/images/ExampleToggle1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/images/ExampleToggle1.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/images/ExampleToggle2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/images/ExampleToggle2.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/images/LaunchExample.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/images/LaunchExample.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/images/MulticellGrid.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/images/MulticellGrid.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/example2/Bidi.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/example2/Bidi.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/example2/Grid.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/example2/Grid.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/itox_files/info.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/itox_files/info.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/images/GridVersusTable.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart1/images/GridVersusTable.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/TableLayoutTutorialPart1.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart1/TableLayoutTutorialPart1.doc -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/images/GridBagVersusTable1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart1/images/GridBagVersusTable1.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/images/GridBagVersusTable2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart1/images/GridBagVersusTable2.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/images/GridBagVersusTable3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart1/images/GridBagVersusTable3.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/images/SimpleLineDiagram.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart1/images/SimpleLineDiagram.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/images/TableLayout-Part1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart1/images/TableLayout-Part1.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/TableLayoutTutorialPart2.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/TableLayoutTutorialPart2.doc -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/images/TableLayout-Part2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/images/TableLayout-Part2.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/example2/Multicell.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/example2/Multicell.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/example2/Toggle1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/example2/Toggle1.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/example2/Toggle2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/example2/Toggle2.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube_files/info.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/hypercube_files/info.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/itox_files/emailMath.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/itox_files/emailMath.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/itox_files/itoxGraph.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/itox_files/itoxGraph.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/itox_files/itoxProof.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/itox_files/itoxProof.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/TableLayout_files/info.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/TableLayout_files/info.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/example2/Scrolling1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/example2/Scrolling1.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/example2/Scrolling2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/example2/Scrolling2.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/feedback_files/Header.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/feedback_files/Header.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/itox_files/background.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/itox_files/background.htm -------------------------------------------------------------------------------- /extensions/info/clearthought/layout/TableLayoutPersistenceDelegate.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/extensions/info/clearthought/layout/TableLayoutPersistenceDelegate.java -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/TableLayout_files/Header.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/TableLayout_files/Header.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/example2/BorderLeftMenu.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/example2/BorderLeftMenu.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/example2/BorderSimple.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/example2/BorderSimple.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/example2/BorderStatus.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/example2/BorderStatus.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/feedback_files/background.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/feedback_files/background.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image01.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image02.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image03.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image04.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image05.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image05.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image06.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image07.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image07.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image08.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image08.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image09.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image09.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image10.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image11.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image12.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image13.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image13.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image14.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image14.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image15.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image15.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image16.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image17.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/hypercube_files/image17.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/example2/MulticellJustify.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/example2/MulticellJustify.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/TableLayout_files/background.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/TableLayout_files/background.gif -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/example2/Scrolling2$Heading.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/example2/Scrolling2$Heading.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/example2/BorderStatus$Heading.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/example2/BorderStatus$Heading.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/example2/Scrolling2$StatusBar.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/example2/Scrolling2$StatusBar.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/TableLayout_files/EmailTableLayout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/TableLayout_files/EmailTableLayout.jpg -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/example2/BorderLeftMenu$Heading.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/example2/BorderLeftMenu$Heading.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/example2/BorderLeftMenu$StatusBar.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/example2/BorderLeftMenu$StatusBar.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/example2/BorderStatus$StatusBar.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/example2/BorderStatus$StatusBar.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/info/clearthought/layout/TableLayout.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/info/clearthought/layout/TableLayout.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/info/clearthought/layout/SingleFiledLayout.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/info/clearthought/layout/SingleFiledLayout.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/info/clearthought/layout/TableLayout$Entry.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/info/clearthought/layout/TableLayout$Entry.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/info/clearthought/layout/TableLayoutConstants.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/info/clearthought/layout/TableLayoutConstants.class -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/info/clearthought/layout/TableLayoutConstraints.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JFormDesigner/swing-tablelayout/HEAD/www/articles/TableLayoutTutorialPart2/pages/info/clearthought/layout/TableLayoutConstraints.class -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/sample.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sample Web Page 4 | 5 | 6 |

Welcome to our website.

7 | 8 |

Page underconstruction. Check back soon.

9 | 10 | 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TableLayout 2 | 3 | > This repo is a clone of the original SVN repo at https://java.net/projects/tablelayout/. 4 | > It is here for **archiving only** because the java.net forge will be discontinued soon. 5 | 6 | ## Links 7 | 8 | - http://www.clearthought.info/sun/products/jfc/tsc/articles/tablelayout/ 9 | 10 | ## License 11 | 12 | [The Clearthought Software License, Version 2.0](src/info/clearthought/layout/TableLayout.java) 13 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | tableLayout 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/apps/simple.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Simple 6 | Daniel E. Barbalace 7 | A simple application illustrating TableLayout 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/apps/grid.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Grid Versus TableLayout 6 | Daniel E. Barbalace 7 | A comparison of GridLayout and TableLayout 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/apps/preferred.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Preferred 6 | Daniel E. Barbalace 7 | An illustration of preferred row and column sizes 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/apps/typical.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Typical 6 | Daniel E. Barbalace 7 | A example of using TableLayout to construct a typical GUI 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | #Fri Apr 08 16:03:09 EDT 2005 2 | eclipse.preferences.version=1 3 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.4 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning 12 | org.eclipse.jdt.core.compiler.source=1.3 13 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/apps/gridbag.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | GridBag Versus TableLayout 6 | Daniel E. Barbalace 7 | A comparison of GridBagLayout and TableLayout 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart1/apps/rad.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A Simple RAD Tool 6 | Daniel E. Barbalace 7 | A example of using dynamic rows and columns to create a simple RAD tool. 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/itox.html: -------------------------------------------------------------------------------- 1 | The Barbalace Formula 2 | 3 | 4 | 5 | 6 | 7 |

8 |

9 |

Download this file as a MS Word document here.

10 |

Back to the mathematics page

11 |

Back to main page

12 |

You can email the author, Daniel Barbalace, at the following address:
13 |

14 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/apps/grid.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example: Grid 6 | Clearthought 7 | 8 | 9 | 10 | Demonstrates how to see the grid used by an instance of TableLayout. 11 | Displays the layout's grid 12 | Grid 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/apps/multicell.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example: Multicell 6 | Clearthought 7 | 8 | 9 | 10 | Demonstrates how to make components span cells with TableLayout. 11 | Components that span cells 12 | Multicell 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/apps/toggle1.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example: Toggling Rows 6 | Clearthought 7 | 8 | 9 | 10 | Demonstrates how to toggle the visibility of rows with TableLayout. 11 | Toggle the visibility of rows 12 | Toggle rows 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/apps/toggle2.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example: Toggling Groups of Rows 6 | Clearthought 7 | 8 | 9 | 10 | Demonstrates how to toggle the visibility of rows with TableLayout. 11 | Toggle the visibility of rows 12 | Toggle rows 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/apps/borderSimple.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example: Simple Border 6 | Clearthought 7 | 8 | 9 | 10 | Demonstrates how to create a simple border around a window with TableLayout. 11 | A simple border around a window 12 | Simple border 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/apps/bidi.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example: Component Orientation 6 | Clearthought 7 | 8 | 9 | 10 | Demonstrates how to use component orientation and new justifications with TableLayout. 11 | Uses component orientation and justifications 12 | Component Orientation 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/apps/scrolling1.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example: Simple Scrolling Effects 6 | Clearthought 7 | 8 | 9 | 10 | Demonstrates how to incorporate a scolling effect with TableLayout. 11 | Makes components move by scrolling their rows or columns 12 | Scrolling effect 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/apps/scrolling2.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example: Making an Entrance 6 | Clearthought 7 | 8 | 9 | 10 | Demonstrates a nice scolling effect to introduce a GUI using TableLayout. 11 | Makes components move by scrolling their rows or columns 12 | Scrolling effect 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/apps/borderLeftMenu.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example: Border with Left Menu 6 | Clearthought 7 | 8 | 9 | 10 | Demonstrates how to use a border and a left menu with TableLayout. 11 | Border with left menu, status bar, and heading 12 | Border with left menu 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/apps/multicellJustify.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example: Multicell Justification 6 | Clearthought 7 | 8 | 9 | 10 | Demonstrates how to justify components that span cells with TableLayout. 11 | Justify components that span cells 12 | Multicell Justified 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/apps/borderStatus.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example: Border with a Status Bar 6 | Clearthought 7 | 8 | 9 | 10 | Demonstrates how to implement a border between a heading and a status bar with TableLayout. 11 | A window with a border, a heading, and a status bar 12 | Border with a status bar 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/example/Simple.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | 4 | 5 | import java.awt.*; 6 | import java.awt.event.*; 7 | import info.clearthought.layout.TableLayout; 8 | 9 | 10 | 11 | public class Simple 12 | { 13 | 14 | 15 | 16 | public static void main (String args[]) 17 | { 18 | // Create a frame 19 | Frame frame = new Frame("Example of TableLayout"); 20 | frame.setBounds (100, 100, 300, 300); 21 | 22 | // Create a TableLayout for the frame 23 | double border = 10; 24 | double size[][] = 25 | {{border, 0.10, 20, TableLayout.FILL, 20, 0.20, border}, // Columns 26 | {border, 0.20, 20, TableLayout.FILL, 20, 0.20, border}}; // Rows 27 | 28 | TableLayout layout = new TableLayout(size); 29 | frame.setLayout (layout); 30 | 31 | // Create some buttons 32 | String label[] = {"Top", "Bottom", "Left", "Right", "Center", "Overlap"}; 33 | Button button[] = new Button[label.length]; 34 | 35 | for (int i = 0; i < label.length; i++) 36 | button[i] = new Button(label[i]); 37 | 38 | // Add buttons 39 | frame.add (button[0], "1, 1, 5, 1"); // Top 40 | frame.add (button[1], "1, 5, 5, 5"); // Bottom 41 | frame.add (button[2], "1, 3 "); // Left 42 | frame.add (button[3], "5, 3 "); // Right 43 | frame.add (button[4], "3, 3, leading, c"); // Center 44 | frame.add (button[5], "3, 3, trailing, c"); // Overlap 45 | 46 | // Allow user to close the window to terminate the program 47 | frame.addWindowListener 48 | (new WindowAdapter() 49 | { 50 | public void windowClosing (WindowEvent e) 51 | { 52 | System.exit (0); 53 | } 54 | } 55 | ); 56 | 57 | // Show frame 58 | frame.setVisible(true); 59 | frame.toFront(); 60 | 61 | System.out.println (layout.getConstraints(button[4])); 62 | System.out.println (layout.getConstraints(button[5])); 63 | } 64 | } -------------------------------------------------------------------------------- /src/example/Launch.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | 4 | 5 | import java.applet.*; 6 | import java.awt.*; 7 | import java.awt.event.*; 8 | import java.lang.reflect.*; 9 | import exampleSupport.Misc; 10 | 11 | 12 | 13 | /** 14 | * Used code like 15 |

16 | 17 | Enable Java to launch example. 18 | 19 | 20 |

21 | */ 22 | 23 | public class Launch extends Applet implements ActionListener 24 | { 25 | 26 | boolean start; 27 | private String className; 28 | private Button button; 29 | 30 | public void init () 31 | { 32 | setBackground (Color.white); 33 | className = getParameter("className"); 34 | start = true; 35 | 36 | button = new Button("Launch " + className); 37 | button.addActionListener (this); 38 | add (button); 39 | } 40 | 41 | public void actionPerformed (ActionEvent e) 42 | { 43 | try 44 | { 45 | if (start) 46 | { 47 | launch(); 48 | button.setLabel ("Close " + className); 49 | } 50 | else 51 | { 52 | dispose(); 53 | button.setLabel ("Launch " + className); 54 | } 55 | 56 | start = !start; 57 | } 58 | catch (Exception error) 59 | { 60 | error.printStackTrace(); 61 | } 62 | } 63 | 64 | public void launch () throws Exception 65 | { 66 | String paramList[] = {"[Ljava.lang.String;"}; 67 | Method method = Misc.getMethod(className, "main", paramList); 68 | 69 | Object parameter[] = {new String[0]}; 70 | method.invoke (null, parameter); 71 | } 72 | 73 | public void dispose () throws Exception 74 | { 75 | Frame frame[] = Frame.getFrames(); 76 | 77 | for (int i = 0; i < frame.length; i++) 78 | frame[i].dispose(); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/exampleSupport/BlankPanel.java: -------------------------------------------------------------------------------- 1 | package exampleSupport; 2 | 3 | 4 | 5 | import java.awt.*; 6 | import java.awt.event.*; 7 | 8 | 9 | 10 | /** 11 | * A BlankPanel is an invisible panel that can be used as a placeholder for 12 | * layout managers and as containers that do not have backgrounds. 13 | * 14 | * @author Daniel E. Barbalace 15 | */ 16 | 17 | public class BlankPanel extends Container 18 | implements java.awt.event.ComponentListener 19 | { 20 | 21 | 22 | 23 | private final static LayoutManager panelLayout = new FlowLayout(); 24 | 25 | 26 | 27 | /** 28 | * Constructs a BlankPanel with the default layout, FlowLayout. 29 | */ 30 | 31 | public BlankPanel () 32 | { 33 | // Call parent constructor 34 | super(); 35 | 36 | // Set default layout 37 | setLayout (panelLayout); 38 | 39 | // This class needs to be notified when it is resized so it can lay out its 40 | // components. Otherwise, layouts will lag one resize behind. 41 | addComponentListener (this); 42 | } 43 | 44 | 45 | 46 | //****************************************************************************** 47 | //** java.awt.event.ComponentListener methods *** 48 | //****************************************************************************** 49 | 50 | 51 | 52 | /** 53 | * Invoked when component has been resized. 54 | * 55 | *

Derived classes that override this method must call this method in 56 | * their version so that components are layed out properly.

57 | */ 58 | 59 | public void componentResized (ComponentEvent e) 60 | { 61 | // Tell the container class (parent) to layout components. Without this 62 | // line, the layout manager will lag one resize behind. 63 | if (e.getSource() == this) 64 | doLayout(); 65 | } 66 | 67 | 68 | 69 | /** 70 | *Invoked when component has been moved. 71 | */ 72 | 73 | public void componentMoved (ComponentEvent e) 74 | { 75 | } 76 | 77 | 78 | 79 | /** 80 | * Invoked when component has been shown. 81 | */ 82 | 83 | public void componentShown (ComponentEvent e) 84 | { 85 | } 86 | 87 | 88 | 89 | /** 90 | * Invoked when component has been hidden. 91 | */ 92 | 93 | public void componentHidden (ComponentEvent e) 94 | { 95 | } 96 | 97 | 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/example/Preferred.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | 4 | 5 | import java.awt.*; 6 | import javax.swing.*; 7 | import info.clearthought.layout.TableLayout; 8 | 9 | 10 | 11 | public class Preferred extends JFrame 12 | { 13 | 14 | 15 | 16 | public static void main (String args[]) 17 | { 18 | new Preferred(); 19 | } 20 | 21 | 22 | 23 | public Preferred () 24 | { 25 | super("The Power of Preferred Sizes"); 26 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 27 | Container pane = getContentPane(); 28 | 29 | // b - border 30 | // f - FILL 31 | // p - PREFERRED 32 | // vs - vertical space between labels and text fields 33 | // vg - vertical gap between form elements 34 | // hg - horizontal gap between form elements 35 | 36 | double b = 10; 37 | double f = TableLayout.FILL; 38 | double p = TableLayout.PREFERRED; 39 | double vs = 5; 40 | double vg = 10; 41 | double hg = 10; 42 | 43 | double size[][] = 44 | {{b, f, hg, p, hg, p, b}, 45 | {b, p, vs, p, vg, p, vs, p, vg, p, vs, p, vg, p, b}}; 46 | 47 | TableLayout layout = new TableLayout(size); 48 | pane.setLayout (layout); 49 | 50 | // Create all controls 51 | JLabel labelName = new JLabel("Name"); 52 | JLabel labelAddress = new JLabel("Address"); 53 | JLabel labelCity = new JLabel("City"); 54 | JLabel labelState = new JLabel("State"); 55 | JLabel labelZip = new JLabel("Zip"); 56 | 57 | JTextField textfieldName = new JTextField(10); 58 | JTextField textfieldAddress = new JTextField(20); 59 | JTextField textfieldCity = new JTextField(10); 60 | JTextField textfieldState = new JTextField(2); 61 | JTextField textfieldZip = new JTextField(5); 62 | 63 | JButton buttonOk = new JButton("OK"); 64 | JButton buttonCancel = new JButton("Cancel"); 65 | JPanel panelButton = new JPanel(); 66 | panelButton.add(buttonOk); 67 | panelButton.add(buttonCancel); 68 | 69 | // Add all controls 70 | pane.add(labelName, "1, 1, 5, 1"); 71 | pane.add(textfieldName, "1, 3, 5, 3"); 72 | pane.add(labelAddress, "1, 5, 5, 5"); 73 | pane.add(textfieldAddress, "1, 7, 5, 7"); 74 | pane.add(labelCity, "1, 9"); 75 | pane.add(textfieldCity, "1, 11"); 76 | pane.add(labelState, "3, 9"); 77 | pane.add(textfieldState, "3, 11"); 78 | pane.add(labelZip, "5, 9"); 79 | pane.add(textfieldZip, "5, 11"); 80 | pane.add(panelButton, "1, 13, 5, 13"); 81 | 82 | pack(); 83 | setResizable(false); 84 | setVisible(true); 85 | toFront(); 86 | } 87 | 88 | 89 | 90 | } 91 | -------------------------------------------------------------------------------- /src/example/GridVersusTable.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | 4 | 5 | import java.awt.*; 6 | import java.awt.event.*; 7 | import javax.swing.JButton; 8 | import info.clearthought.layout.TableLayout; 9 | 10 | 11 | 12 | public class GridVersusTable { 13 | 14 | 15 | 16 | protected static Frame showGridWindow () 17 | { 18 | // Create frame 19 | Frame frame = new Frame("GridLayout"); 20 | frame.setFont (new Font("Helvetica", Font.PLAIN, 14)); 21 | frame.setLayout (new GridLayout(2, 0)); 22 | 23 | // Create and add buttons 24 | frame.add (new JButton("One")); 25 | frame.add (new JButton("Two")); 26 | frame.add (new JButton("Three")); 27 | frame.add (new JButton("Four")); 28 | 29 | // Show frame 30 | frame.pack(); 31 | frame.setLocation (0, 10); 32 | frame.setVisible(true); 33 | frame.toFront(); 34 | 35 | return frame; 36 | } 37 | 38 | 39 | 40 | protected static Frame showTableWindow () 41 | { 42 | // Create frame 43 | Frame frame = new Frame("TableLayout"); 44 | frame.setFont (new Font("Helvetica", Font.PLAIN, 14)); 45 | 46 | // Set layout 47 | double f = TableLayout.FILL; 48 | double size[][] = {{f, f}, {f, f}}; 49 | frame.setLayout (new TableLayout(size)); 50 | 51 | // Create and add buttons 52 | frame.add (new JButton("One"), "0, 0"); 53 | frame.add (new JButton("Two"), "1, 0"); 54 | frame.add (new JButton("Three"), "0, 1"); 55 | frame.add (new JButton("Four"), "1, 1"); 56 | 57 | // Show frame 58 | frame.pack(); 59 | frame.setLocation (200, 10); 60 | frame.setVisible(true); 61 | frame.toFront(); 62 | 63 | return frame; 64 | } 65 | 66 | 67 | 68 | protected static Frame showTableWindow2 () 69 | { 70 | // Create frame 71 | Frame frame = new Frame("TableLayout"); 72 | frame.setFont (new Font("Helvetica", Font.PLAIN, 14)); 73 | 74 | // Set layout 75 | double f = TableLayout.FILL; 76 | double size[][] = {{f, f}, {f, f}}; 77 | frame.setLayout (new TableLayout(size)); 78 | 79 | // Create and add buttons 80 | frame.add (new JButton("One"), "0, 0"); 81 | frame.add (new JButton("Two"), "1, 1"); 82 | 83 | // Show frame 84 | frame.pack(); 85 | frame.setLocation (400, 10); 86 | frame.setVisible(true); 87 | frame.toFront(); 88 | 89 | return frame; 90 | } 91 | 92 | 93 | 94 | public static void main (String args[]) 95 | { 96 | WindowListener listener = 97 | (new WindowAdapter() 98 | { 99 | public void windowClosing (WindowEvent e) 100 | { 101 | System.exit (0); 102 | } 103 | } 104 | ); 105 | 106 | Frame frame = showGridWindow(); 107 | frame.addWindowListener(listener); 108 | 109 | frame = showTableWindow(); 110 | frame.addWindowListener(listener); 111 | 112 | frame = showTableWindow2(); 113 | frame.addWindowListener(listener); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/example/TestAddition.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | 4 | 5 | import java.awt.*; 6 | import java.awt.event.*; 7 | import javax.swing.*; 8 | import info.clearthought.layout.TableLayout; 9 | 10 | 11 | 12 | public class TestAddition extends Frame implements ActionListener 13 | { 14 | 15 | 16 | 17 | private JCheckBox buttonToggle; 18 | private Component hello; 19 | private JCheckBox checkboxRelayout; 20 | private JCheckBox checkboxTableLayout; 21 | private TableLayout tableLayout; 22 | private FlowLayout flowLayout; 23 | 24 | 25 | 26 | public static void main (String args[]) 27 | { 28 | new TestAddition(); 29 | } 30 | 31 | 32 | 33 | public TestAddition () 34 | { 35 | // Create a frame 36 | super("Test Addition"); 37 | setBounds (100, 100, 500, 300); 38 | 39 | // Create a TableLayout for the frame 40 | double border = 10; 41 | double f = TableLayout.FILL; 42 | double p = TableLayout.PREFERRED; 43 | double size[][] = 44 | {{border, p, p, p, border}, 45 | {border, f, p, border}}; 46 | 47 | tableLayout = new TableLayout(size); 48 | tableLayout.setVGap(10); 49 | tableLayout.setHGap(20); 50 | flowLayout = new FlowLayout(); 51 | setLayout (tableLayout); 52 | 53 | // Create and add controls 54 | buttonToggle = new JCheckBox("Toggle"); 55 | add(buttonToggle, "1, 2"); 56 | buttonToggle.addActionListener(this); 57 | 58 | hello = new JButton("Hello"); 59 | checkboxRelayout = new JCheckBox("Relayout and repaint", true); 60 | add (checkboxRelayout, "2, 2"); 61 | checkboxTableLayout = new JCheckBox("Use TableLayout", true); 62 | add (checkboxTableLayout, "3, 2"); 63 | checkboxTableLayout.addActionListener(this); 64 | 65 | // Allow user to close the window to terminate the program 66 | addWindowListener 67 | (new WindowAdapter() 68 | { 69 | public void windowClosing (WindowEvent e) 70 | { 71 | System.exit (0); 72 | } 73 | } 74 | ); 75 | 76 | // Show frame 77 | setVisible(true); 78 | toFront(); 79 | } 80 | 81 | 82 | 83 | public void actionPerformed (ActionEvent e) 84 | { 85 | Object source = e.getSource(); 86 | 87 | if (source == buttonToggle) 88 | { 89 | Container parent = hello.getParent(); 90 | 91 | if (parent == null) 92 | add(hello, "1, 1, 3, 1"); 93 | else 94 | parent.remove(hello); 95 | 96 | if (checkboxRelayout.isSelected()) 97 | { 98 | doLayout(); 99 | repaint(); 100 | } 101 | } 102 | else if (source == checkboxTableLayout) 103 | { 104 | if (checkboxTableLayout.isSelected()) 105 | setLayout(tableLayout); 106 | else 107 | setLayout(flowLayout); 108 | 109 | doLayout(); 110 | repaint(); 111 | } 112 | } 113 | 114 | 115 | 116 | } -------------------------------------------------------------------------------- /src/exampleSupport/BufferedPanel.java: -------------------------------------------------------------------------------- 1 | package exampleSupport; 2 | 3 | 4 | 5 | import java.awt.*; 6 | import java.awt.event.*; 7 | 8 | 9 | 10 | /** 11 | * BufferedPanel is a doubled buffered BlankPanel. 12 | * 13 | * @author Daniel E. Barbalace 14 | */ 15 | 16 | public class BufferedPanel extends BlankPanel 17 | { 18 | 19 | 20 | 21 | /** Offscreen buffer used for double buffering */ 22 | private Image offscreen; 23 | 24 | /** Offscreen buffer's graphics content */ 25 | private Graphics h; 26 | 27 | /** Size of offscreen buffer */ 28 | private Dimension o; 29 | 30 | 31 | 32 | /** 33 | * Constructs the panel. 34 | * 35 | * @param title text to display in window title area 36 | */ 37 | 38 | public BufferedPanel () 39 | { 40 | // Call parent constructor 41 | super(); 42 | 43 | // Initialize o 44 | o = new Dimension(0, 0); 45 | } 46 | 47 | 48 | 49 | /** 50 | * Updates this component. This method only does one thing: calls paint 51 | * . 52 | * 53 | * @param g Graphics context 54 | */ 55 | 56 | public void update (Graphics g) 57 | { 58 | paint (g); 59 | } 60 | 61 | 62 | 63 | /** 64 | * Renders this frame using double buffering. 65 | * 66 | * @param g graphics canvas 67 | */ 68 | 69 | public void paint (Graphics g) 70 | { 71 | // Make sure offscreen buffer exists 72 | if (h == null) 73 | // Abort painting, there is no space on which to draw 74 | return; 75 | 76 | // Call parent's paint 77 | super.paint (h); 78 | 79 | // Render canvas 80 | g.drawImage (offscreen, 0, 0, null); 81 | } 82 | 83 | 84 | 85 | /** 86 | * Creates the offscreen buffer used for double buffering. 87 | */ 88 | 89 | private void createOffscreenBuffer () 90 | { 91 | // Get size of panel 92 | o = getSize(); 93 | 94 | // Make sure both width and height are positive to avoid a non-fatal 95 | // exception when creating an image for double buffering 96 | if ((o.width <= 0) || (o.height <= 0)) 97 | // Abort function, there is no space on which to draw 98 | return; 99 | 100 | // Remove previous background image 101 | if (offscreen != null) 102 | { 103 | // GC 104 | offscreen.flush(); 105 | offscreen = null; 106 | System.gc(); 107 | } 108 | 109 | // Create offscreen canvas 110 | offscreen = Misc.createImage(o.width, o.height); 111 | h = offscreen.getGraphics(); 112 | } 113 | 114 | 115 | 116 | /** 117 | * Disposes of this panel and all the resources it uses. 118 | */ 119 | 120 | public void dispose () 121 | { 122 | // Dispose of offscreen canvas 123 | if (offscreen != null) 124 | offscreen.flush(); 125 | 126 | // Null all references 127 | h = null; 128 | o = null; 129 | offscreen = null; 130 | 131 | // Garbage collection 132 | System.gc(); 133 | } 134 | 135 | 136 | 137 | //****************************************************************************** 138 | //** java.awt.event.ComponentListener methods *** 139 | //****************************************************************************** 140 | 141 | 142 | 143 | /** 144 | * Invoked when component has been resized. 145 | * 146 | *

Derived classes that override this method must call this method.

147 | */ 148 | 149 | public void componentResized (ComponentEvent e) 150 | { 151 | // Call parent method 152 | super.componentResized (e); 153 | 154 | // Make sure the offscreen buffer is as large as the panel 155 | Dimension d = getSize(); 156 | 157 | if ((d.width > o.width) || (d.height > o.height)) 158 | createOffscreenBuffer(); 159 | 160 | // Erase previous image on offscreen canvas 161 | int imageWidth = offscreen.getWidth(null); 162 | int imageHeight = offscreen.getWidth(null); 163 | 164 | h.setColor (Color.white); 165 | h.fillRect (d.width, 0, imageWidth - d.width, imageHeight); 166 | h.fillRect (0, d.height, d.width, imageHeight - d.height); 167 | } 168 | 169 | 170 | 171 | } 172 | -------------------------------------------------------------------------------- /src/example/GridBagVersusTable.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | 4 | 5 | import java.awt.*; 6 | import java.awt.event.*; 7 | import javax.swing.JButton; 8 | import info.clearthought.layout.TableLayout; 9 | 10 | 11 | 12 | public class GridBagVersusTable 13 | { 14 | 15 | 16 | 17 | protected static void makeButton 18 | (Frame frame, String name, GridBagLayout gridbag, GridBagConstraints c) 19 | { 20 | JButton button = new JButton(name); 21 | gridbag.setConstraints(button, c); 22 | frame.add(button); 23 | } 24 | 25 | 26 | 27 | protected static Frame showGridBagWindow () 28 | { 29 | // Create layout and contraints object 30 | GridBagLayout gridbag = new GridBagLayout(); 31 | GridBagConstraints c = new GridBagConstraints(); 32 | 33 | // Create frame 34 | Frame frame = new Frame("GridBagLayout"); 35 | frame.setFont (new Font("Helvetica", Font.PLAIN, 14)); 36 | frame.setLayout (gridbag); 37 | 38 | // Create buttons, add buttons, and apply constraints 39 | c.fill = GridBagConstraints.BOTH; 40 | c.weightx = 1.0; 41 | makeButton (frame, "Button1", gridbag, c); 42 | makeButton (frame, "Button2", gridbag, c); 43 | makeButton (frame, "Button3", gridbag, c); 44 | 45 | c.gridwidth = GridBagConstraints.REMAINDER; //end of row 46 | makeButton (frame, "Button4", gridbag, c); 47 | 48 | c.weightx = 0.0; //reset to the default 49 | makeButton (frame, "Button5", gridbag, c); //another row 50 | 51 | c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last in row 52 | makeButton (frame, "Button6", gridbag, c); 53 | 54 | c.gridwidth = GridBagConstraints.REMAINDER; //end of row 55 | makeButton (frame, "Button7", gridbag, c); 56 | 57 | c.gridwidth = 1; //reset to the default 58 | c.gridheight = 2; 59 | c.weighty = 1.0; 60 | makeButton (frame, "Button8", gridbag, c); 61 | 62 | c.weighty = 0.0; //reset to the default 63 | c.gridwidth = GridBagConstraints.REMAINDER; //end of row 64 | c.gridheight = 1; //reset to the default 65 | makeButton (frame, "Button9", gridbag, c); 66 | makeButton (frame, "Button10", gridbag, c); 67 | 68 | // Show frame 69 | frame.pack(); 70 | frame.setLocation (0, 10); 71 | frame.setVisible(true); 72 | frame.toFront(); 73 | 74 | return frame; 75 | } 76 | 77 | 78 | 79 | protected static Frame showTableWindow () 80 | { 81 | // Create frame 82 | Frame frame = new Frame("TableLayout"); 83 | frame.setFont(new Font("Helvetica", Font.PLAIN, 14)); 84 | 85 | // Set layout 86 | double f = TableLayout.FILL; 87 | double p = TableLayout.PREFERRED; 88 | double size[][] = {{f, f, f, f}, {p, p, p, p, f}}; 89 | 90 | TableLayout layout = new TableLayout(size); 91 | frame.setLayout (layout); 92 | 93 | // Create buttons labeled Button1 to Button10 94 | int numButton = 10; 95 | JButton button[] = new JButton[numButton + 1]; 96 | 97 | for (int i = 1; i <= numButton; i++) 98 | button[i] = new JButton("Button" + i); 99 | 100 | // Add buttons 101 | frame.add (button[1], "0, 0"); 102 | frame.add (button[2], "1, 0"); 103 | frame.add (button[3], "2, 0"); 104 | frame.add (button[4], "3, 0"); 105 | frame.add (button[5], "0, 1, 3, 1"); 106 | frame.add (button[6], "0, 2, 2, 2"); 107 | frame.add (button[7], "3, 2, 3, 2"); 108 | frame.add (button[8], "0, 3, 0, 4"); 109 | frame.add (button[9], "1, 3, 3, 3"); 110 | frame.add (button[10], "1, 4, 3, 4"); 111 | 112 | // Show frame 113 | frame.pack(); 114 | frame.setLocation (400, 10); 115 | frame.setVisible(true); 116 | frame.toFront(); 117 | 118 | return frame; 119 | } 120 | 121 | 122 | 123 | public static void main (String args[]) 124 | { 125 | WindowListener listener = 126 | (new WindowAdapter() 127 | { 128 | public void windowClosing (WindowEvent e) 129 | { 130 | System.exit (0); 131 | } 132 | } 133 | ); 134 | 135 | Frame frame = showGridBagWindow(); 136 | frame.addWindowListener (listener); 137 | 138 | frame = showTableWindow(); 139 | frame.addWindowListener (listener); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/example/TypicalGui.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | 4 | 5 | import java.awt.*; 6 | import java.awt.event.*; 7 | import javax.swing.*; 8 | import info.clearthought.layout.TableLayout; 9 | 10 | 11 | 12 | public class TypicalGui extends JFrame 13 | { 14 | 15 | 16 | 17 | public static void main (String args[]) 18 | { 19 | new TypicalGui(); 20 | } 21 | 22 | 23 | 24 | public TypicalGui () 25 | { 26 | super ("A Typical GUI"); 27 | 28 | Container pane = getContentPane(); 29 | 30 | double b = 10; 31 | double f = TableLayout.FILL; 32 | double p = TableLayout.PREFERRED; 33 | double size[][] = {{b, f, 5, p, 5, p, b}, {p, b, f, 10, p, b}}; 34 | TableLayout layout = new TableLayout(size); 35 | pane.setLayout (layout); 36 | 37 | addMenu(pane); 38 | addCommandButtons(pane, layout); 39 | addColorBoxes(pane, layout); 40 | addTextArea(pane, layout); 41 | 42 | allowClosing(); 43 | setSize (640, 480); 44 | setVisible(true); 45 | toFront(); 46 | } 47 | 48 | 49 | 50 | public void addMenu (Container pane) 51 | { 52 | JMenuBar menuBar = new JMenuBar(); 53 | 54 | String menuText[] = {"File", "Edit", "View", "Help"}; 55 | String itemText[][] = 56 | {{"New", "Open", "Save", "Print", "Exit"}, 57 | {"Cut", "Copy", "Paste"}, 58 | {"Zoom in", "Zoom out"}, 59 | {"About", "Index", "Search"}}; 60 | 61 | for (int i = 0; i < menuText.length; i++) 62 | { 63 | JMenu menu = new JMenu(menuText[i]); 64 | menuBar.add (menu); 65 | 66 | for (int j = 0; j < itemText[i].length; j++) 67 | { 68 | JMenuItem item = new JMenuItem(itemText[i][j]); 69 | menu.add (item); 70 | } 71 | } 72 | 73 | pane.add (menuBar, "0, 0, 6, 0"); 74 | } 75 | 76 | 77 | 78 | public void addCommandButtons (Container pane, TableLayout layout) 79 | { 80 | JPanel buttonPanel = new JPanel(); 81 | pane.add (buttonPanel, "1, 4, 5, 4"); 82 | 83 | for (int i = 1; i <= 5; i++) 84 | { 85 | JButton button = new JButton("Button " + i); 86 | buttonPanel.add (button); 87 | } 88 | } 89 | 90 | 91 | 92 | public void addColorBoxes (Container pane, TableLayout layout) 93 | { 94 | Color color[][] = 95 | {{Color.white, Color.black}, 96 | {Color.green, Color.blue}, 97 | {Color.red, Color.yellow}, 98 | {Color.pink, Color.orange}, 99 | {Color.magenta, Color.cyan}}; 100 | 101 | for (int i = 0; i < color.length; i++) 102 | { 103 | // Add a row for spacing and a row for the color boxes 104 | layout.insertRow (2, TableLayout.PREFERRED); 105 | layout.insertRow (2, 5); 106 | 107 | // Add color boxes 108 | pane.add (new ColorBox(color[i][0]), "3, 3"); 109 | pane.add (new ColorBox(color[i][1]), "5, 3"); 110 | } 111 | 112 | // Remove the unnecessary leading space 113 | layout.deleteRow (2); 114 | } 115 | 116 | 117 | 118 | public void addTextArea (Container pane, TableLayout layout) 119 | { 120 | int numRow = layout.getRow().length; 121 | JTextPane textArea = new JTextPane(); 122 | pane.add (textArea, "1, 2, 1, " + (numRow - 4)); 123 | } 124 | 125 | 126 | 127 | public void allowClosing () 128 | { 129 | addWindowListener 130 | (new WindowAdapter() 131 | { 132 | public void windowClosing (WindowEvent e) 133 | { 134 | System.exit (0); 135 | } 136 | } 137 | ); 138 | } 139 | 140 | 141 | 142 | //************************************************************************** 143 | //*** Inner classes *** 144 | //************************************************************************** 145 | 146 | 147 | 148 | protected class ColorBox extends Component 149 | { 150 | protected Color color; 151 | 152 | protected ColorBox (Color color) 153 | { 154 | this.color = color; 155 | } 156 | 157 | public void update (Graphics g) 158 | { 159 | paint (g); 160 | } 161 | 162 | public void paint (Graphics g) 163 | { 164 | Dimension d = getSize(); 165 | g.setColor (Color.black); 166 | g.drawRect (0, 0, d.width - 1, d.height - 1); 167 | 168 | g.setColor (color); 169 | g.fillRect (1, 1, d.width - 1, d.height - 1); 170 | } 171 | 172 | public Dimension getPreferredSize () 173 | { 174 | return new Dimension(40, 20); 175 | } 176 | } 177 | 178 | 179 | 180 | } 181 | -------------------------------------------------------------------------------- /src/example/BidiTest.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | 4 | import java.awt.*; 5 | import java.awt.event.*; 6 | import java.io.*; 7 | import javax.swing.*; 8 | import info.clearthought.layout.TableLayout; 9 | 10 | 11 | 12 | /** 13 | * Test the bidirectional support of TableLayout. 14 | * 15 | * @version 1.0 Oct 28, 2003 16 | * @author Daniel E. Barbalace 17 | */ 18 | 19 | public class BidiTest extends JFrame implements ActionListener 20 | { 21 | 22 | 23 | private static final long serialVersionUID = 3616453405678186808L; 24 | 25 | 26 | 27 | private JCheckBox checkboxIsLtr; 28 | private JCheckBox checkboxIsHzn; 29 | private JCheckBox checkboxTableLayout; 30 | private TableLayout tableLayout; 31 | private FlowLayout flowLayout; 32 | 33 | 34 | 35 | /** 36 | * Runes the test 37 | * 38 | * @param args Command line arguments 39 | */ 40 | 41 | public static void main (String [] args) 42 | { 43 | new BidiTest(); 44 | } 45 | 46 | 47 | /** 48 | * Constructs the test GUI. 49 | */ 50 | 51 | public BidiTest () 52 | { 53 | super("Test BiDi Support"); 54 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 55 | 56 | flowLayout = new FlowLayout(); 57 | double [][] size = {{-1, -1, -1}, {-1}}; 58 | tableLayout = new TableLayout(size); 59 | Container container = getContentPane(); 60 | container.setLayout(tableLayout); 61 | 62 | checkboxIsLtr = new JCheckBox("Left to right", true); 63 | checkboxIsHzn = new JCheckBox("Horizontal", true); 64 | checkboxIsLtr.addActionListener(this); 65 | checkboxIsHzn.addActionListener(this); 66 | container.add(checkboxIsLtr, "0, 0, LD, C"); 67 | container.add(checkboxIsHzn, "1, 0, LD, C"); 68 | 69 | checkboxTableLayout = new JCheckBox("TableLayout", true); 70 | container.add(checkboxTableLayout, "2, 0"); 71 | checkboxTableLayout.addActionListener(this); 72 | 73 | int numButton = 3; 74 | 75 | for (int i = 0; i < numButton; i++) 76 | { 77 | JButton button = new JButton("Button " + i); 78 | tableLayout.insertColumn(i, -1); 79 | container.add(button, "" + i + ", 0"); 80 | } 81 | 82 | setBounds(100, 100, 640, 480); 83 | setVisible(true); 84 | toFront(); 85 | } 86 | 87 | 88 | 89 | /** 90 | * Invoked when an action is performed. 91 | */ 92 | 93 | public void actionPerformed (ActionEvent e) 94 | { 95 | Object source = e.getSource(); 96 | Container container = getContentPane(); 97 | 98 | if (source == checkboxTableLayout) 99 | { 100 | if (checkboxTableLayout.isSelected()) 101 | container.setLayout(tableLayout); 102 | else 103 | container.setLayout(flowLayout); 104 | 105 | container.doLayout(); 106 | } 107 | else if ((source == checkboxIsLtr) || (source == checkboxIsHzn)) 108 | { 109 | boolean ltr = checkboxIsLtr.isSelected(); 110 | boolean hzn = checkboxIsHzn.isSelected(); 111 | 112 | ComponentOrientation o = createComponentOrientation(ltr, hzn); 113 | applyComponentOrientation(o); 114 | container.doLayout(); 115 | repaint(); 116 | } 117 | } 118 | 119 | 120 | /** 121 | * Used to create ComponentOrientation objects. 122 | */ 123 | 124 | public ComponentOrientation createComponentOrientation 125 | (boolean ltr, boolean hzn) 126 | { 127 | try 128 | { 129 | int [] arrayInt = 130 | { 131 | 0xAC, 0xED, 0x00, 0x05, 0x73, 0x72, 0x00, 0x1D, 0x6A, 0x61, 132 | 0x76, 0x61, 0x2E, 0x61, 0x77, 0x74, 133 | 0x2E, 0x43, 0x6F, 0x6D, 0x70, 0x6F, 0x6E, 0x65, 0x6E, 0x74, 134 | 0x4F, 0x72, 0x69, 0x65, 0x6E, 0x74, 135 | 0x61, 0x74, 0x69, 0x6F, 0x6E, 0xC6, 0xEA, 0xA7, 0x45, 0xA1, 136 | 0x9C, 0x63, 0xCC, 0x02, 0x00, 0x01, 137 | 0x49, 0x00, 0x0B, 0x6F, 0x72, 0x69, 0x65, 0x6E, 0x74, 0x61, 138 | 0x74, 0x69, 0x6F, 0x6E, 0x78, 0x70, 139 | 0x00, 0x00, 0x00, 0x06 140 | }; 141 | 142 | int numByte = arrayInt.length; 143 | byte [] array = new byte[numByte]; 144 | 145 | for (int i = 0; i < numByte; i++) 146 | array[i] = (byte) arrayInt[i]; 147 | 148 | array[numByte - 1] = (byte) ((ltr ? 4 : 0) | (hzn ? 2 : 0)); 149 | 150 | ByteArrayInputStream sba = new ByteArrayInputStream(array); 151 | ObjectInputStream si = new ObjectInputStream(sba); 152 | ComponentOrientation o = (ComponentOrientation) si.readObject(); 153 | si.close(); 154 | return o; 155 | } 156 | catch (Exception e) 157 | { 158 | e.printStackTrace(); 159 | System.exit(1); 160 | } 161 | 162 | return null; 163 | } 164 | 165 | 166 | 167 | /** 168 | * Used to hack ComponentOrientation. 169 | */ 170 | 171 | public void serialize () 172 | { 173 | try 174 | { 175 | FileOutputStream fo = new FileOutputStream("ltr.ser"); 176 | ObjectOutputStream so = new ObjectOutputStream(fo); 177 | so.writeObject(ComponentOrientation.LEFT_TO_RIGHT); 178 | so.flush(); 179 | so.close(); 180 | 181 | fo = new FileOutputStream("rtl.ser"); 182 | so = new ObjectOutputStream(fo); 183 | so.writeObject(ComponentOrientation.RIGHT_TO_LEFT); 184 | so.flush(); 185 | so.close(); 186 | 187 | fo = new FileOutputStream("unk.ser"); 188 | so = new ObjectOutputStream(fo); 189 | so.writeObject(ComponentOrientation.UNKNOWN); 190 | so.flush(); 191 | so.close(); 192 | } 193 | catch (Exception e) 194 | { 195 | e.printStackTrace(); 196 | System.exit(1); 197 | } 198 | } 199 | 200 | 201 | 202 | } 203 | -------------------------------------------------------------------------------- /src/example2/Multicell.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================================== 3 | * 4 | * The Clearthought Software License, Version 1.0 5 | * 6 | * Copyright (c) 2001 Daniel Barbalace. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. The original software may not be altered. However, the classes 16 | * provided may be subclasses as long as the subclasses are not 17 | * packaged in the info.clearthought package or any subpackage of 18 | * info.clearthought. 19 | * 20 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 21 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR, AFFILATED BUSINESSES, 24 | * OR ANYONE ELSE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * ==================================================================== 33 | */ 34 | 35 | 36 | 37 | package example2; 38 | 39 | 40 | 41 | import java.awt.*; 42 | import javax.swing.*; 43 | import java.util.*; 44 | import info.clearthought.layout.TableLayout; 45 | 46 | 47 | 48 | /** 49 | * Example of components spanning cells. 50 | * 51 | * @author Daniel E. Barbalace 52 | * @version 1.0, June 14, 2005 53 | */ 54 | 55 | public class Multicell 56 | { 57 | 58 | 59 | 60 | /** 61 | * Runs the program. 62 | */ 63 | 64 | public static void main (String args[]) 65 | { 66 | // Create frame 67 | JFrame frame = new JFrame("Local Area Connection - Primary Properties"); 68 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 69 | 70 | // Items to display in list control 71 | Vector listElement = new Vector(); 72 | listElement.add("Client for Microsoft Networks"); 73 | listElement.add("File and Print Sharing for Microsoft Networks"); 74 | listElement.add("QoS Packet Scheduler"); 75 | listElement.add("Microsoft TCP/IP version 6"); 76 | listElement.add("Internet Protocol (TCP/IP"); 77 | 78 | // Create controls 79 | JLabel labelConnect = new JLabel("Connect using:"); 80 | JTextField textfieldConnect = new JTextField("Intel(R) PRO/100 VE Network Connection"); 81 | JButton buttonConfigure = new JButton("Configure..."); 82 | JLabel labelUse = new JLabel("This connection uses the following items:"); 83 | JList list = new JList(listElement); 84 | JScrollPane scrollPane = new JScrollPane(list); 85 | JButton buttonInstall = new JButton("Install"); 86 | JButton buttonUninstall = new JButton("Uninstall"); 87 | JButton buttonProperties = new JButton("Properties"); 88 | JCheckBox checkboxShowIcon = new JCheckBox("Show icon in notification area when connected"); 89 | JCheckBox checkboxNotify = new JCheckBox("Notify me when this connection has limited or no connectivity"); 90 | JButton buttonOK = new JButton("OK"); 91 | JButton buttonCancel = new JButton("Cancel"); 92 | 93 | // Create and set layout 94 | double p = TableLayout.PREFERRED; 95 | double border = 10; 96 | double emptySpace = 10; 97 | double [] columnSize = {border, 1.0 / 3.0, TableLayout.FILL, 1.0 / 3.0, border}; 98 | double [] rowSize = {border, border}; 99 | TableLayout layout = new TableLayout(columnSize, rowSize); 100 | layout.setVGap(2); 101 | layout.setHGap(5); 102 | Container container = frame.getContentPane(); 103 | container.setLayout(layout); 104 | 105 | // Add controls 106 | layout.insertRow(1, p); 107 | container.add(labelConnect, "1, 1, 3, 1"); 108 | layout.insertRow(2, p); 109 | container.add(textfieldConnect, "1, 2, 2, 2"); 110 | container.add(buttonConfigure, "3, 2"); 111 | layout.insertRow(3, emptySpace); 112 | layout.insertRow(4, p); 113 | container.add(labelUse, "1, 4, 3, 4"); 114 | layout.insertRow(5, TableLayout.FILL); 115 | container.add(scrollPane, "1, 5, 3, 5"); 116 | layout.insertRow(6, p); 117 | container.add(buttonInstall, "1, 6"); 118 | container.add(buttonUninstall, "2, 6"); 119 | container.add(buttonProperties, "3, 6"); 120 | layout.insertRow(7, emptySpace); 121 | layout.insertRow(8, p); 122 | container.add(checkboxShowIcon, "1, 8, 3, 8"); 123 | layout.insertRow(9, p); 124 | container.add(checkboxNotify, "1, 9, 3, 9"); 125 | layout.insertRow(10, emptySpace); 126 | layout.insertRow(11, p); 127 | container.add(buttonOK, "2, 11"); 128 | container.add(buttonCancel, "3, 11"); 129 | 130 | // Show frame 131 | frame.pack(); 132 | frame.setVisible(true); 133 | frame.toFront(); 134 | } 135 | 136 | 137 | 138 | } 139 | -------------------------------------------------------------------------------- /src/example2/Scrolling1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================================== 3 | * 4 | * The Clearthought Software License, Version 1.0 5 | * 6 | * Copyright (c) 2001 Daniel Barbalace. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. The original software may not be altered. However, the classes 16 | * provided may be subclasses as long as the subclasses are not 17 | * packaged in the info.clearthought package or any subpackage of 18 | * info.clearthought. 19 | * 20 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 21 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR, AFFILATED BUSINESSES, 24 | * OR ANYONE ELSE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * ==================================================================== 33 | */ 34 | 35 | 36 | 37 | package example2; 38 | 39 | 40 | 41 | import java.awt.*; 42 | import javax.swing.*; 43 | import info.clearthought.layout.TableLayout; 44 | 45 | 46 | 47 | /** 48 | * Example of components spanning cells. 49 | * 50 | * @author Daniel E. Barbalace 51 | * @version 1.0, June 21, 2005 52 | */ 53 | 54 | public class Scrolling1 implements Runnable 55 | { 56 | 57 | 58 | 59 | /** Delay between updates in milliseconds */ 60 | private static final int DELAY = 1000 / 60; 61 | 62 | /** Space devoted to left/right bouncing */ 63 | private static final int BOUNCE_SPACE = 200; 64 | 65 | /** Half of the above space */ 66 | private static final int BOUNCE_SPACE_2 = BOUNCE_SPACE / 2; 67 | 68 | /** Instance of TableLayout we are using */ 69 | private TableLayout layout; 70 | 71 | /** Container being laid out */ 72 | private Container container; 73 | 74 | /** Thread used to scroll top button */ 75 | private Thread threadTop; 76 | 77 | /** Thread used to scroll bottom buttom */ 78 | private Thread threadBottom; 79 | 80 | 81 | 82 | /** 83 | * Runs the program. 84 | */ 85 | 86 | public static void main (String args[]) 87 | { 88 | new Scrolling1(); 89 | } 90 | 91 | 92 | 93 | /** 94 | * Creates the app. 95 | */ 96 | 97 | public Scrolling1() 98 | { 99 | // Create frame 100 | JFrame frame = new JFrame("Example of scrolling components"); 101 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 102 | frame.setResizable(false); 103 | 104 | // Create controls 105 | JButton buttonTop = new JButton("Scrolling"); 106 | JButton buttonBottom = new JButton("By your command"); 107 | 108 | // Create and set layout 109 | double f = TableLayout.FILL; 110 | double p = TableLayout.PREFERRED; 111 | double [] columnSize = {0, p, BOUNCE_SPACE}; 112 | double [] rowSize = {0, f, p}; 113 | layout = new TableLayout(columnSize, rowSize); 114 | container = frame.getContentPane(); 115 | container.setLayout(layout); 116 | 117 | // Add controls 118 | container.add(buttonTop, "0, 0, 2, 0"); 119 | container.add(buttonBottom, "1, 2"); 120 | 121 | // Show frame 122 | Dimension d = frame.getPreferredSize(); 123 | frame.setSize(d.width, 200); 124 | frame.setVisible(true); 125 | frame.toFront(); 126 | 127 | // Start the scrolling effects 128 | threadTop = new Thread(this); 129 | threadBottom = new Thread(this); 130 | threadTop.start(); 131 | threadBottom.start(); 132 | } 133 | 134 | 135 | 136 | /** 137 | * Routes threads. 138 | */ 139 | 140 | public void run() 141 | { 142 | Thread thread = Thread.currentThread(); 143 | 144 | if (thread == threadTop) 145 | runTop(); 146 | else if (thread == threadBottom) 147 | runBottom(); 148 | } 149 | 150 | 151 | 152 | /** 153 | * Scrolls the top button into and out of existence. 154 | */ 155 | 156 | private void runTop() 157 | { 158 | double size = 0; 159 | double delta = 1; 160 | 161 | while (true) 162 | { 163 | size += delta; 164 | layout.setRow(0, size); 165 | container.invalidate(); 166 | container.validate(); 167 | 168 | if (size == 0) 169 | delta = 1; 170 | else if (size == 50) 171 | delta = -1; 172 | 173 | try {Thread.sleep(DELAY);} catch (InterruptedException e) {} 174 | } 175 | } 176 | 177 | 178 | 179 | /** 180 | * Scrolls the bottom button left and right. 181 | */ 182 | 183 | private void runBottom() 184 | { 185 | int counter = 0; 186 | 187 | while (true) 188 | { 189 | int offset = BOUNCE_SPACE_2 + (int) 190 | (BOUNCE_SPACE_2 * Math.sin(0.01 * Math.PI * counter++)); 191 | 192 | layout.setColumn(0, offset); 193 | layout.setColumn(2, BOUNCE_SPACE - offset); 194 | container.invalidate(); 195 | container.validate(); 196 | 197 | try {Thread.sleep(DELAY);} catch (InterruptedException e) {} 198 | } 199 | } 200 | 201 | 202 | 203 | } 204 | -------------------------------------------------------------------------------- /www/articles/JComboBoxFixed/JComboBoxFixed.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | JComboBoxFixed 7 | 8 | 9 |

Back to TableLayout project

10 | 11 |

License

12 |

13 | There is none. So don't even ask! This is public domain, no restrictions at all. Use it however you want. 14 |

15 | 16 |

Legal Disclaimer

17 |

18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 19 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR, AFFILATED BUSINESSES, 22 | OR ANYONE ELSE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 25 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 |

31 |

English Translation: Running this code might turn you into a werewolf. On the bright side, cool fangs!

32 |
33 | 34 |

How to use this class

35 |

36 | Where you were doing a JComboBox combo = new JComboBox(...); instead do 37 | JComboBoxFixed combo = new JComboBoxFixed(...);. 38 |

39 | 40 |

Source code for JComboBoxFixed.java

41 |
 42 | import java.awt.event.KeyEvent;
 43 | import java.lang.reflect.Field;
 44 | 
 45 | import javax.swing.JComboBox;
 46 | 
 47 | 
 48 | 
 49 | /**
 50 |  * A class that fixes the bug described in the Java bug database as bug 4199622.  See
 51 |  * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4199622.
 52 |  * 
 53 |  * Note that as this workaround uses some aspects of reflection, it will require elevated rights in WebStart, applets, and other
 54 |  * restricted Java runtimes.
 55 |  * 
 56 |  * @author Daniel E. Barbalace
 57 |  */
 58 | 
 59 | public class JComboBoxFixed extends JComboBox
 60 | {
 61 |     /** Used to prevent duplicate ActionEvents if the user presses [ENTER] on the item already selected. */
 62 |     private Object lastSelectedObject = null;
 63 |     
 64 |     
 65 |     
 66 |     /**
 67 |      * Overrides the JComboBox.processKeyEvent to alter the behavior of the [ENTER] key.  This implementation allows the
 68 |      * [ENTER] key to generate ActionEvents in place of the ones filtered by the overridden "setSelectedItem" method.
 69 |      */
 70 |     
 71 |     public void processKeyEvent (KeyEvent e)
 72 |     {
 73 |         boolean shouldFireActionEvent = false;
 74 |         
 75 |         if (e.getKeyCode() == KeyEvent.VK_ENTER && (e.getID() & KeyEvent.KEY_PRESSED) == KeyEvent.KEY_PRESSED)
 76 |         {
 77 |             Object currentlySelectedObject = getSelectedItem();
 78 |             
 79 |             if (currentlySelectedObject != null && currentlySelectedObject != lastSelectedObject)
 80 |                 shouldFireActionEvent = true;
 81 |             
 82 |             lastSelectedObject = currentlySelectedObject;
 83 |         }
 84 |         
 85 |         super.processKeyEvent(e);
 86 |         
 87 |         if (shouldFireActionEvent)
 88 |             fireActionEvent();
 89 |     }
 90 |     
 91 |     
 92 |     
 93 |     /**
 94 |      * Overrides the JComboBox.setSelectedItem to filter out the unwanted ActionEvents resulting from navigation of a JComboBox
 95 |      * using the arrow and paging keys.
 96 |      */
 97 |     
 98 |     public void setSelectedItem (Object anObject)
 99 |     {
100 |         boolean shouldFireActionEvent = true;
101 |         StackTraceElement [] listSte = Thread.currentThread().getStackTrace();
102 |         
103 |         for (StackTraceElement ste : listSte)
104 |         {
105 |             String methodName = ste.getMethodName();
106 |             
107 |             if ("processKeyBinding".equals(methodName))
108 |             {
109 |                 shouldFireActionEvent = false;
110 |                 break;
111 |             }
112 |             else if ("mouseReleased".equals(methodName))
113 |             {
114 |                 shouldFireActionEvent = true;
115 |                 break;
116 |             }
117 |         }
118 |         
119 |         if (shouldFireActionEvent)
120 |         {
121 |             super.setSelectedItem(anObject);
122 |         }
123 |         else
124 |         {
125 |             setFiringActionEvent(true);
126 |             super.setSelectedItem(anObject);
127 |             setFiringActionEvent(false);
128 |         }
129 |         
130 |     }
131 |     
132 |     
133 |     
134 |     /**
135 |      * Sets the value of the private field JComboBox.firingActionEvent.
136 |      * 
137 |      * This method demonstrates the dark side of the force.  You should never do what I'm doing in this method unless absolutely
138 |      * necessary.  I am only doing this because it is the least intrusive way of altering JComboBox to filter the unwanted
139 |      * ActionEvents.
140 |      * 
141 |      * @param value
142 |      *        Value to which to set the "firingActionEvent" field.
143 |      */
144 |     
145 |     private void setFiringActionEvent (boolean value)
146 |     {
147 |         try
148 |         {
149 |             Class  c = this.getClass().getSuperclass();
150 |             Field field = c.getDeclaredField("firingActionEvent");
151 |             field.setAccessible(true);
152 |             field.set(this, value);
153 |             field.setAccessible(false);
154 |         }
155 |         catch (NoSuchFieldException ex)
156 |         {
157 |             ex.printStackTrace();
158 |         }
159 |         catch (IllegalAccessException ex)
160 |         {
161 |             ex.printStackTrace();
162 |         }
163 |     }
164 | }
165 | 	  
166 | 167 | 168 | -------------------------------------------------------------------------------- /src/example2/MulticellJustify.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================================== 3 | * 4 | * The Clearthought Software License, Version 1.0 5 | * 6 | * Copyright (c) 2001 Daniel Barbalace. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. The original software may not be altered. However, the classes 16 | * provided may be subclasses as long as the subclasses are not 17 | * packaged in the info.clearthought package or any subpackage of 18 | * info.clearthought. 19 | * 20 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 21 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR, AFFILATED BUSINESSES, 24 | * OR ANYONE ELSE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * ==================================================================== 33 | */ 34 | 35 | 36 | 37 | package example2; 38 | 39 | 40 | 41 | import java.awt.*; 42 | import javax.swing.*; 43 | import java.util.*; 44 | import info.clearthought.layout.TableLayout; 45 | 46 | 47 | 48 | /** 49 | * Example of components spanning cells and using justification. 50 | * 51 | * @author Daniel E. Barbalace 52 | * @version 1.0, June 14, 2005 53 | */ 54 | 55 | public class MulticellJustify 56 | { 57 | 58 | 59 | 60 | /** 61 | * Runs the program. 62 | */ 63 | 64 | public static void main (String args[]) 65 | { 66 | // Create frame 67 | JFrame frame = new JFrame("Local Area Connection - Primary Properties"); 68 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 69 | 70 | // Items to display in list control 71 | Vector listElement = new Vector(); 72 | listElement.add("Client for Microsoft Networks"); 73 | listElement.add("File and Print Sharing for Microsoft Networks"); 74 | listElement.add("QoS Packet Scheduler"); 75 | listElement.add("Microsoft TCP/IP version 6"); 76 | listElement.add("Internet Protocol (TCP/IP"); 77 | 78 | // Create controls 79 | JLabel labelConnect = new JLabel("Connect using:"); 80 | JTextField textfieldConnect = new JTextField("Intel(R) PRO/100 VE Network Connection"); 81 | JButton buttonConfigure = new JButton("Configure..."); 82 | JLabel labelUse = new JLabel("This connection uses the following items:"); 83 | JList list = new JList(listElement); 84 | JScrollPane scrollPane = new JScrollPane(list); 85 | JButton buttonInstall = new JButton("Install"); 86 | JButton buttonUninstall = new JButton("Uninstall"); 87 | JButton buttonProperties = new JButton("Properties"); 88 | JCheckBox checkboxShowIcon = new JCheckBox("Show icon in notification area when connected"); 89 | JCheckBox checkboxNotify = new JCheckBox("Notify me when this connection has limited or no connectivity"); 90 | JButton buttonOK = new JButton("OK"); 91 | JButton buttonCancel = new JButton("Cancel"); 92 | 93 | // Give buttons a definitive preferred size independent of their labels 94 | Dimension preferredSize = new Dimension(123, 26); 95 | buttonConfigure.setPreferredSize(preferredSize); 96 | buttonInstall.setPreferredSize(preferredSize); 97 | buttonUninstall.setPreferredSize(preferredSize); 98 | buttonProperties.setPreferredSize(preferredSize); 99 | buttonOK.setPreferredSize(preferredSize); 100 | buttonCancel.setPreferredSize(preferredSize); 101 | 102 | // Create and set layout 103 | double p = TableLayout.PREFERRED; 104 | double border = 10; 105 | double emptySpace = 10; 106 | double [] columnSize = {border, 1.0 / 3.0, TableLayout.FILL, 1.0 / 3.0, border}; 107 | double [] rowSize = {border, border}; 108 | TableLayout layout = new TableLayout(columnSize, rowSize); 109 | layout.setVGap(2); 110 | layout.setHGap(5); 111 | Container container = frame.getContentPane(); 112 | container.setLayout(layout); 113 | 114 | // Place OK and cancel buttons in a panel so that they can be laid out 115 | // independently of all other controls 116 | JPanel panelButton = new JPanel(); 117 | TableLayout layoutPanel = new TableLayout(new double [][] {{p, p}, {p}}); 118 | layoutPanel.setHGap(5); 119 | panelButton.setLayout(layoutPanel); 120 | panelButton.add(buttonOK, "0, 0"); 121 | panelButton.add(buttonCancel, "1, 0"); 122 | 123 | // Add controls 124 | layout.insertRow(1, p); 125 | container.add(labelConnect, "1, 1, 3, 1"); 126 | layout.insertRow(2, p); 127 | container.add(textfieldConnect, "1, 2, 2, 2"); 128 | container.add(buttonConfigure, "3, 2"); 129 | layout.insertRow(3, emptySpace); 130 | layout.insertRow(4, p); 131 | container.add(labelUse, "1, 4, 3, 4"); 132 | layout.insertRow(5, TableLayout.FILL); 133 | container.add(scrollPane, "1, 5, 3, 5"); 134 | layout.insertRow(6, p); 135 | container.add(buttonInstall, "1, 6, LEFT, TOP"); 136 | container.add(buttonUninstall, "2, 6, CENTER, TOP"); 137 | container.add(buttonProperties, "3, 6, RIGHT, TOP"); 138 | layout.insertRow(7, emptySpace); 139 | layout.insertRow(8, p); 140 | container.add(checkboxShowIcon, "1, 8, 3, 8"); 141 | layout.insertRow(9, p); 142 | container.add(checkboxNotify, "1, 9, 3, 9"); 143 | layout.insertRow(10, emptySpace); 144 | layout.insertRow(11, p); 145 | container.add(panelButton, "1, 11, 3, 11, RIGHT, TOP"); 146 | 147 | // Show frame 148 | frame.pack(); 149 | frame.setVisible(true); 150 | frame.toFront(); 151 | } 152 | 153 | 154 | 155 | } 156 | -------------------------------------------------------------------------------- /src/example2/Grid.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================================== 3 | * 4 | * The Clearthought Software License, Version 1.0 5 | * 6 | * Copyright (c) 2001 Daniel Barbalace. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. The original software may not be altered. However, the classes 16 | * provided may be subclasses as long as the subclasses are not 17 | * packaged in the info.clearthought package or any subpackage of 18 | * info.clearthought. 19 | * 20 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 21 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR, AFFILATED BUSINESSES, 24 | * OR ANYONE ELSE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * ==================================================================== 33 | */ 34 | 35 | 36 | 37 | package example2; 38 | 39 | 40 | 41 | import java.awt.*; 42 | import java.lang.reflect.*; 43 | import javax.swing.*; 44 | import info.clearthought.layout.*; 45 | 46 | 47 | 48 | /** 49 | * This class can show a grid on top of any container that uses TableLayout. 50 | * 51 | * @author Daniel E. Barbalace 52 | * @version 1.0, Jun 14, 2005 53 | */ 54 | 55 | public final class Grid extends Component 56 | { 57 | 58 | 59 | 60 | private static Color gridColor = Color.BLACK; 61 | private static Color fillColor = null; 62 | 63 | 64 | 65 | /** 66 | * Runs the program. 67 | */ 68 | 69 | public static void main (String args[]) 70 | { 71 | setFillColor(Color.BLUE); 72 | String className = "example2.MulticellJustify"; 73 | 74 | if (args.length == 1) 75 | className = args[0]; 76 | 77 | try 78 | { 79 | Class cls = Class.forName(className); 80 | Class [] parameterType = {args.getClass()}; 81 | Object [] parameter = {new String[0]}; 82 | Method method = cls.getMethod("main", parameterType); 83 | method.invoke(null, parameter); 84 | 85 | Frame [] frame = Frame.getFrames(); 86 | 87 | if (frame.length == 1) 88 | { 89 | if (frame[0] instanceof JFrame) 90 | showGrid(((JFrame) frame[0]).getContentPane()); 91 | else 92 | showGrid(frame[0]); 93 | } 94 | } 95 | catch (Exception e) 96 | { 97 | e.printStackTrace(); 98 | } 99 | } 100 | 101 | 102 | 103 | /** 104 | * Shows a grid on a given container provided that the container uses 105 | * TableLayout. 106 | * 107 | * @param container container using TableLayout. May not be null. 108 | */ 109 | 110 | public static void showGrid (Container container) 111 | { 112 | if (container == null) 113 | throw new IllegalArgumentException("Parameter container cannot be null"); 114 | 115 | LayoutManager l = container.getLayout(); 116 | 117 | if (!(l instanceof TableLayout)) 118 | throw new IllegalArgumentException("Container is not using TableLayout"); 119 | 120 | TableLayout layout = (TableLayout) l; 121 | 122 | showGrid(container, layout); 123 | 124 | container.invalidate(); 125 | container.validate(); 126 | container.repaint(); 127 | } 128 | 129 | 130 | 131 | /** 132 | * Shows a grid on a given container provided that the container uses 133 | * TableLayout. 134 | * 135 | * @param container container using TableLayout. May not be null. 136 | * @param layout TableLayout instance used by container. May not be null. 137 | */ 138 | 139 | private static void showGrid (Container container, TableLayout layout) 140 | { 141 | int numRow = layout.getNumRow(); 142 | int numCol = layout.getNumColumn(); 143 | 144 | for (int y = 0; y < numRow; y++) 145 | for (int x = 0; x < numCol; x++) 146 | { 147 | Grid g = new Grid(); 148 | container.add(g, new TableLayoutConstraints(x, y), 0); 149 | } 150 | } 151 | 152 | 153 | 154 | /** 155 | * Gets the grid color. 156 | * 157 | * @return the grid color 158 | */ 159 | 160 | public static Color getGridColor() 161 | { 162 | return gridColor; 163 | } 164 | 165 | 166 | 167 | /** 168 | * Sets the grid color. 169 | * 170 | * @param color new grid color 171 | */ 172 | 173 | public static void setGridColor (Color color) 174 | { 175 | gridColor = color; 176 | } 177 | 178 | 179 | 180 | /** 181 | * Gets the fill color. 182 | * 183 | * @return the fill color 184 | */ 185 | 186 | public static Color getFillColor() 187 | { 188 | return fillColor; 189 | } 190 | 191 | 192 | 193 | /** 194 | * Sets the fill color. 195 | * 196 | * @param color new fill color 197 | */ 198 | 199 | public static void setFillColor (Color color) 200 | { 201 | fillColor = color; 202 | } 203 | 204 | 205 | 206 | /** 207 | * Prevent creation of instances outside of this class. 208 | */ 209 | 210 | private Grid() 211 | { 212 | } 213 | 214 | 215 | 216 | /** 217 | * Renders the component. 218 | * 219 | * @param g graphics canvas 220 | */ 221 | 222 | public void paint (Graphics g) 223 | { 224 | Dimension d = getSize(); 225 | 226 | if (gridColor != null) 227 | { 228 | g.setColor(gridColor); 229 | g.drawRect(0, 0, d.width - 1, d.height - 1); 230 | } 231 | 232 | if (fillColor != null) 233 | { 234 | Graphics2D g2d = (Graphics2D) g; 235 | g2d.setComposite 236 | (AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.25f)); 237 | g2d.setPaint(fillColor); 238 | g2d.fill(new Rectangle(1, 1, d.width - 1, d.height - 1)); 239 | } 240 | } 241 | 242 | 243 | 244 | } 245 | -------------------------------------------------------------------------------- /src/example2/Toggle1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================================== 3 | * 4 | * The Clearthought Software License, Version 1.0 5 | * 6 | * Copyright (c) 2001 Daniel Barbalace. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. The original software may not be altered. However, the classes 16 | * provided may be subclasses as long as the subclasses are not 17 | * packaged in the info.clearthought package or any subpackage of 18 | * info.clearthought. 19 | * 20 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 21 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR, AFFILATED BUSINESSES, 24 | * OR ANYONE ELSE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * ==================================================================== 33 | */ 34 | 35 | 36 | 37 | package example2; 38 | 39 | 40 | 41 | import java.awt.*; 42 | import java.awt.event.*; 43 | import javax.swing.*; 44 | import java.util.*; 45 | import info.clearthought.layout.TableLayout; 46 | 47 | 48 | 49 | /** 50 | * Example of components spanning cells. 51 | * 52 | * @author Daniel E. Barbalace 53 | * @version 1.0, June 14, 2005 54 | */ 55 | 56 | public class Toggle1 implements ActionListener 57 | { 58 | 59 | 60 | 61 | /** Instance of TableLayout we are using */ 62 | private static TableLayout layout; 63 | 64 | /** Checkbox that indicates whether or not to notify the user when the 65 | Internet connection goes down. */ 66 | private static JCheckBox checkboxNotify; 67 | 68 | /** Container using the layout */ 69 | private static Container container; 70 | 71 | 72 | 73 | /** 74 | * Runs the program. 75 | */ 76 | 77 | public static void main (String args[]) 78 | { 79 | // Create frame 80 | JFrame frame = new JFrame("Local Area Connection - Primary Properties"); 81 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 82 | 83 | // Items to display in list control 84 | Vector listElement = new Vector(); 85 | listElement.add("Client for Microsoft Networks"); 86 | listElement.add("File and Print Sharing for Microsoft Networks"); 87 | listElement.add("QoS Packet Scheduler"); 88 | listElement.add("Microsoft TCP/IP version 6"); 89 | listElement.add("Internet Protocol (TCP/IP"); 90 | 91 | // Create controls 92 | JLabel labelConnect = new JLabel("Connect using:"); 93 | JTextField textfieldConnect = new JTextField("Intel(R) PRO/100 VE Network Connection"); 94 | JButton buttonConfigure = new JButton("Configure..."); 95 | JLabel labelUse = new JLabel("This connection uses the following items:"); 96 | JList list = new JList(listElement); 97 | JScrollPane scrollPane = new JScrollPane(list); 98 | JButton buttonInstall = new JButton("Install"); 99 | JButton buttonUninstall = new JButton("Uninstall"); 100 | JButton buttonProperties = new JButton("Properties"); 101 | JCheckBox checkboxShowIcon = new JCheckBox("Show icon in notification area when connected"); 102 | checkboxNotify = new JCheckBox("Notify me when this connection has limited or no connectivity"); 103 | checkboxNotify.addActionListener(new Toggle1()); 104 | JLabel labelTimeout = new JLabel("Timeout:"); 105 | JTextField textfieldTimeout = new JTextField(); 106 | JButton buttonOK = new JButton("OK"); 107 | JButton buttonCancel = new JButton("Cancel"); 108 | 109 | // Create and set layout 110 | double p = TableLayout.PREFERRED; 111 | double border = 10; 112 | double emptySpace = 10; 113 | double [] columnSize = {border, 1.0 / 3.0, TableLayout.FILL, 1.0 / 3.0, border}; 114 | double [] rowSize = {border, border}; 115 | layout = new TableLayout(columnSize, rowSize); 116 | layout.setVGap(2); 117 | layout.setHGap(5); 118 | container = frame.getContentPane(); 119 | container.setLayout(layout); 120 | 121 | // Add controls 122 | layout.insertRow(1, p); 123 | container.add(labelConnect, "1, 1, 3, 1"); 124 | layout.insertRow(2, p); 125 | container.add(textfieldConnect, "1, 2, 2, 2"); 126 | container.add(buttonConfigure, "3, 2"); 127 | layout.insertRow(3, emptySpace); 128 | layout.insertRow(4, p); 129 | container.add(labelUse, "1, 4, 3, 4"); 130 | layout.insertRow(5, TableLayout.FILL); 131 | container.add(scrollPane, "1, 5, 3, 5"); 132 | layout.insertRow(6, p); 133 | container.add(buttonInstall, "1, 6"); 134 | container.add(buttonUninstall, "2, 6"); 135 | container.add(buttonProperties, "3, 6"); 136 | layout.insertRow(7, emptySpace); 137 | layout.insertRow(8, p); 138 | container.add(checkboxShowIcon, "1, 8, 3, 8"); 139 | layout.insertRow(9, p); 140 | container.add(checkboxNotify, "1, 9, 3, 9"); 141 | layout.insertRow(10, p); 142 | container.add(labelTimeout, "1, 10, RIGHT, CENTER"); 143 | container.add(textfieldTimeout, "2, 10, 3, 10"); 144 | layout.insertRow(11, emptySpace); 145 | layout.insertRow(12, p); 146 | container.add(buttonOK, "2, 12"); 147 | container.add(buttonCancel, "3, 12"); 148 | 149 | // Note: We don't want to show the timeout row initially because the 150 | // checkbox will not be checked. However, we want to include the 151 | // timeout row's height in the calculation done by Frame.pack(). 152 | // So we call updateDynamicRows() after pack() has been called. 153 | 154 | // Show frame 155 | frame.pack(); 156 | updateDynamicRows(); 157 | frame.setVisible(true); 158 | frame.toFront(); 159 | } 160 | 161 | 162 | 163 | /** 164 | * Invoked when the checkbox is toggled. 165 | */ 166 | 167 | public void actionPerformed (ActionEvent e) 168 | { 169 | updateDynamicRows(); 170 | } 171 | 172 | 173 | 174 | /** 175 | * Updates the visibility of dynamic rows. 176 | */ 177 | 178 | private static void updateDynamicRows() 179 | { 180 | layout.setRow(10, checkboxNotify.isSelected() ? TableLayout.PREFERRED : 0); 181 | container.invalidate(); 182 | container.validate(); 183 | } 184 | 185 | 186 | 187 | } 188 | -------------------------------------------------------------------------------- /www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | TableLayout Home Page 4 | 5 | 6 | 7 | 8 | 9 |

TableLayout

10 | 11 |

12 | Welcome to the TableLayout project homepage! 13 |

14 | 15 |

16 | TableLayout is a totally free layout manager designed to make creating user interfaces 17 | fast and easy. It can do anything GridBagLayout can do and much, much more. Yet it 18 | is remarkably simple and easy to use. 19 |

20 | 21 |

22 | TableLayout uses concepts that everyone is familiar with such as spreadsheet-like 23 | rows, columns, and cells; and word processing justifications like left, center, right, 24 | and full. Consequentially, creating interfaces takes minutes instead of hours. 25 | Read the tutorial articles below to quickly get familiar with TableLayout. 26 | Once you do, you will never want to use another layout manager again! 27 |

28 | 29 |

30 | Since its publication in 2002, TableLayout has rapidly become the most popular third 31 | party layout manager in the world. References to it can be found in languages from 32 | German to Japanese, and it has been used as a teaching aid in classes taught at 33 | the Massachusetts Institute of Technology (MIT). Join the thousands of developers 34 | who have been liberated from tedious GUI programming. 35 |

36 | 37 |

Download

38 | 39 | 40 | 46 | 53 | 54 | 55 | 56 | 62 | 69 | 70 |
41 | 42 | 43 | 44 | 45 | 47 | 48 | Current Release 49 | 50 |

51 | Binaries, source, JavaDoc, and extensions... 52 |
 
57 | 58 | 59 | 60 | 61 | 63 | 64 | License 65 | 66 |

67 | The license for TableLayout. 68 |
71 | 72 |

Commnunity

73 | 74 | 75 | 81 | 88 | 89 | 90 | 91 | 97 | 104 | 105 |
76 | 77 | 78 | 79 | 80 | 82 | 83 | Testimonies 84 | 85 |

86 | Quotes from software engineers who have used TableLayout and provided unsolicited feedback... 87 |
 
92 | 93 | 94 | 95 | 96 | 98 | 99 | History 100 | 101 |

102 | The history and future of TableLayout. 103 |
106 | 107 |

Articles

108 | 109 | 110 | 116 | 125 | 126 | 127 | 128 | 134 | 142 | 143 | 144 | 145 | 151 | 163 | 164 |
111 | 112 | 113 | 114 | 115 | 117 | 118 | TableLayout Tutorial, Part 1: Introduction 119 | 120 |

121 | Tired of using GridBagLayout or nesting panels to get the layout you want? 122 | Learn about TableLayout and what it can do for you. Write GUIs in minutes 123 | instead of hours. 124 |
 
129 | 130 | 131 | 132 | 133 | 135 | 136 | TableLayout Tutorial, Part 2: Building Powerful GUIs 137 | 138 |

139 | Create much more powerful interfaces using techiques such as cell spanning, toggling 140 | groups of controls, scrolling, and component orientation. 141 |
 
146 | 147 | 148 | 149 | 150 | 152 | 153 | Table Dancer 154 | 155 |

156 | This is an article about TableLayout that was published by the German software magazine 157 | Javamagazin. An English translation provided by Google is 158 | here. 160 | A larger copy of the picture to the left is provided 161 | here. 162 |
165 | 166 |

Humor

167 | 168 | 169 | 175 | 182 | 183 |
170 | 171 | 172 | 173 | 174 | 176 | 177 | Totally Gridbag: An animated weblog entry 178 | 179 |

180 | A funny flash cartoon illustrating the frustrations of using layout managers. 181 |
184 | 185 |

Other Stuff

186 | 187 | 188 | 194 | 201 | 202 |
189 | 190 | 191 | 192 | 193 | 195 | 196 | JComboBoxFixed 197 | 198 |

199 | A fix for a bug in JComboBox that causes ActionEvents to be fired when navigating by keys. 200 |
203 | 204 | 206 | 207 | 208 | -------------------------------------------------------------------------------- /extensions/example/Persistent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================================== 3 | * 4 | * The Clearthought Software License, Version 2.0 5 | * 6 | * Copyright (c) 2001 Daniel Barbalace. All rights reserved. 7 | * 8 | * Project maintained at https://tablelayout.dev.java.net 9 | * 10 | * I. Terms for redistribution of original source and binaries 11 | * 12 | * Redistribution and use of unmodified source and/or binaries are 13 | * permitted provided that the following condition is met: 14 | * 15 | * 1. Redistributions of original source code must retain the above 16 | * copyright notice and license. You are not required to redistribute 17 | * the original source; you may choose to redistribute only the 18 | * binaries. 19 | * 20 | * Basically, if you distribute unmodified source, you meet 21 | * automatically comply with the license with no additional effort on 22 | * your part. 23 | * 24 | * II. Terms for distribution of derived works via subclassing and/or 25 | * composition. 26 | * 27 | * You may generate derived works by means of subclassing and/or 28 | * composition (e.g., the Adaptor Pattern), provided that the following 29 | * conditions are met: 30 | * 31 | * 1. Redistributions of original source code must retain the above 32 | * copyright notice and license. You are not required to redistribute 33 | * the original source; you may choose to redistribute only the 34 | * binaries. 35 | * 36 | * 2. The original software is not altered. 37 | * 38 | * 3. Derived works are not contained in the info.clearthought 39 | * namespace/package or any subpackage of info.clearthought. 40 | * 41 | * 4. Derived works do not use the class or interface names from the 42 | * info.clearthought... packages 43 | * 44 | * For example, you may define a class with the following full name: 45 | * org.nameOfMyOrganization.layouts.RowMajorTableLayout 46 | * 47 | * However, you may not define a class with the either of the 48 | * following full names: 49 | * info.clearthought.layout.RowMajorTableLayout 50 | * org.nameOfMyOrganization.layouts.TableLayout 51 | * 52 | * III. Terms for redistribution of source modified via patch files. 53 | * 54 | * You may generate derived works by means of patch files provided 55 | * that the following conditions are met: 56 | * 57 | * 1. Redistributions of original source code must retain the above 58 | * copyright notice and license. You are not required to 59 | * redistribute the original source; you may choose to redistribute 60 | * only the binaries resulting from the patch files. 61 | * 62 | * 2. The original source files are not altered. All alteration is 63 | * done in patch files. 64 | * 65 | * 3. Derived works are not contained in the info.clearthought 66 | * namespace/package or any subpackage of info.clearthought. This 67 | * means that your patch files must change the namespace/package 68 | * for the derived work. See section II for examples. 69 | * 70 | * 4. Derived works do not use the class or interface names from the 71 | * info.clearthought... packages. This means your patch files 72 | * must change the names of the interfaces and classes they alter. 73 | * See section II for examples. 74 | * 75 | * 5. Derived works must include the following disclaimer. 76 | * "This work is derived from Clearthought's TableLayout, 77 | * https://tablelayout.dev.java.net, by means of patch files 78 | * rather than subclassing or composition. Therefore, this work 79 | * might not contain the latest fixes and features of TableLayout." 80 | * 81 | * IV. Terms for repackaging, transcoding, and compiling of binaries. 82 | * 83 | * You may do any of the following with the binaries of the 84 | * original software. 85 | * 86 | * 1. You may move binaries (.class files) from the original .jar file 87 | * to your own .jar file. 88 | * 89 | * 2. You may move binaries from the original .jar file to other 90 | * resource containing files, including but not limited to .zip, 91 | * .gz, .tar, .dll, .exe files. 92 | * 93 | * 3. You may backend compile the binaries to any platform, including 94 | * but not limited to Win32, Win64, MAC OS, Linux, Palm OS, any 95 | * handheld or embedded platform. 96 | * 97 | * 4. You may transcribe the binaries to other virtual machine byte 98 | * code protocols, including but not limited to .NET. 99 | * 100 | * V. License Disclaimer. 101 | * 102 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 103 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 104 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 105 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR, AFFILATED BUSINESSES, 106 | * OR ANYONE ELSE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 107 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 108 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 109 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 110 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 111 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 112 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 113 | * SUCH DAMAGE. 114 | * ==================================================================== 115 | */ 116 | 117 | package example; 118 | 119 | 120 | 121 | import java.awt.*; 122 | import java.awt.event.*; 123 | import info.clearthought.layout.*; 124 | 125 | 126 | 127 | public class Persistent extends WindowAdapter implements WindowListener 128 | { 129 | 130 | 131 | 132 | public static void main (String args[]) 133 | { 134 | Frame frame = new Frame("reshow"); 135 | frame.setBounds (100, 100, 300, 300); 136 | 137 | double size[][] = 138 | {{-2.0, 10.0, 50.0, -1.0, 10.0}, // Columns 139 | {-2.0, 10.0, 0.25, -1.0, 10.0}}; // Rows 140 | 141 | frame.setLayout (new TableLayout(size)); 142 | 143 | Button button; 144 | button = new Button("3, 3, R, C"); 145 | frame.add (button, "3, 3, R, C"); 146 | button = new Button("3, 3, L, T"); 147 | frame.add (button, "3, 3, L, T"); 148 | button = new Button("2, 3, C, T"); 149 | frame.add (button, "2, 3, C, T"); 150 | button = new Button("3, 2, L, C"); 151 | frame.add (button, "3, 2, L, C"); 152 | button = new Button("2, 2, F, F"); 153 | frame.add (button, "2, 2, F, F"); 154 | button = new Button("3, 3, C, C"); 155 | frame.add (button, "3, 3, C, C"); 156 | frame.addWindowListener(new Persistent()); 157 | frame.show(); 158 | } 159 | 160 | 161 | 162 | public void windowClosing (WindowEvent e) 163 | { 164 | try 165 | { 166 | Frame window = (Frame) e.getSource(); 167 | 168 | if (window.getTitle().equals("reshow")) 169 | { 170 | TableLayoutPersistenceDelegate.writeContainer("Test.xml", window); 171 | window.dispose(); 172 | 173 | window = (Frame) 174 | TableLayoutPersistenceDelegate.readWindow("Test.xml"); 175 | window.setTitle("don't reshow"); 176 | window.addWindowListener(new Persistent()); 177 | window.setVisible(true); 178 | window.toFront(); 179 | } 180 | else 181 | System.exit(0); 182 | } 183 | catch (Exception exception) 184 | { 185 | exception.printStackTrace(); 186 | } 187 | } 188 | 189 | 190 | 191 | } 192 | -------------------------------------------------------------------------------- /src/example2/Bidi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================================== 3 | * 4 | * The Clearthought Software License, Version 1.0 5 | * 6 | * Copyright (c) 2001 Daniel Barbalace. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. The original software may not be altered. However, the classes 16 | * provided may be subclasses as long as the subclasses are not 17 | * packaged in the info.clearthought package or any subpackage of 18 | * info.clearthought. 19 | * 20 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 21 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR, AFFILATED BUSINESSES, 24 | * OR ANYONE ELSE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * ==================================================================== 33 | */ 34 | 35 | 36 | 37 | package example2; 38 | 39 | 40 | 41 | import java.awt.*; 42 | import java.awt.event.*; 43 | import javax.swing.*; 44 | import info.clearthought.layout.TableLayout; 45 | 46 | 47 | 48 | /** 49 | * This example shows how to use component orientation and the corresponding 50 | * justifications. 51 | * 52 | * @author Daniel E. Barbalace 53 | * @version 1.0, Jun 27, 2005 54 | */ 55 | 56 | public class Bidi implements ActionListener 57 | { 58 | 59 | 60 | /** Application's frame */ 61 | private JFrame frame; 62 | 63 | /** Menu to select left to right component orientation */ 64 | private JMenuItem menuLtr; 65 | 66 | /** Menu to select right to left component orientation */ 67 | private JMenuItem menuRtl; 68 | 69 | /** Menu to select the unknown component orientation */ 70 | private JMenuItem menuUnknown; 71 | 72 | 73 | 74 | /** 75 | * Runs the program. 76 | */ 77 | 78 | public static void main (String args[]) 79 | { 80 | new Bidi(); 81 | } 82 | 83 | 84 | 85 | /** 86 | * Creates the application's GUI. 87 | */ 88 | 89 | public Bidi() 90 | { 91 | // Create frame 92 | frame = new JFrame("Component Orientation and Bidirectional Support"); 93 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 94 | Container pane = frame.getContentPane(); 95 | 96 | // Create menu 97 | JMenuBar menuBar = new JMenuBar(); 98 | frame.setJMenuBar(menuBar); 99 | JMenu menu = new JMenu("Component Orientation"); 100 | menuBar.add(menu); 101 | menuLtr = new JCheckBoxMenuItem("Left to right"); 102 | menuRtl = new JCheckBoxMenuItem("Right to left"); 103 | menuUnknown = new JCheckBoxMenuItem("Unknown"); 104 | menu.add(menuLtr); 105 | menu.add(menuRtl); 106 | menu.add(menuUnknown); 107 | menuLtr.addActionListener(this); 108 | menuRtl.addActionListener(this); 109 | menuUnknown.addActionListener(this); 110 | menuLtr.setSelected(true); 111 | 112 | // Create all controls 113 | JLabel labelName = new JLabel("Name"); 114 | JLabel labelAddress = new JLabel("Address"); 115 | JLabel labelCity = new JLabel("City"); 116 | JLabel labelState = new JLabel("State"); 117 | JLabel labelZip = new JLabel("Zip"); 118 | 119 | JTextField textfieldName = new JTextField(10); 120 | JTextField textfieldAddress = new JTextField(20); 121 | JTextField textfieldCity = new JTextField(10); 122 | JTextField textfieldState = new JTextField(2); 123 | JTextField textfieldZip = new JTextField(5); 124 | 125 | JButton buttonOk = new JButton("OK"); 126 | JButton buttonCancel = new JButton("Cancel"); 127 | JPanel panelButton = new JPanel(); 128 | panelButton.add(buttonOk); 129 | panelButton.add(buttonCancel); 130 | 131 | // Create and set layout 132 | // b - border 133 | // f - FILL 134 | // p - PREFERRED 135 | // vs - vertical space between labels and text fields 136 | // vg - vertical gap between form elements 137 | // hg - horizontal gap between form elements 138 | 139 | double b = 10; 140 | double f = TableLayout.FILL; 141 | double p = TableLayout.PREFERRED; 142 | double vs = 5; 143 | double vg = 10; 144 | double hg = 10; 145 | 146 | double size[][] = 147 | {{b, f, hg, p, hg, p, b}, 148 | {b, p, vs, p, vg, p, vs, p, vg, p, vs, p, vg, f, p, b}}; 149 | 150 | TableLayout layout = new TableLayout(size); 151 | pane.setLayout (layout); 152 | 153 | // Add all controls 154 | pane.add(labelName, "1, 1, 5, 1, LEADING, BOTTOM"); 155 | pane.add(textfieldName, "1, 3, 5, 3"); 156 | pane.add(labelAddress, "1, 5, 5, 5, LEADING, BOTTOM"); 157 | pane.add(textfieldAddress, "1, 7, 5, 7"); 158 | pane.add(labelCity, "1, 9, LEADING, BOTTOM"); 159 | pane.add(textfieldCity, "1, 11"); 160 | pane.add(labelState, "3, 9, LEADING, BOTTOM"); 161 | pane.add(textfieldState, "3, 11, LEADING, BOTTOM"); 162 | pane.add(labelZip, "5, 9, LEADING, BOTTOM"); 163 | pane.add(textfieldZip, "5, 11"); 164 | pane.add(panelButton, "1, 14, 5, 14"); 165 | 166 | frame.pack(); 167 | frame.setResizable(false); 168 | frame.setVisible(true); 169 | } 170 | 171 | 172 | 173 | /** 174 | * Invoked when one of the menu items is selected. 175 | */ 176 | 177 | public void actionPerformed (ActionEvent e) 178 | { 179 | Object source = e.getSource(); 180 | 181 | if (source == menuLtr) 182 | { 183 | frame.applyComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); 184 | menuLtr.setSelected(true); 185 | menuRtl.setSelected(false); 186 | menuUnknown.setSelected(false); 187 | } 188 | else if (source == menuRtl) 189 | { 190 | frame.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); 191 | menuLtr.setSelected(false); 192 | menuRtl.setSelected(true); 193 | menuUnknown.setSelected(false); 194 | } 195 | else if (source == menuUnknown) 196 | { 197 | frame.applyComponentOrientation(ComponentOrientation.UNKNOWN); 198 | menuLtr.setSelected(false); 199 | menuRtl.setSelected(false); 200 | menuUnknown.setSelected(true); 201 | } 202 | 203 | frame.invalidate(); 204 | frame.validate(); 205 | } 206 | 207 | 208 | 209 | } 210 | -------------------------------------------------------------------------------- /src/info/clearthought/layout/TableLayoutConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================================== 3 | * 4 | * The Clearthought Software License, Version 2.0 5 | * 6 | * Copyright (c) 2001 Daniel Barbalace. All rights reserved. 7 | * 8 | * Project maintained at https://tablelayout.dev.java.net 9 | * 10 | * I. Terms for redistribution of original source and binaries 11 | * 12 | * Redistribution and use of unmodified source and/or binaries are 13 | * permitted provided that the following condition is met: 14 | * 15 | * 1. Redistributions of original source code must retain the above 16 | * copyright notice and license. You are not required to redistribute 17 | * the original source; you may choose to redistribute only the 18 | * binaries. 19 | * 20 | * Basically, if you distribute unmodified source, you meet 21 | * automatically comply with the license with no additional effort on 22 | * your part. 23 | * 24 | * II. Terms for distribution of derived works via subclassing and/or 25 | * composition. 26 | * 27 | * You may generate derived works by means of subclassing and/or 28 | * composition (e.g., the Adaptor Pattern), provided that the following 29 | * conditions are met: 30 | * 31 | * 1. Redistributions of original source code must retain the above 32 | * copyright notice and license. You are not required to redistribute 33 | * the original source; you may choose to redistribute only the 34 | * binaries. 35 | * 36 | * 2. The original software is not altered. 37 | * 38 | * 3. Derived works are not contained in the info.clearthought 39 | * namespace/package or any subpackage of info.clearthought. 40 | * 41 | * 4. Derived works do not use the class or interface names from the 42 | * info.clearthought... packages 43 | * 44 | * For example, you may define a class with the following full name: 45 | * org.nameOfMyOrganization.layouts.RowMajorTableLayout 46 | * 47 | * However, you may not define a class with the either of the 48 | * following full names: 49 | * info.clearthought.layout.RowMajorTableLayout 50 | * org.nameOfMyOrganization.layouts.TableLayout 51 | * 52 | * III. Terms for redistribution of source modified via patch files. 53 | * 54 | * You may generate derived works by means of patch files provided 55 | * that the following conditions are met: 56 | * 57 | * 1. Redistributions of original source code must retain the above 58 | * copyright notice and license. You are not required to 59 | * redistribute the original source; you may choose to redistribute 60 | * only the binaries resulting from the patch files. 61 | * 62 | * 2. The original source files are not altered. All alteration is 63 | * done in patch files. 64 | * 65 | * 3. Derived works are not contained in the info.clearthought 66 | * namespace/package or any subpackage of info.clearthought. This 67 | * means that your patch files must change the namespace/package 68 | * for the derived work. See section II for examples. 69 | * 70 | * 4. Derived works do not use the class or interface names from the 71 | * info.clearthought... packages. This means your patch files 72 | * must change the names of the interfaces and classes they alter. 73 | * See section II for examples. 74 | * 75 | * 5. Derived works must include the following disclaimer. 76 | * "This work is derived from Clearthought's TableLayout, 77 | * https://tablelayout.dev.java.net, by means of patch files 78 | * rather than subclassing or composition. Therefore, this work 79 | * might not contain the latest fixes and features of TableLayout." 80 | * 81 | * IV. Terms for repackaging, transcoding, and compiling of binaries. 82 | * 83 | * You may do any of the following with the binaries of the 84 | * original software. 85 | * 86 | * 1. You may move binaries (.class files) from the original .jar file 87 | * to your own .jar file. 88 | * 89 | * 2. You may move binaries from the original .jar file to other 90 | * resource containing files, including but not limited to .zip, 91 | * .gz, .tar, .dll, .exe files. 92 | * 93 | * 3. You may backend compile the binaries to any platform, including 94 | * but not limited to Win32, Win64, MAC OS, Linux, Palm OS, any 95 | * handheld or embedded platform. 96 | * 97 | * 4. You may transcribe the binaries to other virtual machine byte 98 | * code protocols, including but not limited to .NET. 99 | * 100 | * V. License Disclaimer. 101 | * 102 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 103 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 104 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 105 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR, AFFILATED BUSINESSES, 106 | * OR ANYONE ELSE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 107 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 108 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 109 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 110 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 111 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 112 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 113 | * SUCH DAMAGE. 114 | * ==================================================================== 115 | */ 116 | 117 | package info.clearthought.layout; 118 | 119 | 120 | 121 | /** 122 | * TableLayoutConstants define the constants used by all the TableLayout 123 | * classes. 124 | * 125 | * @version 3.0 February 15, 2004 126 | * @author Daniel E. Barbalace 127 | */ 128 | 129 | public interface TableLayoutConstants 130 | { 131 | 132 | 133 | 134 | /** Indicates that the component is left justified in its cell */ 135 | public static final int LEFT = 0; 136 | 137 | /** Indicates that the component is top justified in its cell */ 138 | public static final int TOP = 0; 139 | 140 | /** Indicates that the component is centered in its cell */ 141 | public static final int CENTER = 1; 142 | 143 | /** Indicates that the component is full justified in its cell */ 144 | public static final int FULL = 2; 145 | 146 | /** Indicates that the component is bottom justified in its cell */ 147 | public static final int BOTTOM = 3; 148 | 149 | /** Indicates that the component is right justified in its cell */ 150 | public static final int RIGHT = 3; 151 | 152 | /** Indicates that the component is leading justified in its cell. 153 | Leading justification means components are left justified if their container 154 | is left-oriented and right justified if their container is right-oriented. 155 | Trailing justification is opposite. 156 | see java.awt.Component#getComponentOrientation */ 157 | public static final int LEADING = 4; 158 | 159 | /** Indicates that the component is trailing justified in its cell. 160 | Trailing justification means components are right justified if their 161 | container is left-oriented and left justified if their container is 162 | right-oriented. Leading justification is opposite. 163 | see java.awt.Component#getComponentOrientation */ 164 | public static final int TRAILING = 5; 165 | 166 | /** Indicates that the row/column should fill the available space */ 167 | public static final double FILL = -1.0; 168 | 169 | /** Indicates that the row/column should be allocated just enough space to 170 | accommodate the preferred size of all components contained completely within 171 | this row/column. */ 172 | public static final double PREFERRED = -2.0; 173 | 174 | /** Indicates that the row/column should be allocated just enough space to 175 | accommodate the minimum size of all components contained completely within 176 | this row/column. */ 177 | public static final double MINIMUM = -3.0; 178 | 179 | 180 | 181 | } 182 | -------------------------------------------------------------------------------- /www/general/history.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | TableLayout Testimonies 4 | 5 | 6 | 7 | 8 | 9 |

History and Future

10 | 11 |

12 | TableLayout is a well-tested and well-used layout manager. It has been around in one form or another 13 | since 1996. Over many years, TableLayout has been refined. It may now be as perfect as a layout manager 14 | can be. So it is unlikely that there will be subsequent version unless someone suggests a change that 15 | would significantly improve Tablelayout, and that change must be added to the core of TableLayout. 16 |

17 | 18 |

19 | However, ancillary support for TableLayout may be added to this site. Some suggestions have been to add 20 | TableLayout support to Netbeans, Forte, JBuilder, and other RAD tools. Since such ancillary "plug-ins" 21 | are not necessary to use TableLayout, and may be tool or JDK specific, they would be provided as 22 | extension jar files. 23 |

24 | 25 |

26 | The main goal of the TableLayout project is to submit TableLayout to Sun for entry into JDK 1.6. 27 | If you would like to see this happen, you can voice your opinion 28 | here. 29 |

30 | 31 |

32 | The brief history of TableLayout is... 33 |

34 | 35 | 36 | 37 | 38 | 43 | 44 | 45 | 46 | 47 | 48 | 59 | 60 | 61 | 62 | 63 | 64 | 69 | 70 | 71 | 72 | 73 | 74 | 78 | 79 | 80 | 81 | 82 | 83 | 87 | 88 | 89 | 90 | 91 | 92 | 101 | 102 | 103 | 104 | 105 | 106 | 109 | 110 | 111 | 112 | 113 | 114 | 117 | 118 | 119 | 120 | 121 | 122 | 125 | 126 | 127 | 128 | 129 | 130 | 136 | 137 | 138 | 139 | 140 | 143 | 144 | 145 | 146 | 147 | 148 | 152 | 153 | 154 | 155 | 156 | 157 | 162 | 163 | 164 | 165 | 166 | 167 | 171 | 172 | 173 | 174 | 175 | 176 | 180 | 181 | 182 | 183 | 184 | 185 | 190 | 191 |
1996-2001 39 | TableLayout was written to the JDK 1.0 and JDK 1.1 using custom classes for LinkedLists, etc. 40 | This version of TableLayout was never published, but was used by the author extensively. 41 | Most of the layout manager was written up front, but over time a few useful features were added. 42 |
 
2001 49 | TableLayout was modified to use only core Java classes from the JDK including the JDK 1.2 collections 50 | framework. Non-standard classes were removed. The API for TableLayout was modified to be more 51 | consistent with established Java conventions.

52 | 53 | The author contacted Sun and submitted the layout manager. A Sun representative asked the author 54 | to write an article about TableLayout for The Swing Connection. The article was submitted to Sun 55 | and reviewed along with the layout manager by several Sun architects. TableLayout was further 56 | refined based on the feedback from Sun. The article and TableLayout were published on Sun's 57 | website. This was the first official version of TableLayout. 58 |
 
2002 65 | The author received many positive messages from users across the world. Some of the messages 66 | contained requests for features like justification for components occupying more than one cell. 67 | The requests that would most improve TableLayout were implemented. 68 |
 
2002 75 | An extension jar for TableLayout was created based on an idea from a developer to use the 76 | persistent delagation mechanism introduced in JDK 1.4 to save and load frames. 77 |
 
2003 Oct 1 84 | A fix is provided for a problem dealing with the preferred size of containers containing 85 | components spanning multiple cells with absolute widths/heights. 86 |
 
2003 Nov 4 93 | TableLayout now supports component orientation. Two new justifcations have been added: 94 | LEADING and TRAILING. Leading justification means components are left justified if 95 | their container is left-oriented and right justified if their container is right-oriented. 96 | Trailing justification is opposite.

97 | 98 | Also, a constructor in the form new TableLayout(double [] columns, double [] rows) 99 | has been added for convenience. 100 |
 
2003 Dec 11 107 | Corrected vertical gaps. 108 |
 
2004 Feb 15 115 | Added leading and trailing constaints to TableLayoutConstraints.toString method. 116 |
 
2004 May 9 123 | Added caching of the methodGetComponentOrientation field in TableLayout. 124 |
 
2005 April 8 131 | Fixed leak of XML Decoder in TableLayoutPersistenceDelegate class located in TableLayoutPersistenceDelegate.jar.
132 | Fixed a javadoc comment for TableLayoutConstraints constructor.
133 | Fixed a bug in getting the minimum size of a container that used preferred column/row sizes and getting 134 | the preferred size of a container that used minimum column/row sizes. 135 |
 
2005 May 5 141 | Updated the javadoc description of TableLayout. 142 |
 
2005 June 15 149 | Added convenience constructors to TableLayoutConstraints. Fixed the sizes of cell spanning components 150 | that were not full justified. They were getting extra space from gaps. 151 |
 
2005 September 14 158 | TableLayout no longer flips container insets for right-to-left oriented containers since most java.awt 159 | layouts and Swing components do not (FlowLayout is the exception). Minor performance tweak in 160 | the layoutContainer method. Compatibility fix with old JDKs that did not support component orientation. 161 |
 
2007 March 6 168 | TableLayoutConstraints constructor was setting LEADING justification to FULL due to an omission. 169 | Fixed this constructor. 170 |
 
2009 May 10 177 | Adjusted calculation for preferred and minimum sizes of a column/row to consider gaps that contribute to the size 178 | of a multicell component. Updated license to be more compatible with most open source licenses. 179 |
 
2009 August 26 186 | Added ComponentArranger builder for creating layouts. Change access setting of insertCr from public to protected. 187 | Users should call insertColumn or insertRow instead. Fixed many spelling errors in JavaDoc. (Thanks to Eclipse 188 | for including a spellchecker!) 189 |
192 | 193 |

194 | Back to project home 195 |

196 | 197 | 198 | -------------------------------------------------------------------------------- /src/exampleSupport/BufferedFrame.java: -------------------------------------------------------------------------------- 1 | package exampleSupport; 2 | 3 | 4 | 5 | import java.awt.*; 6 | import java.awt.event.*; 7 | 8 | 9 | 10 | /** 11 | * This class implements a double buffered window that closes when the user 12 | * presses the "close window" button. 13 | * 14 | * @author Daniel E. Barbalace 15 | */ 16 | 17 | public class BufferedFrame extends Frame implements 18 | java.awt.event.WindowListener, 19 | java.awt.event.ComponentListener 20 | { 21 | 22 | 23 | 24 | 25 | /** Offscreen buffer used for double buffering */ 26 | protected Image offscreen; 27 | 28 | /** Offscreen buffer's graphics content */ 29 | protected Graphics h; 30 | 31 | /** Size of offscreen buffer */ 32 | protected Dimension o; 33 | 34 | /** Smallest size the window may be */ 35 | protected Dimension smallest; 36 | 37 | 38 | 39 | /** 40 | * Constructs the frame. 41 | */ 42 | 43 | public BufferedFrame () 44 | { 45 | this (null); 46 | } 47 | 48 | 49 | 50 | /** 51 | * Constructs the frame. 52 | * 53 | * @param title text to display in window title area 54 | */ 55 | 56 | public BufferedFrame (String title) 57 | { 58 | // Call parent constructor 59 | super (title); 60 | 61 | // Set minum size to default to 0x0 62 | smallest = new Dimension(0, 0); 63 | 64 | // Initialize double buffering 65 | this.offscreen = null; 66 | this.h = null; 67 | 68 | // This class is its own window listener so it can handle window events 69 | addWindowListener (this); 70 | 71 | // Prevent going below minimum size and generate offscreen buffer for 72 | // double buffering 73 | addComponentListener (this); 74 | 75 | // Create offscreen canvas for double buffering 76 | createOffscreenBuffer(); 77 | } 78 | 79 | 80 | 81 | /** 82 | * Sets the minimum size of this window. If the window is resized to be 83 | * smaller than this size, the window will be enlarged enough to meet this size. 84 | * 85 | * @param size minimum size of this window 86 | */ 87 | 88 | public void setMinimumSize (Dimension d) 89 | { 90 | smallest.width = d.width; 91 | smallest.height = d.height; 92 | } 93 | 94 | 95 | 96 | /** 97 | * Sets the minimum size of this window. If the window is resized to be 98 | * smaller than this size, the window will be enlarged enough to meet this size. 99 | * 100 | * @param width minimum width of this window 101 | * @param height minimum height of this window 102 | */ 103 | 104 | public void setMinimumSize (int width, int height) 105 | { 106 | smallest.width = width; 107 | smallest.height = height; 108 | } 109 | 110 | 111 | 112 | /** 113 | * Gets the minimum size of this window. If the window is resized to be 114 | * smaller than this size, the window will be enlarged enough to meet this size. 115 | * 116 | * @return minimum size of this window 117 | */ 118 | 119 | public Dimension getMinimumSize () 120 | { 121 | return new Dimension(smallest); 122 | } 123 | 124 | 125 | 126 | /** 127 | * Updates this component. This method only does one thing: calls paint 128 | * . 129 | * 130 | * @param g Graphics context 131 | */ 132 | 133 | public void update (Graphics g) 134 | { 135 | paint (g); 136 | } 137 | 138 | 139 | 140 | /** 141 | * Renders this frame using double buffering. 142 | * 143 | * @param g graphics canvas 144 | */ 145 | 146 | public void paint (Graphics g) 147 | { 148 | // Make sure offscreen buffer exists 149 | if( h == null ) 150 | // Abort painting, there is no space on which to draw 151 | return; 152 | 153 | // Set clip area 154 | Rectangle clip = g.getClip().getBounds(); 155 | h.setClip (clip); 156 | 157 | // Fill background color 158 | h.setColor (getBackground()); 159 | Dimension d = getSize(); 160 | h.fillRect (0, 0, d.width, d.height); 161 | 162 | // Call parent's paint 163 | super.paint (h); 164 | 165 | // Render canvas 166 | g.drawImage (offscreen, 0, 0, null); 167 | } 168 | 169 | 170 | 171 | /** 172 | * Creates the offscreen buffer used for double buffering. 173 | */ 174 | 175 | private void createOffscreenBuffer () 176 | { 177 | // Get size of frame 178 | o = getToolkit().getScreenSize(); 179 | 180 | // Make sure both width and height are positive to avoid a non-fatal 181 | // exception when creating an image for double buffering 182 | if( (o.width <= 0) || (o.height <= 0) ) 183 | // Abort function, there is no space on which to draw 184 | return; 185 | 186 | // Compensate for insets 187 | o.width += 10; 188 | o.height += 10; 189 | 190 | // Remove previous background image 191 | if( offscreen != null ) 192 | { 193 | // Dispose of offscreen canvas 194 | offscreen.flush(); 195 | offscreen = null; 196 | System.gc(); 197 | } 198 | 199 | // Create offscreen canvas 200 | offscreen = Misc.createImage(o.width, o.height); 201 | h = offscreen.getGraphics(); 202 | } 203 | 204 | 205 | 206 | /** 207 | * Disposes of this frame and all the resources it uses. 208 | */ 209 | 210 | public void dispose () 211 | { 212 | // Dispose of offscreen canvas 213 | if (offscreen != null) 214 | offscreen.flush(); 215 | 216 | // Null all references 217 | h = null; 218 | o = null; 219 | smallest = null; 220 | offscreen = null; 221 | 222 | // Garbage collection 223 | System.gc(); 224 | 225 | // Call parent dispose 226 | super.dispose(); 227 | } 228 | 229 | 230 | 231 | //****************************************************************************** 232 | //** java.awt.event.ComponentListener methods *** 233 | //****************************************************************************** 234 | 235 | 236 | 237 | /** 238 | * Invoked when component has been resized. 239 | */ 240 | 241 | public void componentResized (ComponentEvent e) 242 | { 243 | // Assume good size 244 | boolean resize = false; 245 | 246 | // Get size 247 | Dimension d = getSize(); 248 | 249 | // Make sure width is at least minimum 250 | if( d.width < smallest.width ) 251 | { 252 | d.width = smallest.width; 253 | resize = true; 254 | } 255 | 256 | // Make sure height is at least minimum 257 | if( d.height < smallest.height ) 258 | { 259 | d.height = smallest.height; 260 | resize = true; 261 | } 262 | 263 | // Resize if necessary 264 | if( resize ) 265 | // Set size of this control 266 | setSize (d); 267 | 268 | // Make sure frame size does not exceed offscreen buffer size. This 269 | // could happen if the end user changes resolution at runtime. 270 | if( (d.width > o.width) || (d.height > o.height) ) 271 | createOffscreenBuffer(); 272 | 273 | // Erase previous image on offscreen canvas 274 | int imageWidth = offscreen.getWidth(null); 275 | int imageHeight = offscreen.getWidth(null); 276 | 277 | h.setColor (Color.white); 278 | h.fillRect (d.width, 0, imageWidth - d.width, imageHeight); 279 | h.fillRect (0, d.height, d.width, imageHeight - d.height); 280 | } 281 | 282 | 283 | 284 | /** 285 | *Invoked when component has been moved. 286 | */ 287 | 288 | public void componentMoved (ComponentEvent e) 289 | { 290 | } 291 | 292 | 293 | 294 | /** 295 | * Invoked when component has been shown. 296 | */ 297 | 298 | public void componentShown (ComponentEvent e) 299 | { 300 | } 301 | 302 | 303 | 304 | /** 305 | * Invoked when component has been hidden. 306 | */ 307 | 308 | public void componentHidden (ComponentEvent e) 309 | { 310 | } 311 | 312 | 313 | 314 | //****************************************************************************** 315 | //** java.awt.event.WindowListener methods *** 316 | //****************************************************************************** 317 | 318 | 319 | 320 | /** 321 | * Invoked when a window has been opened. 322 | */ 323 | 324 | public void windowOpened (WindowEvent e) 325 | { 326 | } 327 | 328 | 329 | 330 | /** 331 | * Invoked when a window is in the process of being closed. The close operation 332 | * can be overridden at this point. This method does only one thing: terminates 333 | * the application. Derived classes want to override this method without 334 | * calling BufferedFrame.windowClosing if they terminate the application 335 | * themselves. 336 | */ 337 | 338 | public void windowClosing (WindowEvent e) 339 | { 340 | // Terminate program 341 | System.exit (0); 342 | } 343 | 344 | 345 | 346 | /** 347 | * Invoked when a window has been closed. This method will not be called since 348 | * windowClosing terminates the application. 349 | */ 350 | 351 | public void windowClosed (WindowEvent e) 352 | { 353 | } 354 | 355 | 356 | 357 | /** 358 | * Invoked when a window is iconified. 359 | */ 360 | 361 | public void windowIconified (WindowEvent e) 362 | { 363 | } 364 | 365 | 366 | 367 | /** 368 | * Invoked when a window is de-iconified. 369 | */ 370 | 371 | public void windowDeiconified (WindowEvent e) 372 | { 373 | } 374 | 375 | 376 | 377 | /** 378 | * Invoked when a window is activated. 379 | */ 380 | 381 | public void windowActivated (WindowEvent e) 382 | { 383 | } 384 | 385 | 386 | 387 | /** 388 | * Invoked when a window is de-activated. 389 | */ 390 | 391 | public void windowDeactivated (WindowEvent e) 392 | { 393 | } 394 | 395 | 396 | 397 | } 398 | -------------------------------------------------------------------------------- /src/example2/BorderSimple.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================================== 3 | * 4 | * The Clearthought Software License, Version 1.0 5 | * 6 | * Copyright (c) 2001 Daniel Barbalace. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. The original software may not be altered. However, the classes 16 | * provided may be subclasses as long as the subclasses are not 17 | * packaged in the info.clearthought package or any subpackage of 18 | * info.clearthought. 19 | * 20 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 21 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR, AFFILATED BUSINESSES, 24 | * OR ANYONE ELSE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * ==================================================================== 33 | */ 34 | 35 | 36 | 37 | package example2; 38 | 39 | 40 | 41 | import java.awt.*; 42 | import java.awt.event.*; 43 | import java.io.*; 44 | import java.net.*; 45 | import javax.swing.*; 46 | import info.clearthought.layout.*; 47 | 48 | 49 | 50 | /** 51 | * BorderSimple demonstrates how to create a simple border. 52 | * 53 | * @author Daniel E. Barbalace 54 | * @version 1.0, Jun 17, 2005 55 | */ 56 | 57 | public class BorderSimple implements ActionListener 58 | { 59 | 60 | 61 | 62 | /** Main frame */ 63 | private JFrame frame; 64 | 65 | /** Used to display the path of the file being displayed */ 66 | private JLabel labelFilename; 67 | 68 | /** When selected, files will be displayed as web pages */ 69 | private JRadioButton radioWebPage; 70 | 71 | /** When selected, files will be displayed as text */ 72 | private JRadioButton radioText; 73 | 74 | /** Used to display HTML files as web pages */ 75 | private JEditorPane paneWeb; 76 | 77 | /** Used to display HTML files as text */ 78 | private JTextPane paneText; 79 | 80 | /** Used to scroll document view */ 81 | private JScrollPane scrollPane; 82 | 83 | /** Open file menu item */ 84 | private JMenuItem menuOpenFile; 85 | 86 | /** Open URL item */ 87 | private JMenuItem menuOpenUrl; 88 | 89 | /** Exit menu item */ 90 | private JMenuItem menuExit; 91 | 92 | 93 | 94 | /** 95 | * Runs the program. 96 | */ 97 | 98 | public static void main (String args[]) 99 | { 100 | new BorderSimple(); 101 | } 102 | 103 | 104 | 105 | /** 106 | * Creates the application's GUI. 107 | */ 108 | 109 | public BorderSimple() 110 | { 111 | // Create frame 112 | frame = new JFrame("Simple Border"); 113 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 114 | 115 | // Create menu 116 | JMenuBar menuBar = new JMenuBar(); 117 | JMenu menu = new JMenu("File"); 118 | menuOpenFile = menu.add("Open File"); 119 | menuOpenUrl = menu.add("Open URL"); 120 | menuExit = menu.add("Exit"); 121 | menuOpenFile.addActionListener(this); 122 | menuOpenUrl.addActionListener(this); 123 | menuExit.addActionListener(this); 124 | menuBar.add(menu); 125 | frame.setJMenuBar(menuBar); 126 | 127 | // Create controls 128 | JLabel labelFile = new JLabel("File:"); 129 | labelFilename = new JLabel(""); 130 | JLabel labelView = new JLabel("View as:"); 131 | radioWebPage = new JRadioButton("Web Page"); 132 | radioText = new JRadioButton("Text"); 133 | ButtonGroup groupView = new ButtonGroup(); 134 | groupView.add(radioWebPage); 135 | groupView.add(radioText); 136 | radioWebPage.setSelected(true); 137 | radioWebPage.addActionListener(this); 138 | radioText.addActionListener(this); 139 | paneWeb = new JEditorPane(); 140 | paneWeb.setEditable(false); 141 | paneText = new JTextPane(); 142 | paneText.setEditable(false); 143 | 144 | scrollPane = new JScrollPane(paneWeb); 145 | scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); 146 | scrollPane.setPreferredSize(new Dimension(600, 400)); 147 | scrollPane.setMinimumSize(new Dimension(10, 10)); 148 | 149 | // Create and set layout 150 | double p = TableLayout.PREFERRED; 151 | double border = 10; 152 | double [] columnSize = {border, p, p, p, TableLayout.FILL, border}; 153 | double [] rowSize = {border, p, p, TableLayout.FILL, border}; 154 | TableLayout layout = new TableLayout(columnSize, rowSize); 155 | layout.setHGap(5); 156 | Container container = frame.getContentPane(); 157 | container.setLayout(layout); 158 | 159 | // Add controls 160 | container.add(labelFile, "1, 1, RIGHT, BOTTOM"); 161 | container.add(labelFilename, "2, 1, 4, 1"); 162 | container.add(labelView, "1, 2, RIGHT, CENTER"); 163 | container.add(radioWebPage, "2, 2"); 164 | container.add(radioText, "3, 2"); 165 | container.add(scrollPane, "1, 3, 4, 3"); 166 | 167 | // Show one html file by default 168 | setPath("/sample.html"); 169 | 170 | // Show frame 171 | frame.pack(); 172 | frame.setVisible(true); 173 | frame.toFront(); 174 | } 175 | 176 | 177 | 178 | /** 179 | * Sets the path of the document to view. 180 | * 181 | * @param path full or relative path of document 182 | */ 183 | 184 | private void setPath (String path) 185 | { 186 | // Attempt to open file in jar 187 | URL url = BorderSimple.class.getResource(path); 188 | 189 | // Attempt to open a full URL 190 | if (url == null) 191 | { 192 | try 193 | { 194 | url = new URL(path); 195 | } 196 | catch (MalformedURLException e) {} 197 | } 198 | 199 | // Attempt to open a local file 200 | if (url == null) 201 | { 202 | try 203 | { 204 | File file = new File(path); 205 | url = file.toURL(); 206 | } 207 | catch (MalformedURLException e) {} 208 | } 209 | 210 | // If any of the attempts succeeded, open the url 211 | if (url != null) 212 | { 213 | try 214 | { 215 | paneWeb.setPage(url); 216 | paneText.setText(getContent(url)); 217 | labelFilename.setText(path); 218 | } 219 | catch (IOException e) 220 | { 221 | paneWeb.setText(""); 222 | paneText.setText(""); 223 | labelFilename.setText(""); 224 | System.err.println("Attempted to read a bad URL: " + url); 225 | } 226 | } 227 | else 228 | { 229 | System.err.println("Couldn't find file: " + path); 230 | } 231 | } 232 | 233 | 234 | 235 | /** 236 | * Gets the contents of a URL as a string. 237 | * 238 | * @param url document to get 239 | * 240 | * @return a string containing the URL's contents 241 | */ 242 | 243 | private String getContent (URL url) 244 | { 245 | StringBuffer content = new StringBuffer(); 246 | 247 | try 248 | { 249 | String line = ""; 250 | BufferedReader input = new BufferedReader(new InputStreamReader(url.openStream())); 251 | 252 | while (line != null) 253 | { 254 | content.append(line); 255 | 256 | if (line.length() > 0) 257 | content.append('\n'); 258 | 259 | line = input.readLine(); 260 | } 261 | 262 | input.close(); 263 | } 264 | catch (MalformedURLException me) {} 265 | catch (IOException e) {} 266 | 267 | return content.toString(); 268 | } 269 | 270 | 271 | 272 | /** 273 | * Invoked when one of the radio buttons is selected. 274 | */ 275 | 276 | public void actionPerformed (ActionEvent e) 277 | { 278 | Object source = e.getSource(); 279 | 280 | if (source == radioWebPage) 281 | scrollPane.setViewportView(paneWeb); 282 | else if (source == radioText) 283 | scrollPane.setViewportView(paneText); 284 | else if (source == menuOpenFile) 285 | { 286 | JFileChooser fc = new JFileChooser(); 287 | int returnVal = fc.showOpenDialog(menuOpenFile); 288 | 289 | if (returnVal == JFileChooser.APPROVE_OPTION) 290 | { 291 | File file = fc.getSelectedFile(); 292 | setPath(file.getPath()); 293 | } 294 | } 295 | else if (source == menuOpenUrl) 296 | { 297 | String message = "URL to open"; 298 | String s = (String) JOptionPane.showInputDialog 299 | (frame, message, "Open URL", JOptionPane.PLAIN_MESSAGE, null, null, null); 300 | 301 | if ((s != null) && (s.length() > 0)) 302 | setPath(s); 303 | } 304 | else if (source == menuExit) 305 | System.exit(0); 306 | } 307 | 308 | 309 | 310 | } 311 | -------------------------------------------------------------------------------- /src/exampleSupport/BlankLabel.java: -------------------------------------------------------------------------------- 1 | package exampleSupport; 2 | 3 | 4 | 5 | import java.awt.*; 6 | import java.awt.event.*; 7 | 8 | 9 | 10 | /** 11 | * This class displays static text like the java.awt.Label class. However, 12 | * unlike Label, BlankLabel is a lightweight component with a transparent 13 | * background. Thus, it can placed on top of a background image without 14 | * covering the image. 15 | * 16 | * @author Daniel E. Barbalace 17 | */ 18 | 19 | public class BlankLabel extends Component implements 20 | java.awt.event.ComponentListener 21 | { 22 | 23 | 24 | 25 | // The following constants are used to justify the label. 26 | /** Indicates that the label's text should be left justified. */ 27 | public static final int ALIGN_LEFT = 0; 28 | /** Indicates that the label's text should be centered justified. */ 29 | public static final int ALIGN_CENTER = 1; 30 | /** Indicates that the label's text should be right justified. */ 31 | public static final int ALIGN_RIGHT = 2; 32 | 33 | 34 | 35 | /** Font used when BlankLabel is created */ 36 | protected static Font defaultFont = null; 37 | 38 | /** Text displayed by label */ 39 | protected String label; 40 | 41 | /** Label actually printed on button */ 42 | protected String shownLabel; 43 | 44 | /** Graphics context */ 45 | protected Graphics graphics = null; 46 | 47 | /** Label alignment */ 48 | protected int alignment = ALIGN_LEFT; 49 | 50 | /** Height (in pixels) of label */ 51 | protected int textHeight; 52 | 53 | /** Width (in pixels) of label */ 54 | protected int textWidth; 55 | 56 | /** Horizontal offset to first character of label */ 57 | protected int textInsetX; 58 | 59 | /** Vertical offset to baseline of label */ 60 | protected int textInsetY; 61 | 62 | 63 | 64 | /** 65 | * To construct a BlankLabel with a specified label. 66 | * 67 | * @param label text to be displayed by the label. If label is 68 | * null, no label is displayed. 69 | */ 70 | 71 | public BlankLabel (String label) 72 | { 73 | // Call parent constructor 74 | super(); 75 | 76 | // Set label; if blank, use no label 77 | if (label == null) 78 | this.label = ""; 79 | else 80 | this.label = label; 81 | 82 | // Use the default font if available 83 | if (defaultFont != null) 84 | setFont (defaultFont); 85 | 86 | // This component must know when it has been resized 87 | addComponentListener (this); 88 | } 89 | 90 | 91 | 92 | /** 93 | * Sets the font used by all BlankLabels that do not have their font explicitly 94 | * set. The change only affects new BlankLabels. If this method is not called 95 | * or null is specified for defaultFont, the default component font 96 | * is used. 97 | * 98 | * @param defaultFont font to use as the default font for all new BlankLabels 99 | */ 100 | 101 | public static void setDefaultFont (Font defaultFont) 102 | { 103 | BlankLabel.defaultFont = defaultFont; 104 | } 105 | 106 | 107 | 108 | /** 109 | * Changes the font being used by the label. 110 | * 111 | * @param font font to use 112 | */ 113 | 114 | public void setFont (Font font) 115 | { 116 | // Change font 117 | super.setFont (font); 118 | 119 | // If the font has been changed, the shown label may need adjusting 120 | updateShownLabel(); 121 | } 122 | 123 | 124 | 125 | /** 126 | * Gets the text of the label. 127 | * 128 | * @return the text of the label as a string 129 | */ 130 | 131 | public String getText () 132 | { 133 | return label; 134 | } 135 | 136 | 137 | 138 | /** 139 | * Sets the text of the label. 140 | * 141 | * @param label new label to display. If label is null, no label 142 | * is displayed. 143 | * 144 | * @return the text of the label as a string 145 | */ 146 | 147 | public void setText (String label) 148 | { 149 | // Set the label's text; null means that no label is used 150 | if (label == null) 151 | this.label = ""; 152 | else 153 | this.label = label; 154 | 155 | // If the text has been changed, the shown label may need adjusting 156 | updateShownLabel(); 157 | 158 | // Indicate that container may need to layout out components 159 | invalidate(); 160 | 161 | // Repaint the label 162 | repaint(); 163 | } 164 | 165 | 166 | 167 | /** 168 | * Sets the alignment of the label. 169 | * 170 | * @param alignment one of the following: ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT 171 | */ 172 | 173 | public void setAlignment (int alignment) 174 | { 175 | this.alignment = alignment; 176 | repaint(); 177 | } 178 | 179 | 180 | 181 | /** 182 | * Updates the control drawing properties. 183 | */ 184 | 185 | protected void updateShownLabel () 186 | { 187 | // Set font 188 | Font font = getFont(); 189 | 190 | // Get dimensions of this canvas 191 | Dimension labelSize = getSize(); 192 | 193 | // If the component is not yet visible, it will have no size. This means 194 | // purely static components, those that do not change size of position, will 195 | // never know their size until it's too late. This is a design flaw -- 196 | // er, uh -- feature of the Abstract Window Toolkit. To prevent this code 197 | // from setting the shown label text to the empty screen, whenever the 198 | // component's size is 0 by 0, the entire label is shown -- that is, 199 | // everything that fits inside a 0x0 area is shown. 200 | if ((labelSize.width == 0) && (labelSize.height == 0)) 201 | { 202 | shownLabel = label; 203 | return; 204 | } 205 | 206 | // Get font information 207 | FontMetrics fm = getFontMetrics(font); 208 | textHeight = fm.getHeight(); 209 | textWidth = fm.stringWidth(label); 210 | 211 | // Make sure label is small enough to fit in button 212 | shownLabel = label; 213 | 214 | if (textWidth > labelSize.width) 215 | shownLabel = shownLabel + "..."; 216 | 217 | try 218 | { 219 | // Keep removing a character from label until it fits or has no more 220 | // characters 221 | while (textWidth > labelSize.width) 222 | { 223 | shownLabel = shownLabel.substring(0, shownLabel.length() - 4) + 224 | "..."; 225 | 226 | textWidth = fm.stringWidth(shownLabel); 227 | } 228 | } 229 | catch (StringIndexOutOfBoundsException error) 230 | { 231 | // Label has no more characters except "...", so make label empty 232 | shownLabel = ""; 233 | } 234 | 235 | // Calculate where to put text baseline and first character 236 | textInsetX = (labelSize.width - textWidth) / 2; 237 | textInsetY = (labelSize.height - textHeight) / 2; 238 | } 239 | 240 | 241 | 242 | /** 243 | * Updates this component. This method only does one thing: calls paint 244 | * . 245 | * 246 | * @param g Graphics context 247 | */ 248 | 249 | public void update (Graphics g) 250 | { 251 | // Call paint directly, instead of Component.update, to prevent flickering 252 | paint (g); 253 | } 254 | 255 | 256 | 257 | /** 258 | * Draws the label. 259 | * 260 | * @param g Graphics canvas 261 | */ 262 | 263 | public void paint (Graphics g) 264 | { 265 | try 266 | { 267 | // Set font 268 | Font font = getFont(); 269 | g.setFont (font); 270 | 271 | // Get font metrics 272 | FontMetrics fm = g.getFontMetrics(); 273 | int textHeight = fm.getHeight(); 274 | int textDescent = fm.getDescent(); 275 | int textWidth = fm.stringWidth(shownLabel); 276 | int width = getSize().width; 277 | 278 | // Calculate offset based on alignment and control size 279 | int offset = 0; 280 | 281 | switch (alignment) 282 | { 283 | case ALIGN_LEFT : offset = 0; break; 284 | case ALIGN_CENTER : offset = (width - textWidth) / 2; break; 285 | case ALIGN_RIGHT : offset = width - textWidth; break; 286 | } 287 | 288 | // Draw text 289 | g.setColor (getForeground()); 290 | g.drawString (shownLabel, offset, textHeight - textDescent); 291 | } 292 | catch (NullPointerException exception) 293 | { 294 | // sun.awt.windows.WFontMetrics craps out if paint is called before 295 | // the component is visible or if a time critical condition occurs. If 296 | // the component is not visible, there is no point in drawing it. If 297 | // the time critical condition occurs, a NullPointerException will 298 | // occur at both 299 | // sun.awt.windows.WFontMetrics.stringWidth(WFontMetrics.java:167) and 300 | // sun.awt.windows.WGraphics.drawString(WGraphics.java:199) 301 | // So this component cannot be rendered. 302 | } 303 | } 304 | 305 | 306 | 307 | /** 308 | * Gets the preferred size of this component. The preferred size is just enough 309 | * to fit the label. 310 | * 311 | * @return a dimension object indicating this component's preferred size. 312 | */ 313 | 314 | public Dimension getPreferredSize() 315 | { 316 | Dimension dimension; 317 | 318 | try 319 | { 320 | // Get font metrics 321 | FontMetrics fm = getFontMetrics(getFont()); 322 | 323 | // Set prefered size to be text size 324 | int textWidth = fm.stringWidth(label); 325 | int textHeight = fm.getHeight() + fm.getMaxDescent() - fm.getDescent(); 326 | dimension = new Dimension(textWidth, textHeight); 327 | } 328 | catch (NullPointerException exception) 329 | { 330 | // Stupid AWT givens NullPointerException if getPreferredSize is called 331 | // before control is visible 332 | dimension = new Dimension(0, 0); 333 | } 334 | 335 | return dimension; 336 | } 337 | 338 | 339 | 340 | //****************************************************************************** 341 | //*** java.awt.event.ComponentListener methods *** 342 | //****************************************************************************** 343 | 344 | 345 | 346 | /** 347 | * Invoked when component has been resized. 348 | */ 349 | 350 | public void componentResized (ComponentEvent e) 351 | { 352 | // If the component has been resized, the shown label may need adjusting 353 | if (e.getSource() == this) 354 | updateShownLabel(); 355 | } 356 | 357 | 358 | 359 | /** 360 | * Invoked when component has been moved. 361 | */ 362 | 363 | public void componentMoved (ComponentEvent e) 364 | { 365 | } 366 | 367 | 368 | 369 | /** 370 | * Invoked when component has been shown. 371 | */ 372 | 373 | public void componentShown (ComponentEvent e) 374 | { 375 | } 376 | 377 | 378 | 379 | /** 380 | * Invoked when component has been hidden. 381 | */ 382 | 383 | public void componentHidden (ComponentEvent e) 384 | { 385 | } 386 | 387 | 388 | 389 | } 390 | -------------------------------------------------------------------------------- /src/example2/Toggle2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================================== 3 | * 4 | * The Clearthought Software License, Version 1.0 5 | * 6 | * Copyright (c) 2001 Daniel Barbalace. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. The original software may not be altered. However, the classes 16 | * provided may be subclasses as long as the subclasses are not 17 | * packaged in the info.clearthought package or any subpackage of 18 | * info.clearthought. 19 | * 20 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 21 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR, AFFILATED BUSINESSES, 24 | * OR ANYONE ELSE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * ==================================================================== 33 | */ 34 | 35 | 36 | 37 | package example2; 38 | 39 | 40 | 41 | import java.awt.*; 42 | import java.awt.event.*; 43 | 44 | import javax.swing.*; 45 | import info.clearthought.layout.TableLayout; 46 | import info.clearthought.layout.TableLayoutConstraints; 47 | 48 | 49 | 50 | /** 51 | * Example of components spanning cells. 52 | * 53 | * @author Daniel E. Barbalace 54 | * @version 1.0, June 20, 2005 55 | */ 56 | 57 | public class Toggle2 implements ActionListener 58 | { 59 | 60 | 61 | 62 | /** Indicates an internal office address */ 63 | private static final String INTERNAL = "Internal"; 64 | 65 | /** Indicates a domestic (US) address */ 66 | private static final String DOMESTIC = "Domestic"; 67 | 68 | /** Indicates an international (non-US) address */ 69 | private static final String INTERNATIONAL = "International"; 70 | 71 | /** Empty space for asthetics */ 72 | private static double EMPTY_SPACE = 10; 73 | 74 | /** Instance of TableLayout we are using */ 75 | private TableLayout layout; 76 | 77 | /** Container using the layout */ 78 | private Container container; 79 | 80 | /** Identifies the type of address */ 81 | private JComboBox comboType; 82 | 83 | // A whole bunch of controls that this application will use. 84 | JLabel labelOffice = new JLabel("Office"); 85 | JTextField textOffice = new JTextField(5); 86 | JLabel labelBuilding = new JLabel("Building"); 87 | JComboBox comboBuilding = new JComboBox(new String [] {"A", "B", "C"}); 88 | JLabel labelStreet = new JLabel("Street"); 89 | JLabel labelCity = new JLabel("City"); 90 | JLabel labelState = new JLabel("State"); 91 | JLabel labelZip = new JLabel("Zip Code"); 92 | JLabel labelProvidence = new JLabel("Providence"); 93 | JLabel labelCountry = new JLabel("Country"); 94 | JTextField textStreet = new JTextField(25); 95 | JTextField textCity = new JTextField(25); 96 | JTextField textState = new JTextField(2); 97 | JTextField textZip = new JTextField(5); 98 | JTextField textProvidence = new JTextField(25); 99 | JTextField textCountry = new JTextField(25); 100 | 101 | 102 | 103 | /** 104 | * Runs the program. 105 | */ 106 | 107 | public static void main (String args[]) 108 | { 109 | new Toggle2(); 110 | } 111 | 112 | 113 | 114 | public Toggle2() 115 | { 116 | // Create frame 117 | JFrame frame = new JFrame("Toggling Groups of Rows"); 118 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 119 | frame.setResizable(false); 120 | 121 | // Create and set layout 122 | double p = TableLayout.PREFERRED; 123 | double f = TableLayout.FILL; 124 | double border = 10; 125 | double [] columnSize = {border, f, border}; 126 | double [] rowSize = {border, border}; 127 | layout = new TableLayout(columnSize, rowSize); 128 | container = frame.getContentPane(); 129 | container.setLayout(layout); 130 | 131 | // Create controls 132 | JLabel labelType = new JLabel("Type of Address"); 133 | comboType = new JComboBox(new String [] 134 | {INTERNAL, DOMESTIC, INTERNATIONAL}); 135 | comboType.setEditable(false); 136 | comboType.addActionListener(this); 137 | comboBuilding.setEditable(false); 138 | JButton buttonOK = new JButton("OK"); 139 | JButton buttonCancel = new JButton("Cancel"); 140 | JPanel panelButton = new JPanel(); 141 | double p2 = buttonCancel.getPreferredSize().width; 142 | panelButton.setLayout(new TableLayout(new double [][] {{p2, 5, p2}, {p}})); 143 | panelButton.add(buttonOK, "0, 0"); 144 | panelButton.add(buttonCancel, "2, 0"); 145 | 146 | // Add controls 147 | addControl(labelType); 148 | addControl(comboType); 149 | addSpace(); 150 | addControl(labelOffice); 151 | addControl(textOffice); 152 | addSpace(); 153 | addControl(labelBuilding); 154 | addControl(comboBuilding); 155 | addSpace(); 156 | addControl(labelStreet); 157 | addControl(textStreet); 158 | addSpace(); 159 | addControl(labelCity); 160 | addControl(textCity); 161 | addSpace(); 162 | addControl(labelState); 163 | addControl(textState); 164 | addSpace(); 165 | addControl(labelZip); 166 | addControl(textZip); 167 | addSpace(); 168 | addControl(labelProvidence); 169 | addControl(textProvidence); 170 | addSpace(); 171 | addControl(labelCountry); 172 | addControl(textCountry); 173 | addSpace(); 174 | 175 | // Add the button panel and then center justify it 176 | addControl(panelButton); 177 | TableLayoutConstraints tlc = layout.getConstraints(panelButton); 178 | tlc.hAlign = TableLayout.CENTER; 179 | layout.setConstraints(panelButton, tlc); 180 | 181 | // Add a filler row above the button panel so that the button panel 182 | // will stay at the bottom of the window 183 | layout.insertRow(tlc.row1, TableLayout.FILL); 184 | 185 | // Calculate the maximum size the frame would use 186 | int numItem = comboType.getItemCount(); 187 | Dimension max = new Dimension(0, 0); 188 | frame.setVisible(true); 189 | 190 | for (int i = 0; i < numItem; i++) 191 | { 192 | comboType.setSelectedIndex(i); 193 | updateDynamicRows(); 194 | Dimension d = frame.getPreferredSize(); 195 | max.width = Math.max(max.width, d.width); 196 | max.height = Math.max(max.height, d.height); 197 | } 198 | 199 | comboType.setSelectedIndex(0); 200 | updateDynamicRows(); 201 | 202 | // Show frame 203 | frame.setSize(max.width, max.height); 204 | frame.toFront(); 205 | } 206 | 207 | 208 | 209 | /** 210 | * Adds a row and a control to the content pane. 211 | */ 212 | 213 | private void addControl (Component component) 214 | { 215 | int rowNum = layout.getNumRow() - 1; 216 | layout.insertRow(rowNum, TableLayout.PREFERRED); 217 | container.add(component, new TableLayoutConstraints 218 | (1, rowNum, 1, rowNum, TableLayout.LEFT, TableLayout.BOTTOM)); 219 | } 220 | 221 | 222 | 223 | /** 224 | * Adds a blank row so that the window looks nice. 225 | */ 226 | 227 | private void addSpace() 228 | { 229 | int rowNum = layout.getNumRow() - 1; 230 | layout.insertRow(rowNum, EMPTY_SPACE); 231 | } 232 | 233 | 234 | 235 | /** 236 | * Invoked when the checkbox is toggled. 237 | */ 238 | 239 | public void actionPerformed (ActionEvent e) 240 | { 241 | updateDynamicRows(); 242 | } 243 | 244 | 245 | 246 | /** 247 | * Updates the visibility of dynamic rows. This method first zero outs all 248 | * dynamic rows. Then it resizes the relavent rows to 249 | * TableLayout.PREFERRED, thereby making their contents visible. Some 250 | * rows, like the ones pertaining to the city, are visible for more than 251 | * one type of address. 252 | */ 253 | 254 | private void updateDynamicRows() 255 | { 256 | String type = "" + comboType.getSelectedItem(); 257 | int rowMin, rowMax, rowStart = -1, rowStop = -1; 258 | rowMin = getRow(labelOffice); 259 | rowMax = getRow(textCountry); 260 | 261 | if (type.equals(INTERNAL)) 262 | { 263 | rowStart = getRow(labelOffice); 264 | rowStop = getRow(comboBuilding); 265 | } 266 | else if (type.equals(DOMESTIC)) 267 | { 268 | rowStart = getRow(labelStreet); 269 | rowStop = getRow(textZip); 270 | } 271 | else if (type.equals(INTERNATIONAL)) 272 | { 273 | rowStart = getRow(labelProvidence); 274 | rowStop = getRow(textCountry); 275 | } 276 | 277 | if (rowMin >= 0 && rowMax >= 0) 278 | for (int y = rowMin; y <= rowMax; y++) 279 | layout.setRow(y, 0); 280 | 281 | if (rowStart >= 0 && rowStop >= 0) 282 | for (int y = rowStart; y <= rowStop + 1; y++) 283 | { 284 | double size = ((y - rowStart) % 3 == 2) ? 285 | EMPTY_SPACE : TableLayout.PREFERRED; 286 | layout.setRow(y, size); 287 | } 288 | 289 | if (type.equals(INTERNATIONAL)) 290 | { 291 | rowStart = getRow(labelStreet); 292 | rowStop = getRow(textCity); 293 | 294 | if (rowStart >= 0 && rowStop >= 0) 295 | for (int y = rowStart; y <= rowStop + 1; y++) 296 | { 297 | double size = ((y - rowStart) % 3 == 2) ? 298 | EMPTY_SPACE : TableLayout.PREFERRED; 299 | layout.setRow(y, size); 300 | } 301 | } 302 | 303 | container.invalidate(); 304 | container.validate(); 305 | } 306 | 307 | 308 | 309 | /** 310 | * Gets the row associated with a control. 311 | * 312 | * @return the row in which a control has been placed or -1 if the component 313 | * is not found 314 | */ 315 | 316 | private int getRow (Component component) 317 | { 318 | TableLayoutConstraints tlc = layout.getConstraints(component); 319 | return (tlc == null) ? -1 : tlc.row1; 320 | } 321 | 322 | 323 | 324 | } 325 | -------------------------------------------------------------------------------- /www/articles/TableLayoutTutorialPart2/pages/hypercube.html: -------------------------------------------------------------------------------- 1 | 2 | How do draw a hypercube 3 | 4 | 5 |

6 | 7 |

Before drawing a hypercube, consider how to draw a cube.

8 |

 

9 |

A cube is made up of six squares. Only two will be parallel to the 10 | xy axis. The other four would have to be imagined by two-dimensional 11 | people. Similarly, a hypercube is made up of eight cubes. Only two are 12 | parallel to the xyz space. The other six must be imagined by 13 | three-dimensional people.

14 |

Let's draw the cube by first drawing two squares. Lets label each point in each square with a number from 1 to 4.

15 |

 

16 |

Now connect each point in one square with the corresponding point in the other square.

17 |
18 | 19 |

20 |

Now you have a cube -- well, not 21 | exactly since the edges are not all equal. But it's easier to draw some 22 | of the edges elongated. So I'll do the same with the hypercube, thus 23 | I'll really draw a hyper rectangular prism. A hypercube looks almost 24 | the same, but its harder to see all the (3D) sides at once.

25 |

A line is the area between two terminal points. A square is the area 26 | between to parallel lines. A cube is the area between two parallel 27 | squares. A hypercube is the area between two parallel cubes. So let's 28 | draw two parallel cubes and label the points o 29 | n each cube.

30 |
31 | 32 |

33 | 34 |

When we render a cube on a 35 | two-dimensional surface, we don't put the two parallel squares exactly 36 | parallel. We move one slightly up to provide prospective. For the same 37 | reason, let's move one of the cubes slightly up.

38 |

 

39 |

Now let's connect the corresponding points in the two cubes.

40 | 41 | 42 |

43 |

These are all the edges in the 44 | hypercube. But it's too hard to visualize in black and white. So let's 45 | go back to the cubes. This time let's add color. A cube can be draw as 46 | four squares. Let's make each square a different color.

47 |

 

48 |

You may have noticed that I've drawn each of the 12 edges twice. The 49 | edges that are part of more than two squares, I've drawn in both in 50 | both colors so that it is easy to see each square. However, they are 51 | the same edge.

52 |

The sides of the cube are:

53 |
54 | 55 |
	front
 56 | 	back
 57 | 	left
 58 | 	right
 59 | 	top (dashed)
 60 | 	bottom (dashed)
61 | 62 |

Now let's draw the two cubes in different colors.

63 |

 

64 |

In the hypercube, there will be eight sides:

65 |
66 |
 67 | 	front
 68 | 	back
 69 | 	left
 70 | 	right
 71 | 	top (dashed)
 72 | 	bottom (dashed)
 73 | 	x (dashed)
 74 | 	y (dashed)
75 |

I call the two new sides x and y 76 | for lack of a better name. Let's add the front and back sides of the 77 | hypercube. Remember that each side of a hypercube is a cube.

78 | 79 |

80 |

The magenta cube is parallel to the green cube. Both the magenta cube and the green cube are perpendicular to the blue cube. Yet, the blue cube shares one square face 81 | with the magenta cube and another square face with the green cube. 82 | In three dimensions, this would be an optical illusion, but in four dimensions it is a perfectly valid form.

83 | 84 |

Remember that the front square of the magenta cube is just as close to us as the front square of the green cube. The blue cube is not tilted. It is parallel to the fourth axis.

85 | 86 |

Now I've already drawn every edge 87 | in the hypercube -- some of them twice. However, I've only show four of 88 | the cubic faces of the hypercube. You might have noticed that there is 89 | no top or bottom. Let's add the top now.

90 | 91 | 92 |

93 |

The top side of the hypercube does 94 | not appear to be a cube. However, it is. Unfortunately, we are 95 | rendering the hypercube in two dimensions. The top side goes through 96 | the fourth axis like the front side, but the top side is parallel to 97 | the front side. Since we rendered the front side in a "nice" way, we're 98 | forced to render the top side in a "not so nice" way. The top side 99 | looks like a cube whose faces fell down to the left. However, this 100 | configuration allows the top side of the hypercube to be covered. The 101 | bottom side can be rendered in a similar fashion.

102 |
103 | 104 |

105 |

We 106 | still have to show side x and side y. These two sides will appear even 107 | more weird than the top and bottom sides. Cubic side x will connect the 108 | left square side of the magenta cube with the left square side of the green cube. Likewise, cubic side y will connect the right square side of magenta cube with the right square side of the green cube. To make these two cubic sides easy to see, let's draw only the left, right 109 | , FONT>x (dashed), and y (dashed) sides of the hypercube.

110 |

Here's side x.

111 | 112 | 113 |

114 |

Here's both side x and side y.

115 |

 

116 |

Finally, here's the hypercube in all of its glory.

117 |
118 | 119 |

120 |

That's 121 | eight cubes, twenty squares, thirty two edges, and sixteen terminal 122 | points. Here it is again with the redundant rendering of edges removed. 123 | Can you still see all eight cubes?

124 | 125 |

126 |

Well, 127 | to be a true hypercube, all edges would have to be the same length. For 128 | clarity, I discarded this fact. But the true hypercube would actually 129 | look like this.

130 | 131 |

132 |

Let's find the eight cubes in the hypercube.

133 | 134 |

135 |

If 136 | we wanted to, we could try drawing a hyper-hypercube, a five 137 | dimensional figure. However, rendering a five dimensional figure in two 138 | dimensions is very messy. It would be better to render a 139 | hyper-hypercube in three dimensions.

140 | 141 |
142 |

Back to the mathematics page

143 |

Back to main page

144 | 145 | -------------------------------------------------------------------------------- /www/general/testimonies.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | TableLayout Testimonies 4 | 5 | 6 | 7 | 8 | 9 |

Testimonies

10 | 11 |

12 | The following are quotes from software engineers who have used TableLayout and provided unsolicited 13 | feedback. To protect the privacy of the individuals, their email address and names are not given. 14 | For brevity, some quotes represents only part of a letter. 15 |

16 | 17 |

18 | 19 | The opinions given here do not represent endorsement from any company or organizations that own the domain 20 | names shown below. The opinions were expressed by individual software developers whose email addresses 21 | were from the domains shown. 22 |

23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 324 | 325 |
From:yahoo.com 
  34 | Great job on the layout! I love it. I am blown away how easy it is to use. It is 35 | by far much better than any of the other layouts. The only one I will use is CardLayout for a wizard 36 | component I wrote. But other than that, this is now my only layout I use! I think you should seriously 37 | consider submitting it to Sun to get included in the next version of Java, if not a 1.4 update, maybe 1.5. 38 | It is, as you showed, much easier to use than both GridLayout and GridBagLayout. 39 |
 
From:infosim.com 
  52 | ...this should most definitely be in the JDK - it blows away the 53 | competition (have you tried to actually use the SpringLayout). 54 |
 
From:ota.fr.socgen.com 
  68 | Your TableLayout saves us a lot of time and handles gracefully the most complex 69 | designs, great work! 70 |
 
From:lane15.com 
  83 | I really love your TableLayout. I think it's going to revolutionize layout in Java GUIs. 84 |
 
From:wpafb.af.mil 
  98 | Liked the article, it really opened my eyes to AWT. I've been so immersed 99 | in Swing, that I didn't realize AWT could have the flexibility demonstrated 100 | in your article. 101 |
 
From:absolutesys.com 
  114 | I read your article "TableLayout - An Alternative to GridBagLayout" on the 115 | Sun JFC site, and I think TableLayout is quite superb.

116 | 117 | I use Netbeans for most of my work, and I am now trying to find a Netbeans 118 | support module for TableLayout. 119 |
 
From:clarityconnect.com 
  133 | I wanted to personally thank you for the excellent TableLayout. 134 | It is exactly in the sweet spot between simplicity and power. 135 | Before TableLayout I was layering panels in BorderLayouts like you 136 | wouldn't believe! I had to write the UIs in one sitting because I could 137 | never go back and make a change! 138 | I tried creating UIs with every release of JBuilder from latte to version 139 | 6. Every time I went back to SlickEdit (although I've now switched to 140 | IntelliJ Idea) 141 | And I tried coding GridBagLayout by hand. That didn't even come out 142 | looking like the the Java I know. 143 | So, I just stayed away from writing UI code. 144 | Finally, with TableLayout, I can sculpt the UI as I go along. 145 |
 
From:offset.demon.nl 
  158 | My compliments on your article about table layout and the code, found on 159 | the Swing connection.

160 | 161 | A longtime 'command line' DOS programmer, I am trying to teach myself Java 162 | which I admire greatly but find GUI coding terrible. I quickly found out 163 | how to use this layout and have already used it in an in house application. 164 | I hope the Swing team will integrate this in their next offering. 165 | No reply required -- just thanks for your work. 166 |
 
From:shef.ac.uk 
  180 | Just wanted to thank you for your article on TSC on the new TableLayout, 181 | it was exactly what I needed for a project I'm doing (sports scorer for 182 | Cricket). Great article 183 |
 
From:askasicomp.com 
  196 | I have been sidetracked for a while, but I finally took 197 | the time to read your article: 198 | TableLayout - An Alternative to GridBagLayout A Simple and Powerful Layout Manager 199 | I just have to make more time to play with stuff like this. 200 | This is way cool. Although I'm not qualified to say this, 201 | I am way impressed. Keep up the great work!!! 202 |
 
From:pacbell.net 
  216 | I just can't resist to thank you for your excellent job on the TableLayout. 217 | It is the best layout to date. Lots of people literally suffering working 218 | with Sun's layouts, these layouts are a real pain.

219 | 220 | Your layout is a joy to work with! 221 |
 
From:aciworldwide.com 
  234 | I read your article about your TableLayout manager that is posted on the 235 | Sun web site. I want to tell you that I think your layout manager is the 236 | easiest to use of all of the layout manager classes that I have 237 | implemented. I have primarily been working with the GridBagLayout manager 238 | for all of my Swing projects. It was very frustrating trying to get the 239 | UIs to size without any of the pixel problems that you point out in your 240 | article. Thanks again for such a great layout manager class. 241 |
 
From:mac.com 
  255 | TableLayout is fantastic! Are you planning any enhancements? 256 |
 
From:mueller.ca 
  269 | TableLayout is very useful and makes it a lot easier to develop Swing 270 | applications. In fact, the existing knowledge on spreadsheets and HTML 271 | tables enables developers to create frames and dialogs much more 272 | efficiently. Thanks for this excellent invention! 273 |
 
From:powervision.com 
  287 | I wanted to say thanks for the layout! As many of the other quotes from 288 | your web-site attest, it's a great contribution. I don't abhor laying out 289 | my GUI screens anymore, I just sketch them on paper and lay them out in 290 | seconds. 291 |
 
From:rlx.com 
  304 | TableLayout is a terrific layout manager. Thank you for the excellent work. 305 |
 
From:JGoodies.com  
  319 | You have significantly improved the layout situation in Swing applications. 320 | It is not only that you've inspired me, but I have used your TableLayout in 321 | Swing courses and have found that its mental model is what developers can 322 | understand quickly. 323 |
326 | 327 |

328 | Back to project home 329 |

330 | 331 | 332 | --------------------------------------------------------------------------------