!"# $!"%& ' (" % ) % % %* % % % * ' %

Size: px
Start display at page:

Download "!"# $!"%& ' (" % ) % % %* % % % * ' %"

Transcription

1

2 !"# $!"%& ' (" % ) % % %* % *! % % * ' % %

3 Contents!!!! "#$ %&#! " # '# #(# #)! #*+ *++,#- *++)!#" #!.*" % #%,% /--% "0 %0 %*+#0 %&#-, $ % & #- )#-2-)!#.3 $4 # %% # #!#+5 )-# #!#)! 5#!# )!#!#,!#!# #!#!6)--#(#"!6)--#*++"!6)--,#--#" ##!#"!6)--57-#)#" "#)!#!#"

4 Contents "!6,-5####)!% "!6,#-#)!% %5#!#% %!6)--5!58#+% 0)#!#0 0!6,-)#0 )-#-,$##!#0 &$-#!#+9,-#)!!6,-.5#)! ' %%! #!#+5 )-# #!#)! )!#!#,!#!# #!#!6)--,:+,#!#,#!#+&# "&$-#!#+9 %,-)! %!6,5)!#$#+, %!6,#)!#, ( )*+ )!( ",!#" ",!5##" ")!#" "!6)#--,!5##)!#%, +) +% $& %#-#!# %)#-2- %!!+- %&$- %*78 -. $$ 0,#+ 0/$#- 0!6,-/$#*# 0/$#)--#!# 0!6)#-))#;8-/$#" / ) 0 $- 2-))#0 ))#0 )##))#(0!6,5#)#( & %) )# #!

5 Contents -)! $)!!6)#-) #!#+ #!#+<#! +!#!# #!#+9/#! #( #!#+4!)" #!#+4!" #!#+4!<#!% #!#+4!9/#% #!#+4!#!#+% #!#+4!8#+% "#!#+4!)#% $8#%,!#4!% #!#+4!)!0 #!#+9&# *# =7*# "5#- %,#: )!#!# #'

6

7 Chapter : Introduction 0+) % +%,'**, %,- *% ' % ' $.//### /0! 0 % % $# 0 # 2/"# 3%%!# *'' $ 0 **,$"#* JTabbedPane "# +% #'4, 4,*%*%5 % 4, 5 + % 4, ".//### *%, **% % *!! 6 * *) *+ #' * *! + * # %# -0 ' 0 # % % * *

8 Chapter : Introduction ) * * #JTabbedPane, *,"#! * * **5 0JTabbedPane **,,# % % 0 +* % *',##' ' +* * * * * * **-0 ' +* # * ** 5% * * #* ** * *,% 0 # +* # 0 ** '' ' * **% +* ' *** *%%,%%0 % *,* #! % * % * **', # * * *% 0 5% *JTabbedPane % "#! * 0 *% * *#!% # )23 ) % 0 0 % *%, '% & 7% %, ' 23 ) )0 %0 %,%, *% 2*" 0 *%.//### /0 ( 0,8**, 9289!2# 2

9 Chapter : Introduction, :;<! "#$%&'' 3

10 Chapter 2: Basic Concepts! " * *,! **"# * "# #0 $,!! 0 ** # * # * * '( # *+ # # *' *+ + **' ) $ * **# % %0 *% *!! 0 4 ** '(( 4

11 Chapter 2: Basic Concepts! $ 0 ) * %# +* % "# * #(! * *% = "# > ** * # * * *=%>*#=#> *# * * '(+! # 0 *#% ** * # # *' #% ' * * *#= * > * *#* =*> *! # *% % % 2 * * +* *'(,'*% #*# * +* % %# %# * # % * *% 6 # *3%#* % * *= * > * % 5

