1 / 120

SD2054 Software Development

SD2054 Software Development. Advanced Graphics Programming. By the end of this lecture you should be able to:. create pull down menus create combo boxes create option dialogues create message dialogues create input dialogues create confirm dialogues. import javax.swing .*;.

Télécharger la présentation

SD2054 Software Development

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SD2054 Software Development

  2. Advanced Graphics Programming By the end of this lecture you should be able to: • create pull downmenus • create combo boxes • create option dialogues • create message dialogues • create input dialogues • create confirm dialogues.

  3. import javax.swing.*;

  4. Making choices pull-down menus combo boxes

  5. Pull-down menus

  6. Pull-down menus

  7. Pull-down menus

  8. Pull-down menus

  9. Pull-down menus

  10. Pull-down menus

  11. Pull-down menus JFrame

  12. public class Flag extends JFrame implementsActionListener { } JFrame

  13. Declare menu components as attributes of the Flag class

  14. JMenuBar

  15. private JMenuBar bar = new JMenuBar(); JMenuBar

  16. JMenu

  17. private JMenu topStripeMenu = new JMenu("Top Colour"); JMenu

  18. JMenu

  19. private JMenu middleStripeMenu = new JMenu(“Middle Colour"); JMenu

  20. JMenu

  21. private JMenu bottomStripeMenu = new JMenu(“Bottom Colour"); JMenu

  22. JMenuItem

  23. private JMenuItem blueStripe = new JMenuItem("Blue"); JMenuItem

  24. JMenuItem

  25. private JMenuItem redStripe = new JMenuItem(“Red"); JMenuItem

  26. Assemble menu components onto the screen in the Constructor

  27. public Flag( ) { setVisible(true); }

  28. First, add menu-items …..

  29. … to menu

  30. blueStripe

  31. topStripeMenu blueStripe

  32. topStripeMenu.add(blueStripe); topStripeMenu blueStripe

  33. topStripeMenu redStripe

  34. topStripeMenu.add(redStripe); topStripeMenu redStripe

  35. Then, add menu …..

  36. … to menu-bar

  37. bar

  38. topStripeMenu bar

  39. bar.add(topStripeMenu); topStripeMenu bar

  40. Finally, add menu-bar …..

  41. …. to frame

  42. bar

  43. setJMenuBar(bar); bar

  44. Processing menu choices…..

  45. ..first, give each menu item a listener in the constructor.

  46. blueStripe

More Related