Menus Pull-downs and popups. Tooltips –a ToolTip is a context-sensitive text string that is displayed in a popup window when the mouse rests over a particular.

Slides:



Advertisements
Similar presentations
Chapter 11 Creating User Interfaces F What is JavaBean? F JComponent F JButton  ImageIcon  JLabel  JTextField  JTextArea  JComboBox  JList  JCheckBox.
Advertisements

Graphical User Interfaces (Part IV)
CS221 © 2007 Ray S. Babcock Menus, Toolbars, and a Mouse Appendix C.6-C.7.
Things to mention public static void main(String [] args) imports comments –block comments /* … */ –single-line comments // –javadoc comments and tags.
1 lecture 14 GUI PROGRAMMING IVLecture 15 Graphical User Interfaces (cont.) Overview  GUI Programming (cont.)  Example 1: Creating Multi-layout GUIs.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
1 Chapter 23 Menus, Toolbars, Dialogs, and Internal Frames.
Object-Oriented Software Engineering PersonGui (Mark 2) Case Study.
1 lecture 12Lecture 15 Graphical User Interfaces (cont.) Overview  GUI Programming (cont.)  Example 1: Creating Multi-layout GUIs with Tooltips.  Example.
A Guide to Oracle9i1 Creating an Integrated Database Application Chapter 8.
GUI and Event-Driven Programming Part 2. Event Handling An action involving a GUI object, such as clicking a button, is called an event. The mechanism.
1 L47 Advanced GUI Component (2). 2 OBJECTIVES  To create and manipulate pop-up menus and windows.  To change the look-and-feel of a GUI, using Swing's.
Advanced Java Class GUI, part 2. JComponent methods addXXXListener(XXXListener) repaint() – [optional arguments: delay and coordinates of sub-area to.
GUI Programming using NetBeans. What is a GUI ? GUI – Graphical User Interface The (visual) interface between humans and computers Ranging from command.
More on Creating GUIs in Java using Swing David Meredith Aalborg University.
BİL528 – Bilgisayar Programlama II Advanced Controls, Menus, Toolbars, and Status Bars 1.
CC1007NI: Further Programming Week 5 Dhruba Sen Module Leader (Islington College)
Graphic User Interfaces Part 1. Typical GUI Screen from Microsoft Word What GUI “components” can you see? –Menus? Buttons? Labels? What else? –Anything.
BIM313 – Advanced Programming Simple Controls 1. Contents Traditional Controls – Labels, Text Boxes, Buttons, Check Boxes, List Boxes, Combo Boxes Advanced.
Getting Started The structure of a simple wxWidgets program, Look at where and how a wxWidgets application starts and ends, how to show the main window,
Creating GUIs in Java using Swing Medialogy, Semester 7, 2010 Aalborg University, Aalborg David Meredith.
Creating User Interfaces F JComponent F JButton F JLabel F JTextField F JTextArea F JComboBox F JList F JCheckBox F JRadioButton F Dialogs.
CS 450: COMPUTER GRAPHICS REVIEW: GLUT INPUT FUNCTIONS SPRING 2015 DR. MICHAEL J. REALE.
Introduction To Microsoft Word C Apply intermediate skills in utilizing word processing software Word processing programs make the writing process.
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
1 The EDIT Program The Edit program is a full screen text editor that allows you to: Create text files Create text files Edit an existing text files Edit.
Chapter 3 – Part 1 Word Processing Writer for Linux CMPF 112 : COMPUTING SKILLS.
1CS 338: Graphical User Interfaces. Dario Salvucci, Drexel University. Lecture 15: Menus, Toolbars, and Text.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved
More Event Handling Adapters Anonymous Listeners Pop menus Validating User Input.
Productivity Programs Common Features and Commands.
CSE 219 Patterns in Programming More Design Patterns.
SWING. AbstractButton Swing Buttons are subclasses of the AbstractButton class, which extends JComponent. Abstract class javax.swing.AbstractButton AbstractButton.
FEN IntroJava2006 AAU1 GUI: Graphical User Interface AWT/SWING: Components Drag and Drop in NetBeans Events Listeners.
Exploring Windows and Essential Computing Concepts 1 Windows Desktop u Windows Basics u Icon u Start Button u My Computer u Network Neighborhood u Recycle.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Graphical User Interfaces (Part 2) 1. View  view  presents the user with a sensory (visual, audio, haptic) representation of the model state  a user.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 22.1 Test-Driving the Typing Skills Developer.
CS1054: Lecture 21 - Graphical User Interface. Graphical User Interfaces vs. Text User Interface.
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
Visual Basic Programming Introduction VB is one of the High level language VB has evolved from the BASIC language. BASIC stands for Beginners All-purpose.
Menus Menus provide groups of related commands for windows applications Menu, menu items, submenus A menu item that contains a submenu is considered to.
Slide 1 Using Menu Bar & Common Dialog Boxes. Slide 2 Setting Up the Main Items v First open the form on which you want the menu located v Then start.
Swing - 2 Session 13. Swing - 2 / 2 of 38 Objectives (1) Discuss trees and tables Discuss progress bars Discuss MVC architecture Describe menus.
SD2054 Software Development. By the end of this lecture you should be able to: Advanced Graphics Programming create pull down menus create combo boxes.
Creating a Window. A basic window in Java is represented by an object of the class Window in the package java.awt.
Ajmer Singh PGT(IP) JAVA IDE Programming - I. Ajmer Singh PGT(IP) GUI (Graphical User Interface) It is an interface that uses a graphic entities along.
Software Construction LAB 08 Java Programming with SWING GUI Builder.
Basics of Windows 95/98/NT. Versions of Windows Windows 95 and 98 used mainly on standalone computers Windows NT used on networked computers (as in our.
Computer Science [3] Java Programming II - Laboratory Course Lab 4 -1 : Introduction to Graphical user interface GUI Components Faculty of Engineering.
Advanced Java Class Events. change in state initiated by system or user java.util.EventObject java.awt.event java.swing.event.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 15 : Swing III King Fahd University of Petroleum & Minerals College of Computer.
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
1 Lecture 8: User Interface Components with Swing.
MATLAB and SimulinkLecture 61 To days Outline Graphical User Interface (GUI) Exercise on this days topics.
Menus and Toolbars CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
View  view  presents the user with a sensory (visual, audio, haptic) representation of the model state  a user interface element (the user interface.
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
Introduction to GUI in 1 Graphical User Interface 3 Nouf Almunyif.
Objects First With Java A Practical Introduction Using BlueJ Building Graphical User Interfaces (GUIs) Week
Visual Basic.NET BASICS Lesson 14 Menus and Printing.
Java Programming Fifth Edition Chapter 13 Introduction to Swing Components.
Chapter 7 Multiple Forms, Modules, and Menus. Section 7.2 MODULES A module contains code—declarations and procedures—that are used by other files in a.
Human Computer Interaction Lecture 07 The Interaction.
·  Chapter 29 Menus.
Advanced User Interfaces
Graphical User Interface
Constructors, GUI’s(Using Swing) and ActionListner
Presentation transcript:

Menus Pull-downs and popups

Tooltips –a ToolTip is a context-sensitive text string that is displayed in a popup window when the mouse rests over a particular object on the screen JButton myButton = new JButton(“Accept Order”); myButton.setToolTipText(“By selecting this button you accept the order and it will be shipped to you”);

Menus To create a Menu: –create a Menu Bar –create a Menu Object –create Menu Items –add Menu Items to a Menu Object –add Menu Objects to the Menu Bar

Menus Pull-downs are found on a Menu bar Menu bars may only appear in frames JMenuBar menuBar = new JMenuBar();

Menus Create the Menu object JMenu hamburgerMenu = new JMenu(“Hamburger”); Next create the Menu items JMenuItem plainItem = new JMenuItem(“Plain”); JMenuItem mustardItem = new JMenuItem(“Mustard”); JMenuItem everythingItem = new JMenuItem(“Everything”):

Menus Now add the item to the Menu object hamburgerMenu.add(plainItem); Next add the Menu objects to the Menu Bar menuBar.add(hamburgerMenu);

Menus Selecting a menu item will generate an action event. You need to install an action event listener for each menu item plainItem.addActionListener(this); Adding menu items listeners is easy but TEDIOUS.

Cut and Paste example –JMenu menu = new JMenu(“Edit”); –item = new JMenuItem(“Cut”); –item.addActionListener(this); –menu.add(item); –item = new JMenuItem(“Paste”); –item.addActionListener(this); –menu.add(item); –menuBar.add(menu);

Reacting to menu events Public void actionPerformed(ActionEvent evt); –{ if (evt.getSource() instanceof JMenuItem) String arg = evt.getActionCommand(); if (arg.equals(“Cut”)){ do something } else if (arg.equals(“Paste”)) {do something else} –}

Menu Items Adding –adds a menu item Removing –removes a specific item from the menu Inserting –adds a new menu item (or submenu) to the menu at a specific index Gray-out menu items

Menus Icons on a menu item –Icon hamburgerIcon = new (“smallHamburger.gif”); –item = new JMenuItem(“Plain”, hamburgerIcon)); –hamburger.add(item);

Checkboxs on menu items Checkbox - when the user selects the menu item, the item automatically toggles between checked and unchecked. JCheckBoxMenuItem readonlyItem = new JCheckBoxMenuItem(“Read only”);

Radio buttons on menu items Radio button menu items work just like regular radio buttons. You must add them to a button group. When one of the buttons in the selected, all others are deselected.

Radio buttons on menu items ButtonGroup group = new ButtonGroup(); JRadioButtonMenuITem plainItem = new JRadioButtonMenuItem(“Plain”); plainItem.setSelected(true); JRadioButtonMenuItem everythingItem = new JRadioButtonMenuItem (“Everything”); group.add(plainItem); group.add(everythtingItem);

Popup menus A pop-up menu is a menu that is not attached to a menu bar but that floats somewhere on the frame or panel. JPopupMenu popup = new JPopupMenu(); You then add menu items in the usual way. You must specify the parent component and the location of the popup popup.show(panel, x, y);

Popups Pop-up trigger install a mouse listener add code for the mouse handler: –public void mouseReleased(MouseEvent e) –{ if (e. isPopupTrigger()) –popup.show(e.getComponent(), e.getX(), getY() ); –}

Keyboard Mnemonics It is a real convenience for the experienced user to select menu items by keyboard mnemonics. JMenuItem cutItem = new JMenuItem(“Cut”, ‘T’); To select a top-level menu from the menu bar, you hit ALT+ the mnemonic letter JMenu helpMenu = new Jmenu (“Help”); helpMenu.setMnemonic(‘H’);

Accelerators Accelerators are keyboard shortcuts that let you select menu items without ever opening a menu. E.g., CTRL+O and CTRL+S in many programs allow the user to Open and Save items in the File menu.

Accelerators setAccelerator method will attach an accelerator key to a menu item E.g., the following will attach the accelerator CTRL+O to the openITem menu item: openItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK _O, InputEvent.CTRL+MASK)); When the user presses the accelerator key combination, this will select the menu option and fires an action event, as if the user had selected the menu option manually