12 Chapter 2: Basic Concepts 2 * *%% ** =% > % ** *' * # % *%! #! ) % * * *#* #7=*> *'(- ** % 7! # $ 5 *# # ## 0 * +%%! *# * ** '( 6

13 Chapter 2: Basic Concepts! ' * ****'*' ' (.! ' 2 * ** *+ #*% * " *** ** 2 ** * + * "#" *** **! '! * 2 * ' #*# **+ ) * ***! ' $.%+%+ ** +?@*% * *%! #-0 '# * **# * * * 7

14 Chapter 2: Basic Concepts +* ** * ) * **! ( *"# ' %!$,"#'# %! * # * ' ' * "# * # * *+ +* % *' ' + * 0 * ** ** # % * *!#% 2 * ** + * * **!, * * % 0 '5%! *$**,' % "# *%*% *'(/!, 0 ' #% * % ' '#' %'() 0 *% #* * * *+% ** * *' 0 *#* 8

15 Chapter 2: Basic Concepts!,! %* * =!>'(. # ** ** # * ** # ** ** % *+ # * * **#* # + *# # + * * ** 9

16 Chapter 3: Creating Tabbed Panels and Titled Tabs $ % *# % TabbedPanelTitledTab& % % ', $ - $ $ + %, % %* 2 (SwingUtilities.invokeLater=> SwingUtilities.invokeAndWait=>#, $! % 6% 0) 5+7,,% ' *5% JTabbedPane #0 # # %TitledTab TabbedPanel60 # ## *# JTabbedPane # *#, 0 " JTabbedPane tabbedpane = new JTabbedPane(); tabbedpane.addtab("tab ", new JTextArea()); tabbedpane.addtab("tab 2", new JTextArea()); tabbedpane.addtab("tab 3", new JTextArea()); " TabbedPanel tabbedpanel = new TabbedPanel(); TitledTab tab = new TitledTab("Tab ", null, new JTextArea(), null); TitledTab tab2 = new TitledTab("Tab 2", null, new JTextArea(), null); TitledTab tab3 = new TitledTab("Tab 3", null, new JTextArea(), null); tabbedpanel.addtab(tab); tabbedpanel.addtab(tab2); tabbedpanel.addtab(tab3); +0 0?*@ $ (' 0 tabbedpane.setselectedindex(tabbedpane.indexof( Tab 2 )); $ (' 2""34 // Alternative : Selection via the tabbed panel: tabbedpanel.setselectedtab(tab2); // Alternative 2: Selection via the tab tab2.setselected(true); # + *+ 0 = JTextArea> 5# $%$ 0 int selectedindex = tabbedpane.getselectedindex(); String title = tabbedpane.gettitleat(selectedindex); JComponent contentcomponent = (JComponent)tabbedPane.getComponentAt(selectedIndex); 0

17 Chapter 3: Creating Tabbed Panels and Titled Tabs 5# $%$ TitledTab selectedtab = (TitledTab)tabbedPanel.getSelectedTab(); String title = selectedtab.gettext(); JComponent contentcomponent = selectedtab.getcontentcomponent(); 6 *0 TabbedPanel=5% JTabbedPane) *0' 0 *0; %+ #*% *+0*% + +## # *?*A@?*+@,'(%' 0 tabbedpane.inserttab("tab 4", null, new JTextArea(), null, tabbedpane.indexoftab("tab 2"));,'(%' TitledTab tab4 = new TitledTab("Tab 4", null, new JTextArea(), null); tabbedpanel.inserttab(tab4, tabbedpanel.gettabindex(tab2)); ##!?*B@ +'$ 0 boolean selected = tabbedpane.getselectedindex() == tabbedpane.indexoftab("tab 3"); +'$ 2$""34 // Alternative : Via the tabbed panel boolean selected = tabbedpanel.getselectedtab() == tab3; // Alternative 2: Checking the tab itself boolean selected = tab3.isselected(); $ $ + 2+ ) TabbedPanelTab +* TabListener TabbedPanelTab * # #Tab*/ ' ' ' ' ' ' = *>'' * $ #3# $ TabListener listener = new TabListener() { public void tabadded(tabevent event) { System.out.println("Tab " + event.gettab() + " was added to tabbed panel " + event.gettab().gettabbedpanel()); public void tabremoved(tabremovedevent event) { System.out.println("Tab " + event.gettab() + " was removed from tabbed panel " + event.gettabbedpanel()); public void tabdragged(tabdragevent event) { System.out.println("Tab " + event.gettab() + " in tabbed panel " + event.gettab().gettabbedpanel() + " was dragged to point " + event.getpoint());

18 Chapter 3: Creating Tabbed Panels and Titled Tabs public void tabdropped(tabdragevent event) { System.out.println("Tab " + event.gettab() + " in tabbed panel " + event.gettab().gettabbedpanel() + " was dropped at point " + event.getpoint()); public void tabdragaborted(tabevent event) { System.out.println("Tab " + event.gettab() + " in tabbed panel " + event.gettab().gettabbedpanel() + " was not dropped"); public void tabselected(tabstatechangedevent event) { System.out.println((event.getTab() == null? "No Tab" : "Tab " + event.gettab()) + " in tabbed panel " + event.gettabbedpanel() + " was selected"); System.out.println((event.getPreviousTab() == null? "No Tab" : "Tab " + event.getprevioustab()) + " was selected before"); System.out.println((event.getCurrentTab() == null? "No Tab" : "Tab " + event.getcurrenttab()) + " is now selected"); public void tabdeselected(tabstatechangedevent event) { // Deselect tells you which tab that was deselected. The event also contains // information about the selected tab in the tabbed panel. System.out.println("Tab " + event.gettab() + " in tabbed panel " + event.gettabbedpanel() + " was deselected"); System.out.println((event.getPreviousTab() == null? "No Tab" : "Tab " + event.getprevioustab()) + " was selected before"); System.out.println((event.getCurrentTab() == null? "No Tab" : "Tab " + event.getcurrenttab()) + " is now selected"); public void tabhighlighted(tabstatechangedevent event) { System.out.println((event.getTab() == null? "No Tab" : "Tab " + event.gettab()) + " in tabbed panel " + event.gettabbedpanel() + " was highlighted"); System.out.println((event.getPreviousTab() == null? "No Tab" : "Tab " + event.getprevioustab()) + " was highlighted before"); System.out.println((event.getCurrentTab() == null? "No Tab" : "Tab " + event.getcurrenttab()) + " is now highlighted"); public void tabdehighlighted(tabstatechangedevent event) { // Dehighlight tells you which tab that was dehighlighted. The event also // contains information about the highlighted tab in the tabbed panel. System.out.println("Tab " + event.gettab() + " in tabbed panel " + event.gettabbedpanel() + " was deselected"); System.out.println((event.getPreviousTab() == null? "No Tab" : "Tab " + event.getprevioustab()) + " was selected before"); 2

19 Chapter 3: Creating Tabbed Panels and Titled Tabs System.out.println((event.getCurrentTab() == null? "No Tab" : "Tab " + event.getcurrenttab()) + " is now selected"); public void tabmoved(tabevent event) { System.out.println("Tab " + event.gettab() + " in tabbed panel " + event.gettab().gettabbedpanel() + " was moved in the tab area"); ; // Add the listener to a tabbed panel TabbedPanel tabbedpanel = new TabbedPanel(); tabbedpanel.addtablistener(listener); // Add the listener to a tab TitledTab tab = new TitledTab( Tab, null, new JTextArea(), null); tab.addtablistener(listener); 3

20 Chapter 4: Configuring a Tabbed Panel # %% *# %TabbedPanel# 0% 0 TabbedPanel *5 % net.infonode.tabbedpanel! # " TabbedPanel%% % %*% TabbedPanel % % $,, #** % 0 % TabbedPanel* $ 6$ TabbedPanel tabbedpanel = new TabbedPanel();,% #!# 0* % %"# #!* C#' % %% Property*5 %*! 'TabbedPanel * * 2Property' TabbedPanel#% % Property *5 # % *5 #! % TabbedPanel##% % % %%* %! " %%'! % % JTabbedPane %! # $ ) TabbedPanel *5 * * getproperties=># % *5 TabbedPanelProperties 5# $ TabbedPanelProperties properties = tabbedpanel.getproperties(); *5 ',' % 4

21 Chapter 4: Configuring a Tabbed Panel TabbedPanel *5 %! TabbedPanel TabbedPanelProperties TabbedPanelButtonProperties TabAreaProperties TabAreaComponentsProperties TabbedPanelContentPanelProperties 5 ButtonProperties ComponentProperties ShapedPanelProperties 8%# $ # $ " ButtonProperties *% %'* ' 0 ButtonFactory%# *% ButtonProperties net.infonode.properties.gui.util! # $! ) ComponentProperties % %JComponent *' '*!%' % ComponentProperties net.infonode.properties.gui.util! # $ $ *+ ShapedPanelProperties ' 7 / *%* * *!% +",, *% +%* ",*5 " ShapedPanelProperties DIRECTION %* TabbedPanel TitledTab # # TabbedPanelProperties % 5

22 Chapter 4: Configuring a Tabbed Panel TabbedPanel *5 TabbedPanel+ # # 23 )+ %%+ 0 4 * # * %** * $"2" 4 tabbedpanel.getproperties().settabareaorientation(direction.down); # #! 23 )+ %% 0 = % *% > % * $3$3 tabbedpanel.getproperties().settablayoutpolicy(tablayoutpolicy.compression); # # $ 23 )+ %% *%% Tab*% % +* % % % %+ * ' +* * *! %*% $ $ tabbedpanel.getproperties().settabselecttrigger(tabselecttrigger.mouse_release); # ' 0 TabAreaProperties % * % ComponentProperties*5 # ' 23 )+ %%" 9% *!% * * $ $ tabbedpanel.getproperties().gettabareaproperties().getcomponentproperties(). setbackgroundcolor(color.red); # ( 0 ) TabAreaComponentsProperties % *% % *# * =*% ># 6

23 Chapter 4: Configuring a Tabbed Panel # ( 23 )*%" 0 ) " Border% % * * $ $ " tabbedpanel.getproperties().gettabareacomponentsproperties(). getcomponentproperties().setborder(new LineBorder(Color.BLACK)); # (! 23 )*+%+ 0 ) +* # * * * **=%>*#=#> ># * * % %JComponent TabAreaComponentsProperties ComponentProperties 7 $ " tabbedpanel.getproperties().gettabareacomponentsproperties(). setstretchenabled(true); #, " TabbedPanelButtonProperties *% **'%/#/ / *# +* ButtonFactory''* 0 *% %%%#*% *% ** % *% % *% *% TabbedPanelDefaultButtonFactories #, 23 )+ %%" "8 ## 0 % %*% *% % $6$$ tabbedpanel.getproperties().getbuttonproperties().getscrollupbuttonproperties(). settooltiptext( Scroll Up ); $$ 3 ButtonFactory scrollupbuttonfactory = new ButtonFactory() { public AbstractButton createbutton(object object) { JButton button = new JButton("Up"); // You can also add action listeners button.addactionlistener(new ActionListener() { public void actionperformed(actionevent e) { System.out.println("Scrolled Up"); ); return button; 7

24 Chapter 4: Configuring a Tabbed Panel tabbedpanel.getproperties().getbuttonproperties().getscrollupbuttonproperties(). setfactory(scrollupbuttonfactory); # - TabbedPanelContentPanelProperties % **,%TabbedPanelContentPanel= *+ > % # - 23 )*%0 * # *% *+ * -6$" tabbedpanel.getproperties().getcontentpanelproperties().getcomponentproperties(). setinsets(new Insets(5, 5, 5, 5)); # / %%* ##+ 0% +## **# #. **% % * %,* **! * * =#> *# *% %*## * **!*%*% * +*% # * *!% *!*%*% *5 # % *5! * LineBorder blackborder = new LineBorder(Color.BLACK); // Changing the properties that are located in the porperties root object tabbedpanel.getproperties().settabreorderenabled(true). settabselecttrigger(tabselecttrigger.mouse_release). settabdeselectable(true). settabareaorientation(direction.down). settabdropdownlistvisiblepolicy(tabdropdownlistvisiblepolicy.more_than_one_tab); 8

25 Chapter 4: Configuring a Tabbed Panel // Changing the properties for the tab area tabbedpanel.getproperties().gettabareaproperties().getcomponentproperties(). setbackgroundcolor(color.blue). setborder(blackborder); // Changing the properties for the area with the tab area components tabbedpanel.getproperties().gettabareacomponentsproperties(). getcomponentproperties(). setbackgroundcolor(null). // using null as color means transparent setborder(null); // Changing the properties for the content area tabbedpanel.getproperties().getcontentpanelproperties().getcomponentproperties(). setbackgroundcolor(color.blue). setborder(blackborder); TitledTab *% ' - $ 6 # % TabbedPanel+# % ' ((8 # & )% % Property# % % Property' %+ +% # ##$ // Let's say that the default tab spacing is int tabspacing = tabbedpanel.getproperties().gettabspacing(); // Now change tab spacing tabbedpanel.getproperties().settabspacing(20); // The tab spacing is 20 tabspacing = tabbedpanel.getproperties().gettabspacing(); // Remove the property value in the storage map TabbedPanelProperties.TAB_SPACING.removeValue(tabbedPanel.getProperties().getMap ()); // Now tab spacing will be again. tabbedpanel.getproperties().gettabspacing(); 9

26 Chapter 4: Configuring a Tabbed Panel # *% 0 ) +* % * TabbedPanel! * 0 *% TabbedPanel" * % *% * settabareacomponents=> TabbedPanel ##%0 *% *# *% # 23 )*%5" 0 ) +## #*% * # JComponentssetTabAreaComponents=> TabbedPanel ##% *',+ "6$ // Note CloseButton and MaximizeButton are just extended JButtons // used in this example tabbedpanel.settabareacomponents(new JComponent[]{new CloseButton(), new MaximizeButton()); %# * 'settabareacomponents=># null 20

27 Chapter 5: Configuring a Titled Tab ' %% *# %TitledTab# 0 % 0 TitledTab *5 % net.infonode.tabbedpanel.titledtab! +* % *# *!% ' ' " TitledTab%% % %*% TitledTab %% $,, #** % 0 % TitledTab* $ 6$ TitledTab tab = new TitledTab( My Titled Tab, new PyramidIcon(), // An example icon new JTextArea( Content for My Titled Tab, new CloseButton()); // An example title component,% #!# 0* % %"# #!* C#' % %% Property*5 %*! 'TitledTab %* * 2Property' TitledTab#*% % Property *5 # % *5 '! % TitledTab##% % % %%* %!" % %'! % %JTabbedPane %! ' $ ) TitledTab *5 * * getproperties=># % *5 TitledTabProperties 5# $% 2

28 Chapter 5: Configuring a Titled Tab TitledTabProperties properties = titledtab.getproperties(); *5 '-9 *5 'TitledTabStateProperties' %! * TitledTabProperties Normal State Highlighted State 3 Disabled State TitledTabStateProperties ComponentProperties ShapedPanelProperties 8%' $ ' $ ) ComponentProperties % %JComponent *' '*!%' % ComponentProperties net.infonode.properties.gui.util! ' $! *+ ShapedPanelProperties ' 7 / *%* * *!% +",, *% +%* ",*5 " ShapedPanelProperties DIRECTION 22

29 Chapter 5: Configuring a Titled Tab %* TabbedPanel TitledTab ' # TitledTabProperties TitledTabStateProperties*5 *+ ' ' * ' # 23 )+ %%*: "7 # 7 *% 0 #% * ' % *# % 0 % 7% '-(* * #* # %7'-+ $" $3 $ TitledTab tab = new TitledTab("My Titled Tab", null, new JTextArea(), null); tab.getproperties().gethighlightedproperties().seticon(new PyramidIcon()); #$:$3 tab.getproperties().setsizepolicy(titledtabsizepolicy.individual_size); ' ' * TitledTabStateProperties * *. 0 ) '

30 Chapter 5: Configuring a Titled Tab 9 = > % ''* ' ' * *! +% *+ 0 ' * * # * '-,-- $ TitledTab tab = new TitledTab("My Titled Tab", null, new JTextArea(), null); 6$ tab.getproperties().gethighlightedproperties(). settext("my Titled Tab Highlighted Text"); ' ( )% % Property# % % Property' %+ +% #TabbedPanel',5# 3;$ ', *%) "#'JComponent%* TitledTab % *% TitledTab# " * % TitledTab! TitledTabStateProperties+# 24

31 Chapter 5: Configuring a Titled Tab ', 23 )* " )* 0 ## *% ' - $ $$# $ 24 // Via constructor TitledTab tab = new TitledTab("My Titled Tab", null, new JTextArea(), new CloseButton()); // Via set method tab.settitlecomponent(new CloseButton()); ',! 23 )*)+* 0 ## 7*% ' *% * '-. $ TitledTab tab = new TitledTab("My Titled Tab", null, new JTextArea(), null); tab.setnormalstatetitlecomponent(new MinimizeButton()); tab.sethighlightedstatetitlecomponent(new CloseButton()); tab.setdisabledstatetitlecomponent(null); 25

32 Chapter 6: Custom Shapes and Component Painters ( )*+ ) *#!% ** *%* ( *+ 0 3% % **+ *' * 3% *6 %% *!% * %* TabgetShape=> TitledTab# % + Shape# 0 ** * # % # * ( *+ " ' * %(ShapedBorder! * %% # * %*%!! ShapedBorder=%net.infonode.gui.shaped.border!> 0 "#Border % java.awt.shape getshape=> ShapedBorder% #%3% ShapedBorder * ComponentProperties %# Shape %*getshape=>#*% # #*!%# Shape #* % ShapeTitledTab #* # % %% ShapedBorderCompoundBorder' % ShapedBorder+"#*% (! ) +* % =% net.infonode.gui.componentpainter!> *! * % *!%% **+ *' * ' * *!%# Shape ComponentPainter #*% %' # % ComponentPainter ShapedPanelProperties % 26

33 Chapter 6: Custom Shapes and Component Painters # ' #* # *!% ComponentProperties#* * *!% null (! 23 ) % % *+ " ) 0 ## TabbedPanel# TitledTab *!!?%@ - # ShapedBorder!!?%@ 8 public class HouseShapedBorder implements ShapedBorder { // Height of the roof private static final int TOP_INSET = 0; private Color color; public HouseShapedBorder(Color color) { this.color = color; public Shape getshape(component c, int x, int y, int width, int height) { int xpoints[] = new int[5]; int ypoints[] = new int[5]; int index = 0; xpoints[index] = x; ypoints[index++] = y + height; xpoints[index] = x; ypoints[index++] = y + TOP_INSET; xpoints[index] = (x + width) / 2; ypoints[index++] = y; xpoints[index] = x + width - ; ypoints[index++] = y + TOP_INSET; xpoints[index] = x + width - ; ypoints[index++] = y + height; return new Polygon(xpoints, ypoints, 5); public boolean isborderopaque() { return false; public void paintborder(component c, Graphics g, int x, int y, int width, int height) { g.setcolor(color); // Get the shape we are going to paint Polygon p = (Polygon)getShape(c, x, y, width, height); // We use drawpolyline so that no line is drawn between // the first and the last coordinate g.drawpolyline(p.xpoints, p.ypoints, p.npoints); public Insets getborderinsets(component c) { return new Insets(TOP_INSET,, 0, ); 27

34 Chapter 6: Custom Shapes and Component Painters 2#! % %# * ComponentPainter public class HouseComponentPainter implements ComponentPainter { private static final int TOP_INSET = 0; private Color roofcolor; public HouseComponentPainter(Color roofcolor) { this.roofcolor = roofcolor; public void paint(component component, Graphics g, int x, int y, int width, int height) { g.setcolor(roofcolor); g.fillrect(x, y, width, TOP_INSET + ); g.setcolor(color.white); g.fillrect(x, y + TOP_INSET +, width, height - TOP_INSET - ); public void paint(component component, Graphics g, int x, int y, int width, int height, Direction direction, boolean horizontalflip, boolean verticalflip) { paint(component, g, x, y, width, height); public Color getcolor(component component) { return null; public boolean isopaque(component component) { return false; ; ## TabbedPanel#TitledTab# HouseShapedBorder HouseComponentPainter*! * #HouseShapedBorder HouseComponentPainter*% *%'% $"$ <8 TabbedPanel tabbedpanel = new TabbedPanel(); HouseShapedBorder normalborder = new HouseShapedBorder(Color.BLACK); HouseShapedBorder highlightborder = new HouseShapedBorder(Color.RED); HouseShapedBorder tabareacomponentsborder = new HouseShapedBorder(Color.BLUE); HouseComponentPainter normalpainter = new HouseComponentPainter(Color.BLACK); HouseComponentPainter highlightpainter = new HouseComponentPainter(Color.RED); HouseComponentPainter tabareacomponentspainter = new HouseComponentPainter (Color.BLUE); for (int i = 0; i < 8; i++) { TitledTab tab = new TitledTab("Tab " + i, null, new JTextArea("Contents for Tab " + i), null); // Set the borders tab.getproperties().getnormalproperties().getcomponentproperties(). setborder(normalborder); tab.getproperties().gethighlightedproperties().getcomponentproperties(). setborder(highlightborder); // Set the painters tab.getproperties().getnormalproperties().getshapedpanelproperties(). setcomponentpainter(normalpainter); 28

35 Chapter 6: Custom Shapes and Component Painters tab.getproperties().gethighlightedproperties().getshapedpanelproperties(). setcomponentpainter(highlightpainter); tabbedpanel.addtab(tab); // Set tab area components area border tabbedpanel.getproperties().gettabareacomponentsproperties(). getcomponentproperties().setborder(tabareacomponentsborder); // Set tab area components area component painter tabbedpanel.getproperties().gettabareacomponentsproperties(). getshapedpanelproperties().setcomponentpainter(tabareacomponentspainter); 29

36 Chapter 7: Themes and Inheriting Properties, +) +% *# *5 # % net.infonode.tabbedpanel.theme!, +% +*?@ * #TabbedPanelTitledTab * %# TabbedPanels # % + # *5 %*5 TabbedPanel+ *5 ' ( 3= ((= % *5 % TabbedPanel,! % 6%+),* TabbedPanelProperties*5 'TitledTabProperties*5 *0 * TabbedPanelTitledTabTheme ( 5% %*5 0 TabbedPanelProperties*5 %*5 TitledTabProperties*5 *, # # ## # GradientTheme TabbedPanel# #TitledTab,! 0% +) 2## GradientTheme TabbedPanel# TitledTab'. $3 & // Creating a Gradient Theme with opaque tab area and no shadow GradientTheme gradienttheme = new GradientTheme(true, false); TabbedPanel tabbedpanel = new TabbedPanel(); // Apply the theme properties to the tabbed panel tabbedpanel.getproperties(). addsuperobject(gradienttheme.gettabbedpanelproperties()); for (int i = 0; i < 4; i++) { TitledTab tab = new TitledTab("Tab " + i, null, new JTextArea("Content for Tab " + i), null); // Apply the theme properties to the titled tab tab.getproperties().addsuperobject(gradienttheme.gettitledtabproperties()); tabbedpanel.addtab(tab); 30

37 Chapter 7: Themes and Inheriting Properties 3%# TitledTab% TabbedPanel %# TitledTab +* 0 TitledTab TabbedPanel %# # %% %,!! )% +) TabbedPanelTitledTab#% % * %!% % # TabbedPanelTitledTab%*%" # % % # *?!#@ * +* # DefaultTheme *% TabbedPanelProperties *5 TitledTabProperties*5! %! ## GradientTheme# %0 5# $"$ // Remove theme properties from the tabbed panel tabbedpanel.getproperties().removesuperobject(gradienttheme.gettabbedpanelproperties()); // Iterate over every titled tab and remove theme properties for (int i = 0; i < tabbedpanel.gettabcount(); i++) ((TitledTab)tabbedPanel.getTabAt(i)).getProperties().removeSuperObject(gradientTheme.getTitledTabProperties());, $ 9 8+)!- "# JTabbedPane+!%! #!! *% # #! # #! *%! *'%% *% %*% 3

38 Chapter 7: Themes and Inheriting Properties %# % * # > $ // First remove look and feel theme properties from the tabbed panel tabbedpanel.getproperties().removesuperobject(lookandfeeltheme.gettabbedpanelproperties()); // Iterate over every titled tab and remove theme properties for (int i = 0; i < tabbedpanel.gettabcount(); i++) ((TitledTab)tabbedPanel.getTabAt(i)).getProperties().removeSuperObject(lookAndFeelTheme.getTitledTabProperties()); // Dispose the look and feel theme lookandfeeltheme.dispose(); % * % ' /= <# % + *#* **% *%! "! # $# $! $ JTabbedPane # 32

39 Chapter 8: Mouse Hover -. ** *% %! * % # % % ** * - * AWTEvent AWTPermission( listentoallawtevents ) +% =0 #%#* >'% % # # #! '#* *=# % > TabbedUtilsisHoverEnabled() *%!* -!.% * ** %2 % 'net.infonode.gui.hover.hoverlistener# %0 HoverListener 5% MouseListener Component*%#Component # MouseListener' # mouseexited(...) MouseListener# % % Component **% ** + *3% HoverListener **' *' * HoverListener% # % % # %0 3% **+* TabbedPanelHoverPolicy=,% > **% * 0 **# **%* ** *% *# % + % # % **. ; ** * # % B * % 33

40 Chapter 8: Mouse Hover A * % * HoverListener # 'mouseentered(hoverevent event) mouseexited(hoverevent event)hoverevent *% 2 ** ' HoverEvent+%##* TabbedPanel2 *' HoverEvent+%#* TitledTab -! 23 )*%. % *5 $$#$ $ // Hover listener for entire tabbed panel tabbedpanel.getproperties().sethoverlistener( new HoverListener() { public void mouseentered(hoverevent event) { System.out.println("Enter Tabbed Panel"); public void mouseexited(hoverevent event) { System.out.println("Exit Tabbed Panel"); ); // Hover listener for tab area tabbedpanel.getproperties().gettabareaproperties().sethoverlistener( new HoverListener() { public void mouseentered(hoverevent event) { System.out.println("Enter Tab Area"); public void mouseexited(hoverevent event) { System.out.println("Exit Tab Area"); ); // Hover listener for tab area components area tabbedpanel.getproperties().gettabareacomponentsproperties().sethoverlistener( new HoverListener() { public void mouseentered(hoverevent event) { System.out.println("Enter Tab Area Components Area"); public void mouseexited(hoverevent event) { System.out.println("Exit Tab Area Components Area"); ); // Hover listener for content area tabbedpanel.getproperties().getcontentpanelproperties().sethoverlistener( new HoverListener() { public void mouseentered(hoverevent event) { System.out.println("Enter Content Area"); public void mouseexited(hoverevent event) { System.out.println("Exit Content Area"); ); #$ $ tab.getproperties().sethoverlistener( new HoverListener() { public void mouseentered(hoverevent event) { System.out.println("Enter Titled Tab " + ((TitledTab)event.getSource()).getText()); 34

41 Chapter 8: Mouse Hover public void mouseexited(hoverevent event) { System.out.println("Exit Titled Tab " + ((TitledTab)event.getSource()).getText()); ); - $.0 + %% % ' net.infonode.tabbedpanel.hover!! # ** * C 2 % ' + *5 %*5 + # # %. TabbedPanelHoverAction8* HoverListener TabbedPanel TabbedPanelProperties*5 %*5 TabbedPanelProperties TabbedPanel TabbedPanelTitledTabHoverAction8" TabbedPanelHoverAction*% TitledTabProperties *5 #*%*5 TitledTabProperties TitledTab TabbedPanel TitledTabHoverActionD* HoverListenerTitledTab TitledTabProperties*5 %*5 TitledTabProperties TitledTab TitledTabTabbedPanelHoverAction8 TabbedPanelTitledTabHoverAction' * TabbedPanelProperties*5 TitledTabProperties*5 * HoverListenerTitledTab # TabbedPanelProperties*5 %*5 TabbedPanel TitledTab * TitledTabProperties*5 % *5 TitledTabProperties TitledTab TitledTabDelayedMouseExitHoverAction8 # %0 #* % 0 TitledTab +* * % net.infonode.gui.hover.compoundhoverlistener * # HoverListener %* #% / %*5 # * ** + # 35

42 Chapter 8: Mouse Hover - # 23 ) % );8%. 2 0 ## *+*!% *%# + *%* 0 2 *' 0 %* # B # %0 * $# TabbedPanel tabbedpanel = new TabbedPanel(); // Create a shared properties object for all the titled tabs TitledTabProperties sharedproperties = new TitledTabProperties(); // Hide the tab text sharedproperties.getnormalproperties().settextvisible(false); // Create a hover action that sets the background to blue when tab is hovered TitledTabHoverAction coloraction = new TitledTabHoverAction(); coloraction.gettitledtabproperties().getnormalproperties().getcomponentproperties().setbackgroundcolor(color.blue); // Create a hover action that shows the text when tab is hovered TitledTabHoverAction foldingaction = new TitledTabHoverAction(); foldingaction.gettitledtabproperties().getnormalproperties().settextvisible(true); // Create a 3-second delayed exit action for the folding action TitledTabDelayedMouseExitHoverAction delayedexitaction = new TitledTabDelayedMouseExitHoverAction(3000, foldingaction); // Set the compound hover action as hover listener sharedproperties.sethoverlistener(new CompoundHoverListener( coloraction, delayedexitaction)); // Create a few tabs and add them to the tabbed panel for (int i = 0; i < 4; i++) { TitledTab tab = new TitledTab("Tab " + i, null, new JLabel("Tab " + i), null); // Add the shared properties as super object tab.getproperties().addsuperobject(sharedproperties); tabbedpanel.addtab(tab); 36

43 Chapter 8: Mouse Hover 37

44 Chapter 9: Custom Tabbed Panel Content Area / ) 0 ###**,*%# % # % / 6% )0 TabbedPanel% ** *+ '#! %*' % 'TabbedPanelContentPanel' # *+ / )0 +* %* % % TabbedPanel# %! * %# * %? 0 $ $ JPanel customcontentarea = new JPanel(); TabbedPanel tabbedpanel = new TabbedPanel(customContentArea); TabbedPanelContentPanelProperties TabbedPanelProperties',/ $ $'# % % /! 0 )0 4 +* %% JComponent * * Tab+ ** * TabbedPanel% *' * * TabbedPanel0 # % TabbedPanel# *#!!*#!## TabbedPanel TabListener $" TabbedPanel tabbedpanel = new TabbedPanel(null); ( % TabbedPanel * TabbedPanel % % # TabbedPanel# Tab+ 2 TabbedPanel+ * * % ## TabbedPanel7 * 38

45 Chapter 9: Custom Tabbed Panel Content Area ## TabbedPanel * * * # * #* /! 23 )*" 0 4 +## TabbedPanel# #. *# * *%* *% %!*% *!*% * *%* *%*# 0* # * *0 * # * 0* # * ** %* *# *= % > *# *% %** *#% **# *+ - # % public class MyContentArea extends JPanel { public MyContentArea(TabbedPanel tabbedpanel) { super(new BorderLayout()); // Adding a tab listener so we know when a tab is selected tabbedpanel.addtablistener(new TabAdapter() { public void tabselected(tabstatechangedevent event) { // If there was a previously selected tab then we need to remove its // content component if (event.getprevioustab()!= null && event.getprevioustab().getcontentcomponent()!= null) remove(event.getprevioustab().getcontentcomponent()); // If there's a currently selected tab we add its content component if (event.getcurrenttab()!= null && event.getcurrenttab().getcontentcomponent()!= null)) add(event.getcurrenttab().getcontentcomponent(), BorderLayout.CENTER); ); repaint(); ## %TabbedPanel 0 TitledTab $ $ 39

46 Chapter 9: Custom Tabbed Panel Content Area LineBorder blackborder = new LineBorder(Color.BLACK); // Tabbed panel without content area TabbedPanel tabbedpanel = new TabbedPanel(null); // Configuring tabbed panel tabbedpanel.getproperties(). settabareaorientation(direction.left). settabspacing(2). settabdropdownlistvisiblepolicy (TabDropDownListVisiblePolicy.MORE_THAN_ONE_TAB). gettabareaproperties().getcomponentproperties(). setborder(blackborder). setinsets(new Insets(2, 2, 2, 2)). setbackgroundcolor(color.light_gray); tabbedpanel.getproperties().gettabareacomponentsproperties(). setstretchenabled(true). getcomponentproperties(). setborder(blackborder). setbackgroundcolor(null); // Configuring titled tab TitledTabProperties tabproperties = new TitledTabProperties(); tabproperties.sethighlightedraised(0). getnormalproperties(). setdirection(direction.up). getcomponentproperties(). setborder(blackborder). setbackgroundcolor(null); tabproperties.gethighlightedproperties().getcomponentproperties(). setborder(blackborder). setbackgroundcolor(color.white); // Creating the custom content area MyContentArea contentarea = new MyContentArea(tabbedPanel); contentarea.setborder(blackborder); // Creating 5 titled tabs with JTextArea as content component for (int i = 0; i < 5; i++) { TitledTab tab = new TitledTab("Tab " + i, null, new JTextArea("Content for Tab " + i), null); // Adding the configured titled tab properties as super object to each titled // tab's properties tab.getproperties().addsuperobject(tabproperties); tabbedpanel.addtab(tab); 2 TabbedPanel #% # TabbedPanel# % ') 40

47 Chapter 9: Custom Tabbed Panel Content Area 4

48 Chapter 0: Creating Custom Tabs & %) *# % TabTab% net.infonode.tabbedpanel! & Tab "# +*0 JPanel # BorderLayout% ' ' E% = > & 0%) +* 0 Tab Tab% % *%setlayout=> "# &! 2) TabbedPanel % Tab!## Tab ' Tab +* # Tab TabbedPanel% * seteventcomponent=>= > seteventcomponents=>=# > * Tab/ Tab &! 23 ) % ) 2### 0 % Tab# # '. 0 *% * *%*!%# *!%# 0* # ** * 0 * *%* #! 0 *% %* 0 % Tab TabbedPanel*( 42

49 Chapter 0: Creating Custom Tabs 8%& + 3 *"$$ $ 6$ public class MyCustomTab extends Tab { private JLabel textlabel = new JLabel(); private JButton closebutton = new JButton("X"); public MyCustomTab(String text, JComponent contentcomponent) { super(contentcomponent); textlabel.settext(text); // Make solid setopaque(true); // Set background setbackground(color.gray); // Add components, BorderLayout is default layout manager add(closebutton, BorderLayout.WEST); add(textlabel, BorderLayout.CENTER); closebutton.addactionlistener(new ActionListener() { public void actionperformed(actionevent e) { // Close tab by removing it from the tabbed panel it is a member of gettabbedpanel().removetab(mycustomtab.this); ); // Set border and spacing setborder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(2, 5, 2, 5))); // Set the textlabel as the only event component seteventcomponent(textlabel); // Add a tab listener so we know when tab is selected or not addtablistener(new TabAdapter() { public void tabselected(tabstatechangedevent event) { if (event.getcurrenttab() == MyCustomTab.this) setbackground(color.white); public void tabdeselected(tabstatechangedevent event) { if (event.getprevioustab() == MyCustomTab.this) setbackground(color.gray); ); 43

50 Chapter 0: Creating Custom Tabs 8%&! 3=32"06* 4 $ 44

51 Chapter : Properties %*! "#$%&' $#$%&' % net.infonode.properties! %) ' % %92,#% 2 # % $* '*% $ Property $ ' * PropertyGroup%Property* *5 %* *5 '0 PropertyMap= (3=> %Property*5 % Property.setValue() %, *5 % Property.getValue() " % % %# Property.removeValue()! %* % Property.valueIsRemovable() Property!' *% * # Property! PropertyGroup $ Property ' % $ net.infonode.properties.types! % *Property #% $-0 ' IntegerProperty % Integer #. #!PropertyValueHandler*5 % PropertyValueHandler* % *5 * %* *5 45

52 Chapter 2: Property Maps! %*! "#$%&' $#$%&' % % #% Property%! net.infonode.properties.propertymap!(# PropertyValueHandler PropertyGroup Property PropertyMapValueHandler PropertyMapGroup PropertyMapProperty PropertyMapListener -defaultmap PropertyMap PropertyMapTreeListener * -map PropertyChangeListener PropertyMapFactory PropertyMapContainer 8%! 3$ * #! PropertyMap Property%PropertyMap*5 * % PropertyMapFactory3% PropertyMap PropertyMapGroupPropertyMap PropertyMap % PropertyMapGroup % ( Property.setValue()Property.getValue() %PropertyMapPropertyMap% %# Property.removeValue() 46

53 Chapter 2: Property Maps!! PropertyMapGroupPropertyGroup#%PropertyMap % 6PropertyMapGroupPropertyMap# % % Property %% % #% %PropertyMap3% % %# PropertyMapGroup.getDefaultMap() % %#) PropertyMap' % %%* * PropertyMap '0 7! $. PropertyMapValueHandler% % PropertyMap! # PropertyMapProperty PropertyMap% % %# *! ' 8 PropertyMap*5! ( % %* % PropertyMap %!! 0 8 % PropertyMap * % *# 0 %% C PropertyMapGroup% 0. PointPropertyMapGroup# #IntegerProperty'X Y LinePropertyMapGroup# #PropertyMapProperty' StartEnd' Point % 0 % ## % * % ' % * '##!! * PropertyMap% *% %+ % PropertyMap' % % + % ' 0 % 47

54 Chapter 2: Property Maps % %PropertyMap.addSuperMap()' % PropertyMap.removeSuperMap()% *% PropertyMap.replaceSuperMap() 0. ; P = new Point P.X =, P.Y = 2 B P2 = new Point A P2.Y = 3 P% P2#P2.X == ' %%P' P2.Y == 3' %%P2!!! ) 2PropertyMap PropertyMapGroup PropertyMapProperty'PropertyMapProperty# PropertyMap%4 %# % PropertyMap % + * 2% '' PropertyMap''# PropertyMap %' PropertyMap% % PropertyMap%% ' % +% *'% 0 PropertyMap% % #% -0. ; L = new Line P = new Point B P.X = A P% L.Start'# L.Start.X == L : Line L.Start : Point 8%!! P : Point X = PropertyMap3, L2 = new Line F L2.Start.X == 2, L2.Start.Y ==

55 Chapter 2: Property Maps G L2% L%L2.Start *% L.Start'*% %P %L2.Start" #L.Start.X == L.Start.Y == 3. L : Line L2 : Line L.Start : Point 8%! $ P : Point X = PropertyMap3. 2 L2.Start : Point X = 2 Y = 3!! $ (PropertyMap.createRelativeRef()% % % 5%! %'*% %% #PropertyMap % PropertyMap # % C+0 # #!. L = new Line L.End.Y = B L.Start.X L.End.Y"' L.Start.X == L : Line L.Start : Point X = <parent>.end.y 8%! # L.End : Point Y = PropertyMap3 + L2 = new Line() L% L2#L2.Start.X == '*%. ; %X%L2.Start'L.Start % 49

56 Chapter 2: Property Maps L2#%!% %L2.End.Y B %Y%L2.End' %L.End % L2 : Line L : Line L2.Start : Point L2.End : Point L.Start : Point X = <parent>.end.y L.End : Point Y = 8%! ' PropertyMap3- F L2.End.Y = 2#L2.Start.X == 2*% L2 L2" L.Start.X == %!! # * PropertyMap. PropertyMapListener PropertyMapTreeListener PropertyChangeListener *$-PropertyMap>-!9-#!!#!# -#-# *$-PropertyMap!##$+9-#!!#!# -#-# *#$-#!!#!#+ PropertyMap # Property.getValue()# PropertyMap #% % % *' #Property.setValue() PropertyMap # % #* % -0 ' PropertyMap#* % % % ' #% # % PropertyMap!! ' < 9 #! * PropertyMap # 2! %%0 #%#, &'*% %+ # ** PropertyMapWeakListenerManager#! 50

57 Chapter 2: Property Maps #! PropertyMap3% % % PropertyMapWeakListenerManager# %#!!! ( " +% PropertyMapManager.runBatch() *% 7 % * # % % % run() Runnable PropertyMapManager.runBatch()#**% # %=> % * 6 % * * #0 #Property%. PropertyMapManager.runBatch(new Runnable() { public void run() { X.set(p, 4); Y.set(p, 5); );!!, * : PropertyMap*# ObjectOutputStream% PropertyMap.write() % ' PropertyMap PropertyMapProperty#*# % Property * %# % 7 %# PropertyMap% PropertyMap.read() ## %' %# D0 Property% %! Property % %! $ ) net.infonode.properties.gui.util.componentproperties JComponent %* JComponent% applyto() 5

!"# $!"%& ' (" % ) % % %* % % % * ' %

!# $!%& ' ( % ) % % %* % % % * ' % !"# $!"%& ' (" % ) % % %* % *! % % * ' % % Contents! """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""!!"#$"##$" %&" '(% # $ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""%

More information

Introduction to the JAVA UI classes Advanced HCI IAT351

Introduction to the JAVA UI classes Advanced HCI IAT351 Introduction to the JAVA UI classes Advanced HCI IAT351 Week 3 Lecture 1 17.09.2012 Lyn Bartram lyn@sfu.ca About JFC and Swing JFC Java TM Foundation Classes Encompass a group of features for constructing

More information

Bringing Life to Swing Desktop Applications

Bringing Life to Swing Desktop Applications Bringing Life to Swing Desktop Applications Alexander Potochkin Sun Microsystems Kirill Grouchnikov Amdocs Inc. TS-3414 2007 JavaOne SM Conference Session TS-3414 Presentation Goal Learn advanced painting

More information

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics Topic 9: Swing Outline Swing = Java's GUI library Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 7: Expand moving shapes from Assignment 4 into game. "Programming

More information

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 5: Will be an open-ended Swing project. "Programming Contest"

More information

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun! Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Why are we studying Swing? 1. Useful & fun! 2. Good application of OOP techniques

More information

Window Interfaces Using Swing Objects

Window Interfaces Using Swing Objects Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs

More information

Graphic Interface Programming II Using Swing and OOP more advanced issues. Uppsala universitet

Graphic Interface Programming II Using Swing and OOP more advanced issues. Uppsala universitet Graphic Interface Programming II Using Swing and OOP more advanced issues IT Uppsala universitet Good interface programming Swing is an EXTENDIBLE toolkit Build your OWN components Many times you need

More information

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction CSC 160 LAB 8-1 DIGITAL PICTURE FRAME PROFESSOR GODFREY MUGANDA DEPARTMENT OF COMPUTER SCIENCE 1. Introduction Download and unzip the images folder from the course website. The folder contains 28 images

More information

AP CS Unit 12: Drawing and Mouse Events

AP CS Unit 12: Drawing and Mouse Events AP CS Unit 12: Drawing and Mouse Events A JPanel object can be used as a container for other objects. It can also be used as an object that we can draw on. The first example demonstrates how to do that.

More information

More Swing. Chapter 14. Chapter 14 1

More Swing. Chapter 14. Chapter 14 1 More Swing Chapter 14 Chapter 14 1 Objectives learn to add menus, icons, borders, and scroll bars to GUIs learn to use the BoxLayout manager and the Box class learn about inner classes learn about the

More information

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class CHAPTER GRAPHICAL USER INTERFACES 10 Slides by Donald W. Smith TechNeTrain.com Final Draft 10/30/11 10.1 Frame Windows Java provides classes to create graphical applications that can run on any major graphical

More information

Chapter 14. More Swing

Chapter 14. More Swing Chapter 14 More Swing Menus Making GUIs Pretty (and More Functional) Box Containers and Box Layout Managers More on Events and Listeners Another Look at the Swing Class Hierarchy Chapter 14 Java: an Introduction

More information

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT CSE 143 Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/

More information

Window Interfaces Using Swing Objects

Window Interfaces Using Swing Objects Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs

More information

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

Graphics. Lecture 18 COP 3252 Summer June 6, 2017 Graphics Lecture 18 COP 3252 Summer 2017 June 6, 2017 Graphics classes In the original version of Java, graphics components were in the AWT library (Abstract Windows Toolkit) Was okay for developing simple

More information

2IS45 Programming

2IS45 Programming Course Website Assignment Goals 2IS45 Programming http://www.win.tue.nl/~wsinswan/programmeren_2is45/ Rectangles Learn to use existing Abstract Data Types based on their contract (class Rectangle in Rectangle.

More information

Graphic Interface Programming II Events and Threads. Uppsala universitet

Graphic Interface Programming II Events and Threads. Uppsala universitet Graphic Interface Programming II Events and Threads IT Uppsala universitet Animation Animation adds to user experience Done right, it enhances the User Interface Done wrong, it distracts and irritates

More information

Command-Line Applications. GUI Libraries GUI-related classes are defined primarily in the java.awt and the javax.swing packages.

Command-Line Applications. GUI Libraries GUI-related classes are defined primarily in the java.awt and the javax.swing packages. 1 CS257 Computer Science I Kevin Sahr, PhD Lecture 14: Graphical User Interfaces Command-Line Applications 2 The programs we've explored thus far have been text-based applications A Java application is

More information

Part I: Learn Common Graphics Components

Part I: Learn Common Graphics Components OOP GUI Components and Event Handling Page 1 Objectives 1. Practice creating and using graphical components. 2. Practice adding Event Listeners to handle the events and do something. 3. Learn how to connect

More information

GUI DYNAMICS Lecture July 26 CS2110 Summer 2011

GUI DYNAMICS Lecture July 26 CS2110 Summer 2011 GUI DYNAMICS Lecture July 26 CS2110 Summer 2011 GUI Statics and GUI Dynamics 2 Statics: what s drawn on the screen Components buttons, labels, lists, sliders, menus,... Containers: components that contain

More information

PIC 20A GUI with swing

PIC 20A GUI with swing PIC 20A GUI with swing Ernest Ryu UCLA Mathematics Last edited: November 22, 2017 Hello swing Let s create a JFrame. import javax. swing.*; public class Test { public static void main ( String [] args

More information

CS 251 Intermediate Programming GUIs: Components and Layout

CS 251 Intermediate Programming GUIs: Components and Layout CS 251 Intermediate Programming GUIs: Components and Layout Brooke Chenoweth University of New Mexico Fall 2017 import javax. swing.*; Hello GUI public class HelloGUI extends JFrame { public HelloGUI ()

More information

Jonathan Aldrich Charlie Garrod

Jonathan Aldrich Charlie Garrod Principles of Software Construction: Objects, Design, and Concurrency (Part 3: Design Case Studies) Introduction to GUIs Jonathan Aldrich Charlie Garrod School of Computer Science 1 Administrivia Homework

More information

Assignment 2. Application Development

Assignment 2. Application Development Application Development Assignment 2 Content Application Development Day 2 Lecture The lecture covers the key language elements of the Java programming language. You are introduced to numerical data and

More information

Graphics programming. COM6516 Object Oriented Programming and Design Adam Funk (originally Kirill Bogdanov & Mark Stevenson)

Graphics programming. COM6516 Object Oriented Programming and Design Adam Funk (originally Kirill Bogdanov & Mark Stevenson) Graphics programming COM6516 Object Oriented Programming and Design Adam Funk (originally Kirill Bogdanov & Mark Stevenson) Overview Aims To provide an overview of Swing and the AWT To show how to build

More information

Control Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User

Control Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User CSE3461 Control Flow Paradigms: Reacting to the User Control Flow: Overview Definition of control flow: The sequence of execution of instructions in a program. Control flow is determined at run time by

More information

Starting Out with Java: From Control Structures Through Objects Sixth Edition

Starting Out with Java: From Control Structures Through Objects Sixth Edition Starting Out with Java: From Control Structures Through Objects Sixth Edition Chapter 12 A First Look at GUI Applications Chapter Topics 12.1 Introduction 12.2 Creating Windows 12.3 Equipping GUI Classes

More information

CONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13

CONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13 CONTENTS Chapter 1 Getting Started with Java SE 6 1 Introduction of Java SE 6... 3 Desktop Improvements... 3 Core Improvements... 4 Getting and Installing Java... 5 A Simple Java Program... 10 Compiling

More information

Example: Building a Java GUI

Example: Building a Java GUI Steven Zeil October 25, 2013 Contents 1 Develop the Model 2 2 Develop the layout of those elements 3 3 Add listeners to the elements 9 4 Implement custom drawing 12 1 The StringArt Program To illustrate

More information

Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008

Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008 Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008 Announcements A3 is up, due Friday, Oct 10 Prelim 1 scheduled for Oct 16 if you have a conflict, let us know now 2 Interactive

More information

Programming graphics

Programming graphics Programming graphics Need a window javax.swing.jframe Several essential steps to use (necessary plumbing ): Set the size width and height in pixels Set a title (optional), and a close operation Make it

More information

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7 PROGRAMMING DESIGN USING JAVA (ITT 303) Graphical User Interface Unit 7 Learning Objectives At the end of this unit students should be able to: Build graphical user interfaces Create and manipulate buttons,

More information

Example: Building a Java GUI

Example: Building a Java GUI Steven Zeil October 25, 2013 Contents 1 Develop the Model 3 2 Develop the layout of those elements 4 3 Add listeners to the elements 12 4 Implement custom drawing 15 1 The StringArt Program To illustrate

More information

AP CS Unit 11: Graphics and Events

AP CS Unit 11: Graphics and Events AP CS Unit 11: Graphics and Events This packet shows how to create programs with a graphical interface in a way that is consistent with the approach used in the Elevens program. Copy the following two

More information

Chapter 13 Lab Advanced GUI Applications

Chapter 13 Lab Advanced GUI Applications Gaddis_516907_Java 4/10/07 2:10 PM Page 113 Chapter 13 Lab Advanced GUI Applications Objectives Be able to add a menu to the menu bar Be able to use nested menus Be able to add scroll bars, giving the

More information

Lecture 5: Java Graphics

Lecture 5: Java Graphics Lecture 5: Java Graphics CS 62 Spring 2019 William Devanny & Alexandra Papoutsaki 1 New Unit Overview Graphical User Interfaces (GUI) Components, e.g., JButton, JTextField, JSlider, JChooser, Containers,

More information

Java Programming Lecture 6

Java Programming Lecture 6 Java Programming Lecture 6 Alice E. Fischer Feb 15, 2013 Java Programming - L6... 1/32 Dialog Boxes Class Derivation The First Swing Programs: Snow and Moving The Second Swing Program: Smile Swing Components

More information

Advanced Java Unit 6: Review of Graphics and Events

Advanced Java Unit 6: Review of Graphics and Events Advanced Java Unit 6: Review of Graphics and Events This is a review of the basics of writing a java program that has a graphical interface. To keep things simple, all of the graphics programs will follow

More information

Graphical User Interface (GUI)

Graphical User Interface (GUI) Graphical User Interface (GUI) Layout Managment 1 Hello World Often have a static method: createandshowgui() Invoked by main calling invokelater private static void createandshowgui() { } JFrame frame

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor: Alan

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor:

More information

Here is a list of a few of the components located in the AWT and Swing packages:

Here is a list of a few of the components located in the AWT and Swing packages: Inheritance Inheritance is the capability of a class to use the properties and methods of another class while adding its own functionality. Programming In A Graphical Environment Java is specifically designed

More information

Advanced Effects in Java Desktop Applications

Advanced Effects in Java Desktop Applications Advanced Effects in Java Desktop Applications Kirill Grouchnikov, Senior Software Engineer, Amdocs kirillcool@yahoo.com http://www.pushing-pixels.org OSCON 2007 Agenda Swing pipeline Hooking into the pipeline

More information

UI Software Organization

UI Software Organization UI Software Organization The user interface From previous class: Generally want to think of the UI as only one component of the system Deals with the user Separate from the functional core (AKA, the app

More information

Graphical User Interface (GUI)

Graphical User Interface (GUI) Graphical User Interface (GUI) An example of Inheritance and Sub-Typing 1 Java GUI Portability Problem Java loves the idea that your code produces the same results on any machine The underlying hardware

More information

Welcome to CIS 068! 1. GUIs: JAVA Swing 2. (Streams and Files we ll not cover this in this semester, just a review) CIS 068

Welcome to CIS 068! 1. GUIs: JAVA Swing 2. (Streams and Files we ll not cover this in this semester, just a review) CIS 068 Welcome to! 1. GUIs: JAVA Swing 2. (Streams and Files we ll not cover this in this semester, just a review) Overview JAVA and GUIs: SWING Container, Components, Layouts Using SWING Streams and Files Text

More information

CSSE 220. Event Based Programming. Check out EventBasedProgramming from SVN

CSSE 220. Event Based Programming. Check out EventBasedProgramming from SVN CSSE 220 Event Based Programming Check out EventBasedProgramming from SVN Interfaces are contracts Interfaces - Review Any class that implements an interface MUST provide an implementation for all methods

More information

Object-Oriented Software Engineering. PersonGui (Mark 1) Case Study

Object-Oriented Software Engineering. PersonGui (Mark 1) Case Study Object-Oriented Software Engineering PersonGui (Mark 1) Case Study Contents The PersonGui (Mark1) The The Person Gui (Mark1) ToolBar PersonGui Constructor Adding Buttons Making Buttons Handling Events

More information

Datenbank-Praktikum. Universität zu Lübeck Sommersemester 2006 Lecture: Swing. Ho Ngoc Duc 1

Datenbank-Praktikum. Universität zu Lübeck Sommersemester 2006 Lecture: Swing. Ho Ngoc Duc 1 Datenbank-Praktikum Universität zu Lübeck Sommersemester 2006 Lecture: Swing Ho Ngoc Duc 1 Learning objectives GUI applications Font, Color, Image Running Applets as applications Swing Components q q Text

More information

Advanced Java Programming. Swing. Introduction to Swing. Swing libraries. Eran Werner, Tel-Aviv University Summer, 2005

Advanced Java Programming. Swing. Introduction to Swing. Swing libraries. Eran Werner, Tel-Aviv University Summer, 2005 Advanced Java Programming Swing Eran Werner, Tel-Aviv University Summer, 2005 19 May 2005 Advanced Java Programming, Summer 2005 1 Introduction to Swing The Swing package is part of the Java Foundation

More information

Frames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling

Frames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling Frames, GUI and events Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling Introduction to Swing The Java AWT (Abstract Window Toolkit)

More information

Java Swing. Recitation 11/(20,21)/2008. CS 180 Department of Computer Science, Purdue University

Java Swing. Recitation 11/(20,21)/2008. CS 180 Department of Computer Science, Purdue University Java Swing Recitation 11/(20,21)/2008 CS 180 Department of Computer Science, Purdue University Announcements Project 8 is out Milestone due on Dec 3rd, 10:00 pm Final due on Dec 10th, 10:00 pm No classes,

More information

CSE 331. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

CSE 331. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT CSE 331 Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/

More information

Chapter 8. Java continued. CS Hugh Anderson s notes. Page number: 264 ALERT. MCQ test next week. This time. This place.

Chapter 8. Java continued. CS Hugh Anderson s notes. Page number: 264 ALERT. MCQ test next week. This time. This place. Chapter 8 Java continued CS3283 - Hugh Anderson s notes. Page number: 263 ALERT MCQ test next week This time This place Closed book CS3283 - Hugh Anderson s notes. Page number: 264 ALERT Assignment #2

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 32 April 9, 2018 Swing I: Drawing and Event Handling Chapter 29 HW8: Spellchecker Available on the web site Due: Tuesday! Announcements Parsing, working

More information

I/O Framework and Case Study. CS151 Chris Pollett Nov. 2, 2005.

I/O Framework and Case Study. CS151 Chris Pollett Nov. 2, 2005. I/O Framework and Case Study CS151 Chris Pollett Nov. 2, 2005. Outline Character Streams Random Access Files Design case study Planning Iterations Character Streams Java internally represents strings as

More information

Unit 7: Event driven programming

Unit 7: Event driven programming Faculty of Computer Science Programming Language 2 Object oriented design using JAVA Dr. Ayman Ezzat Email: ayman@fcih.net Web: www.fcih.net/ayman Unit 7: Event driven programming 1 1. Introduction 2.

More information

Java continued. Chapter 8 ALERT ALERT. Last week. MCQ test next week. This time. This place. Closed book. Assignment #2 is for groups of 3

Java continued. Chapter 8 ALERT ALERT. Last week. MCQ test next week. This time. This place. Closed book. Assignment #2 is for groups of 3 Chapter 8 Java continued MCQ test next week This time This place Closed book ALERT CS3283 - Hugh Anderson s notes. Page number: 263 CS3283 - Hugh Anderson s notes. Page number: 264 ALERT Last week Assignment

More information

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008 Overview Lecture 7: Inheritance and GUIs Written by: Daniel Dalevi Inheritance Subclasses and superclasses Java keywords Interfaces and inheritance The JComponent class Casting The cosmic superclass Object

More information

User interfaces and Swing

User interfaces and Swing User interfaces and Swing Overview, applets, drawing, action listening, layout managers. APIs: java.awt.*, javax.swing.*, classes names start with a J. Java Lectures 1 2 Applets public class Simple extends

More information

1.00/ Introduction to Computers and Engineering Problem Solving. Quiz 2 / November 5, 2004

1.00/ Introduction to Computers and Engineering Problem Solving. Quiz 2 / November 5, 2004 1.00/1.001 Introduction to Computers and Engineering Problem Solving Quiz 2 / November 5, 2004 Name: Email Address: TA: Section: You have 90 minutes to complete this exam. For coding questions, you do

More information

CS 251 Intermediate Programming GUIs: Event Listeners

CS 251 Intermediate Programming GUIs: Event Listeners CS 251 Intermediate Programming GUIs: Event Listeners Brooke Chenoweth University of New Mexico Fall 2017 What is an Event Listener? A small class that implements a particular listener interface. Listener

More information

Class 16: The Swing Event Model

Class 16: The Swing Event Model Introduction to Computation and Problem Solving Class 16: The Swing Event Model Prof. Steven R. Lerman and Dr. V. Judson Harward 1 The Java Event Model Up until now, we have focused on GUI's to present

More information

CSE 331. Event- driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

CSE 331. Event- driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT CSE 331 Event- driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT Lecturer: Michael Hotan slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer,

More information

DM503 Programming B. Peter Schneider-Kamp.

DM503 Programming B. Peter Schneider-Kamp. DM503 Programming B Peter Schneider-Kamp petersk@imada.sdu.dk! http://imada.sdu.dk/~petersk/dm503/! ADVANCED OBJECT-ORIENTATION 2 Object-Oriented Design classes often do not exist in isolation from each

More information

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp DM550 / DM857 Introduction to Programming Peter Schneider-Kamp petersk@imada.sdu.dk http://imada.sdu.dk/~petersk/dm550/ http://imada.sdu.dk/~petersk/dm857/ GRAPHICAL USER INTERFACES 2 HelloWorld Reloaded

More information

Chapter 13 Lab Advanced GUI Applications Lab Objectives. Introduction. Task #1 Creating a Menu with Submenus

Chapter 13 Lab Advanced GUI Applications Lab Objectives. Introduction. Task #1 Creating a Menu with Submenus Chapter 13 Lab Advanced GUI Applications Lab Objectives Be able to add a menu to the menu bar Be able to use nested menus Be able to add scroll bars, giving the user the option of when they will be seen.

More information

Window Interfaces Using Swing. Chapter 12

Window Interfaces Using Swing. Chapter 12 Window Interfaces Using Swing 1 Reminders Project 7 due Nov 17 @ 10:30 pm Project 6 grades released: regrades due by next Friday (11-18-2005) at midnight 2 GUIs - Graphical User Interfaces Windowing systems

More information

Lecture 18 Java Graphics and GUIs

Lecture 18 Java Graphics and GUIs CSE 331 Software Design and Implementation The plan Today: introduction to Java graphics and Swing/AWT libraries Then: event-driven programming and user interaction Lecture 18 Java Graphics and GUIs None

More information

Table of Contents. Chapter 1 Getting Started with Java SE 7 1. Chapter 2 Exploring Class Members in Java 15. iii. Introduction of Java SE 7...

Table of Contents. Chapter 1 Getting Started with Java SE 7 1. Chapter 2 Exploring Class Members in Java 15. iii. Introduction of Java SE 7... Table of Contents Chapter 1 Getting Started with Java SE 7 1 Introduction of Java SE 7... 2 Exploring the Features of Java... 3 Exploring Features of Java SE 7... 4 Introducing Java Environment... 5 Explaining

More information

Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science

Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science mluckner@mini.pw.edu.pl http://www.mini.pw.edu.pl/~lucknerm } Abstract Window Toolkit Delegates creation and

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC124, WINTER TERM, 2009 FINAL EXAMINATION 7pm to 10pm, 18 APRIL 2009, Dunning Hall Instructor: Alan McLeod If the

More information

BASICS OF GRAPHICAL APPS

BASICS OF GRAPHICAL APPS CSC 2014 Java Bootcamp Lecture 7 GUI Design BASICS OF GRAPHICAL APPS 2 Graphical Applications So far we ve focused on command-line applications, which interact with the user using simple text prompts In

More information

G51PRG: Introduction to Programming Second semester Applets and graphics

G51PRG: Introduction to Programming Second semester Applets and graphics G51PRG: Introduction to Programming Second semester Applets and graphics Natasha Alechina School of Computer Science & IT nza@cs.nott.ac.uk Previous two lectures AWT and Swing Creating components and putting

More information

CSC 161 SPRING 17 LAB 2-1 BORDERLAYOUT, GRIDLAYOUT, AND EVENT HANDLING

CSC 161 SPRING 17 LAB 2-1 BORDERLAYOUT, GRIDLAYOUT, AND EVENT HANDLING CSC 161 SPRING 17 LAB 2-1 BORDERLAYOUT, GRIDLAYOUT, AND EVENT HANDLING PROFESSOR GODFREY MUGANDA 1. Learn to Generate Random Numbers The class Random in Java can be used to create objects of the class

More information

H212 Introduction to Software Systems Honors

H212 Introduction to Software Systems Honors Introduction to Software Systems Honors Lecture #19: November 4, 2015 1/14 Third Exam The third, Checkpoint Exam, will be on: Wednesday, November 11, 2:30 to 3:45 pm You will have 3 questions, out of 9,

More information

Java Mouse Actions. C&G criteria: 5.2.1, 5.4.1, 5.4.2,

Java Mouse Actions. C&G criteria: 5.2.1, 5.4.1, 5.4.2, Java Mouse Actions C&G criteria: 5.2.1, 5.4.1, 5.4.2, 5.6.2. The events so far have depended on creating Objects and detecting when they receive the event. The position of the mouse on the screen can also

More information

Summary Chapter 25 GUI Components: Part 2

Summary Chapter 25 GUI Components: Part 2 1040 Chapter 25 GUI Components: Part 2 ponent on the line. TheJTextField is added to the content pane with a call to our utility method addcomponent (declared at lines 79 83). MethodaddComponent takes

More information

Graphic User Interfaces. - GUI concepts - Swing - AWT

Graphic User Interfaces. - GUI concepts - Swing - AWT Graphic User Interfaces - GUI concepts - Swing - AWT 1 What is GUI Graphic User Interfaces are used in programs to communicate more efficiently with computer users MacOS MS Windows X Windows etc 2 Considerations

More information

Java Coordinate System

Java Coordinate System Java Graphics Drawing shapes in Java such as lines, rectangles, 3-D rectangles, a bar chart, or a clock utilize the Graphics class Drawing Strings Drawing Lines Drawing Rectangles Drawing Ovals Drawing

More information

1.00/1.001 Introduction to Computers and Engineering Problem Solving Spring Quiz 2

1.00/1.001 Introduction to Computers and Engineering Problem Solving Spring Quiz 2 1.00/1.001 Introduction to Computers and Engineering Problem Solving Spring 2010 - Quiz 2 Name: MIT Email: TA: Section: You have 80 minutes to complete this exam. For coding questions, you do not need

More information

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM Objectives The objectives of this assignment are: to get your first experience with Java to become familiar with Eclipse Java

More information

Graphical User Interfaces 2

Graphical User Interfaces 2 Graphical User Interfaces 2 CSCI 136: Fundamentals CSCI 136: Fundamentals of Computer of Science Computer II Science Keith II Vertanen Keith Vertanen Copyright 2011 Extending JFrame Dialog boxes Overview

More information

FirstSwingFrame.java Page 1 of 1

FirstSwingFrame.java Page 1 of 1 FirstSwingFrame.java Page 1 of 1 2: * A first example of using Swing. A JFrame is created with 3: * a label and buttons (which don t yet respond to events). 4: * 5: * @author Andrew Vardy 6: */ 7: import

More information

CS11 Java. Fall Lecture 3

CS11 Java. Fall Lecture 3 CS11 Java Fall 2014-2015 Lecture 3 Today s Topics! Class inheritance! Abstract classes! Polymorphism! Introduction to Swing API and event-handling! Nested and inner classes Class Inheritance! A third of

More information

Check out ThreadsIntro project from SVN. Threads and Animation

Check out ThreadsIntro project from SVN. Threads and Animation Check out ThreadsIntro project from SVN Threads and Animation Often we want our program to do multiple (semi) independent tasks at the same time Each thread of execution can be assigned to a different

More information

CMP-326 Exam 2 Spring 2018 Solutions Question 1. Version 1. Version 2

CMP-326 Exam 2 Spring 2018 Solutions Question 1. Version 1. Version 2 Question 1 30 30 60 60 90 20 20 40 40 60 Question 2 a. b. public Song(String title, String artist, int length, String composer) { this.title = title; this.artist = artist; this.length = length; this.composer

More information

Applet which displays a simulated trackball in the upper half of its window.

Applet which displays a simulated trackball in the upper half of its window. Example: Applet which displays a simulated trackball in the upper half of its window. By dragging the trackball using the mouse, you change its state, given by its x-y position relative to the window boundaries,

More information

KF5008 Program Design & Development. Lecture 1 Usability GUI Design and Implementation

KF5008 Program Design & Development. Lecture 1 Usability GUI Design and Implementation KF5008 Program Design & Development Lecture 1 Usability GUI Design and Implementation Types of Requirements Functional Requirements What the system does or is expected to do Non-functional Requirements

More information

encompass a group of features for building Graphical User Interfaces (GUI).

encompass a group of features for building Graphical User Interfaces (GUI). Java GUI (intro) JFC Java Foundation Classes encompass a group of features for building Graphical User Interfaces (GUI). javax.swing.* used for building GUIs. Some basic functionality is already there

More information

Java Swing. based on slides by: Walter Milner. Java Swing Walter Milner 2005: Slide 1

Java Swing. based on slides by: Walter Milner. Java Swing Walter Milner 2005: Slide 1 Java Swing based on slides by: Walter Milner Java Swing Walter Milner 2005: Slide 1 What is Swing? A group of 14 packages to do with the UI 451 classes as at 1.4 (!) Part of JFC Java Foundation Classes

More information

Lecture 3: Java Graphics & Events

Lecture 3: Java Graphics & Events Lecture 3: Java Graphics & Events CS 62 Fall 2017 Kim Bruce & Alexandra Papoutsaki Text Input Scanner class Constructor: myscanner = new Scanner(System.in); can use file instead of System.in new Scanner(new

More information

Dr. Hikmat A. M. AbdelJaber

Dr. Hikmat A. M. AbdelJaber Dr. Hikmat A. M. AbdelJaber Portion of the Java class hierarchy that include basic graphics classes and Java 2D API classes and interfaces. java.lang.object Java.awt.Color Java.awt.Component Java.awt.Container

More information

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling Handout 12 CS603 Object-Oriented Programming Fall 15 Page 1 of 12 Handout 14 Graphical User Interface (GUI) with Swing, Event Handling The Swing library (javax.swing.*) Contains classes that implement

More information

SELF-STUDY. Glossary

SELF-STUDY. Glossary SELF-STUDY 231 Glossary HTML (Hyper Text Markup Language - the language used to code web pages) tags used to embed an applet. abstract A class or method that is incompletely defined,

More information

CS11 Java. Fall Lecture 4

CS11 Java. Fall Lecture 4 CS11 Java Fall 2006-2007 Lecture 4 Today s Topics Interfaces The Swing API Event Handlers Inner Classes Arrays Java Interfaces Classes can only have one parent class No multiple inheritance in Java! By

More information

CSE 331 Software Design & Implementation

CSE 331 Software Design & Implementation CSE 331 Software Design & Implementation Hal Perkins Winter 2018 Java Graphics and GUIs 1 The plan Today: introduction to Java graphics and Swing/AWT libraries Then: event-driven programming and user interaction

More information

Design patterns for graphical user interface applications

Design patterns for graphical user interface applications Design patterns for graphical user interface applications Prof.Asoc. Alda Kika Department of Informatics Faculty of Natural Sciences University of Tirana Outline Pattern Concept Design pattern in computer

More information

Packages: Putting Classes Together

Packages: Putting Classes Together Packages: Putting Classes Together 1 Introduction 2 The main feature of OOP is its ability to support the reuse of code: Extending the classes (via inheritance) Extending interfaces The features in basic

More information