1 / 12

IM103 week 11 Part 2 P532 Case Study part 2: the Airport GUI

IM103 week 11 Part 2 P532 Case Study part 2: the Airport GUI. Learning objectives By the end of this lecture you should be able to:. use the JTabbedPane Swing class to create an attractive user interface; add tool tips to Swing components using the setToolTipText method;

chick
Download Presentation

IM103 week 11 Part 2 P532 Case Study part 2: the Airport GUI

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. IM103 week 11 Part 2 P532 Case Study part 2: the Airport GUI Learning objectives By the end of this lecture you should be able to: • use the JTabbedPane Swing class to create an attractive user interface; • add tool tips to Swing components using the setToolTipText method; • add short cut keys to Swing menu items using the setMnemonic method.

  2. JFrame JMenuBar JLabel JTabbedPane JPanel JButton Swing based design of the GUI

  3. at the moment the first tab is selected components associated with the other two tabs are kept hidden until the tabs are clicked these components are added to the JPanel the first tabbed component is a JPanel The JTabbedPane class You can think of a JTabbedPane component as a collection of overlapping tabbed "cards", on which you place other user interface components. A particular card is revealed by clicking on its tab.

  4. Creating a JTabbedPane // constructor created an empty JTabbedPane JTabbedPane tabs = new JTabbedPane(); // create a JPanel component JPanel controlPanel = new Jpanel(); /* other components can be added to this panel either now or later */ /* add this panel to the JTabbedPane component and give the tab a title */ tabs.addTab("Flight Control", controlPanel,);

  5. Both "Flight Arrivals" and "Flight Departures" consist of a text area

  6. Adding a JTextArea to a JTabbedPane To add scroll bars to a JTextArea, the JTextArea component has to be added to a JScrollPane component. The JScrollPane is then added to the JTabbedPane as follows: // create text area JTextArea jtaArrivals = new JTextArea(30,20); // add text area to scroll pane JScrollPane jspArrivals = new JScrollPane(jtaArrivals); // add scroll pane to JTabbedPane component tabs.addTab("Flight Arrivals", jspArrivals);

  7. Tool Tips A tool tip is an informative description of the purpose of a GUI component. This informative description is revealed when the user places the cursor over the component. We have added tool tips to our buttons.

  8. The setToolTipText method Adding a tool tip to a Swing component is easy; just use the setToolTipText method: // create Swing component JButton jbtnBoard = new JButton ("Board"); // add tool tip text jbtnBoard.setToolTipText ("Record a flight as ready for boarding");

  9. the underlined 'F' indicates that this menu can be selected by pressing ALT-F Short cut keys Ordinarily, a graphical component is selected by clicking on it with a mouse. Sometimes it is convenient to provide keyboard access to such items by means of a short cut.

  10. The setMnemonic method: Creating keyboard short cuts for Swing components is straightforward, just use the setMnemonic method: // create Swing component JMenu fileMenu = new JMenu("File"); // add keyboard shortcut fileMenu.setMnemonic('F');

  11. Airport Dialogue Boxes Whenever a button is selected in the "Flight Control" screen, a dialogue box is required to get and process user input.

  12. JDialog AirportDialog RegisterDialog RequestToLandDialog LandingDialog BoardingDialog TakeOffDialog Implementing the Airport Dialogs It makes sense to generalise common features of the dialogue into a base class, AirportDialog, and then use inheritance to develop the specialized dialogue classes: Code for all classes are discussed in Charatan and Kans chapter 21.

More Related