// // TestTabs class // part of the set of documents known as Java no sugar. // Copyright (c) 1996,1997 Sunil Gupta, sunil@magnetic.demon.co.uk // placed into the public domain by the author // import java.applet.*; import java.awt.*; import TabBar; import TabEntry; public class TestTabs extends Applet { TabBar tab; Checkbox chk_size, chk_square, chk_upBevel, chk_downBevel; CheckboxGroup group; Panel cards_panel = null; private static final String TAB1 = "tab1"; private static final String TAB2 = "tab2"; private static final String TAB3 = "Another Tab"; private static final String TAB4 = "Last Tab"; private static final char DELIM = ','; public void init() { Panel chk_panel, centre_panel; Label label; //===----------add the tabs to the north bit of the center panel------- tab = new TabBar(TAB1 + DELIM + TAB2 + DELIM + TAB3 + DELIM + TAB4, DELIM); //-----------create notepad and add to center of the center panel------- cards_panel = new Panel(); cards_panel.setLayout( new CardLayout()); label = new Label( TAB1); cards_panel.add( TAB1, label); label = new Label( TAB2); cards_panel.add( TAB2, label); label = new Label( TAB3); cards_panel.add( TAB3, label); label = new Label( TAB4); cards_panel.add( TAB4, label); centre_panel = new Panel(); centre_panel.setLayout(new BorderLayout()); centre_panel.add("North", tab); centre_panel.add ( "Center", cards_panel); //====-----create checkboxes ------------------- chk_size = new Checkbox("Fixed width"); chk_size.setState(true); chk_square = new Checkbox("Square"); chk_upBevel = new Checkbox("Bevel1"); chk_downBevel = new Checkbox("Bevel2"); group = new CheckboxGroup(); chk_square.setCheckboxGroup( group); chk_upBevel.setCheckboxGroup( group); chk_downBevel.setCheckboxGroup( group); //---------add to the panel--------------- chk_panel = new Panel(); chk_panel.setLayout(new GridLayout(0,1)); chk_panel.add(chk_size); chk_panel.add(chk_square); chk_panel.add(chk_upBevel); chk_panel.add(chk_downBevel); //====----------add panels to this applet----- setLayout(new BorderLayout()); this.add("Center", centre_panel); this.add("East", chk_panel); } public boolean action( Event e, Object arg) { Boolean state; TabBar entry; CardLayout layout; if (e.target == chk_size) { Boolean obj = (Boolean) arg; tab.set_fixed_size(obj.booleanValue()); return true; } else if (e.target == chk_square) { tab.set_style( TabBar.SQUARE); return true; } else if (e.target == chk_upBevel) { tab.set_style( TabBar.TOP_BEVELLED); return true; } else if (e.target == chk_downBevel) { tab.set_style( TabBar.BOTTOM_BEVELLED); return true; } else if (e.target == tab) { entry = (TabBar)arg; layout = (CardLayout) cards_panel.getLayout(); layout.show( cards_panel, entry.getActiveTabName() ); } return false; } }
file: /Techref/language/java/nosugar/custom/tabs/code/TestTabs.java, 3KB, , updated: 1997/1/27 20:35, local time: 2024/12/24 08:56,
18.118.144.50:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://sxlist.com/Techref/language/java/nosugar/custom/tabs/code/TestTabs.java"> language java nosugar custom tabs code TestTabs</A> |
Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
Welcome to sxlist.com! |
.