FH-Hof Auswahlmenüs Richard Göbel. FH-Hof Aufbau einer Menüleiste - Klassen JMenuBarJMenu JMenuItem.

Slides:



Advertisements
Similar presentations
1 Event Listeners Some Events and Their Associated Event Listeners Act that Results in the EventListener Type User clicks a button, presses Enter while.
Advertisements

FH-Hof Dialoge Richard Göbel. FH-Hof Inhalt JDialog Vordefinierte Dialoge File Browser.
15 Copyright © 2005, Oracle. All rights reserved. Adding User Interface Components and Event Handling.
2I1073 Lektion 2 KTH-MI Peter Mozelius Servlets, säkerhet, och filhantering.
Import javax.swing.*; public class FrameTest { public static void main(String args[]) { JFrame f = new JFrame("Frame Test"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLO.
1 cs205: engineering software university of virginia fall 2006 Wimpy Interfaces.
Programming in Java; Instructor:John Punin Graphics and Graphical User Interfaces1 Programming in Java Graphics and Graphical User Interfaces.
Page w16.1 – Spring 2010Steffen Vissing Andersen SDJ I1 subjects, Spring 2010 Agenda – Week 16, 2010 GUI.
Chapter 11 Creating User Interfaces F What is JavaBean? F JComponent F JButton  ImageIcon  JLabel  JTextField  JTextArea  JComboBox  JList  JCheckBox.
Chapter 19 – Graphical User Interfaces
Graphical User Interfaces (Part IV)
TCU CoSc Programming with Java Handling Events.
Swing: the art of the GUI COMP204, Bernhard Pfahringer.
Multiple Device User Interface A Rule Approach Paul D. Johnson Final Presentation (SE690) Supervised by Dr. Jia
Fall 2007CS 225 Graphical User Interfaces Event Handling Appendix C.
Jan Event Handling -1.1 Yangjun Chen Dept. Business Computing University of Winnipeg.
CS221 © 2007 Ray S. Babcock Menus, Toolbars, and a Mouse Appendix C.6-C.7.
Event Handling Events and Listeners Timers and Animation.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 14 – Graphical User Components Part 2 Outline 14.1 Introduction 14.2 JTextArea 14.3 Creating.
1 lecture 14 GUI PROGRAMMING IVLecture 15 Graphical User Interfaces (cont.) Overview  GUI Programming (cont.)  Example 1: Creating Multi-layout GUIs.
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.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 14 GUI and Event-Driven Programming.
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 L46 Advanced GUI Component (1). 2 OBJECTIVES  To create and manipulate sliders, and menus,
Advanced Java Class GUI, part 2. JComponent methods addXXXListener(XXXListener) repaint() – [optional arguments: delay and coordinates of sub-area to.
More on Creating GUIs in Java using Swing David Meredith Aalborg University.
Graphic User Interfaces Part 1. Typical GUI Screen from Microsoft Word What GUI “components” can you see? –Menus? Buttons? Labels? What else? –Anything.
Using Inheritance to Customize Frames Use inheritance for complex frames to make programs easier to understand Design a subclass of JFrame Store the components.
MENUS AND PROGRESS BARS Joey Erlandson and Alex Blue.
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.
7-Oct-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming Design Topic : User Interface Components with.
1 Introduction to JFC/Swing Alex Chaffee jGuru Training by the MageLang Institute
3-1 Composite Design Pattern Rick Mercer. 2 Composite Pattern Context : –Often complex structures are built with container and primitive objects. Container.
CS377A: A Programming Approach to HCI Jan Borchers Spring Swing Refresher David Merrill 5/14/2002
3-1 Composite Design Pattern Rick Mercer. 2 Composite Pattern Recurring problem: –Often complex structures are built with container and primitive objects.
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
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.
1.  Container  JComponent  AbstractButton  JButton  JMenuItem  JCheckBoxMenuItem  JMenu  JRadioButtonMenuItem  JToggleButton  JCheckBox  JRadioButton.
Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin, and Skylight.
Chapter 15: Advanced GUI Topics. Objectives Use content panes Use color Learn more about layout managers Use JPanel s to increase layout options Create.
Graphical User Interfaces (Part 2) 1. View  view  presents the user with a sensory (visual, audio, haptic) representation of the model state  a user.
Java Programming Introduction to Swing Class 7. Swing Graphical User Interface Provides Windows Menus Buttons Labels Textboxes In the beginning, there.
Session 28 Swing - II. Java Simplified / Session 28 / 2 of 49 Review The Java Foundation Classes (JFC) are developed as an extension to Abstract Windows.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 22.1 Test-Driving the Typing Skills Developer.
AGDER COLLEGEFACULTY OF ENGINEERING & SCIENCE GUI Components ikt403 – Object-Oriented Software Development.
CS1054: Lecture 21 - Graphical User Interface. Graphical User Interfaces vs. Text User Interface.
Swing - 2 Session 13. Swing - 2 / 2 of 38 Objectives (1) Discuss trees and tables Discuss progress bars Discuss MVC architecture Describe menus.
1CS480: Graphical User Interfaces. Dario Salvucci, Drexel University. Lecture 9: Swing Components.
SD2054 Software Development. By the end of this lecture you should be able to: Advanced Graphics Programming create pull down menus create combo boxes.
SWING 的圖形介面元件. JLabel JLabel label = new JLabel(" 關閉 "); JLabel label1 = new JLabel( new ImageIcon("tree.jpg")); JLabel(String,int), JLabel(ImageIcon,
Software Construction LAB 08 Java Programming with SWING GUI Builder.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 15 : Swing III King Fahd University of Petroleum & Minerals College of Computer.
Chapter 10 GUI1 例 : LunarPhases, 月亮盈亏 (JB demo) 如何使用 Compound Bounder 如何使用 Combo Boxes 如何使用 Loading Multiple Images.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
View  view  presents the user with a sensory (visual, audio, haptic) representation of the model state  a user interface element (the user interface.
Introduction to GUI in 1 Graphical User Interface 3 Nouf Almunyif.
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.
Objects First With Java A Practical Introduction Using BlueJ Building Graphical User Interfaces (GUIs) Week
C Sc 335 Object-Oriented Programming and Design Rick Mercer
Chapter 6 Building Java GUIs. MVC Model View Controller The model passes its data to the view for rendering The view determines which events are passed.
·  Chapter 29 Menus.
Object-Oriented Programming (Java), Unit 22
Advanced User Interfaces
GUI III IS
it appears for a few seconds when the mouse cursor stays motionless
Graphical User Interface
Presentation transcript:

FH-Hof Auswahlmenüs Richard Göbel

FH-Hof Aufbau einer Menüleiste - Klassen JMenuBarJMenu JMenuItem

FH-Hof Aufbau einer Menüleiste - Programmcode Teil 1 JMenuBar menuBar; JMenu menu; JMenuItem menuItem; menuBar = new JMenuBar(); menu = new JMenu("File"); menu.setMnemonic('F'); menuBar.add(menu); menuItem = new JMenuItem("Load"); menuItem.setMnemonic('L'); menuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_L, ActionEvent.ALT_MASK)) menu.add(menuItem);

FH-Hof Aufbau einer Menüleiste - Programmcode Teil 2 menuItem = new JMenuItem("Save"); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem("Quit"); menu.add(menuItem);....setJMenuBar(menuBar);

FH-Hof Aufbau einer Menüleiste - Untermenüs

FH-Hof Aufbau einer Menüleiste - Programmcode für Untermenüs menu = new JMenu("Edit"); menuBar.add(menu); JMenu submenu = new JMenu("Create"); menu.add(submenu); menuItem = new JMenuItem("Student"); submenu.add(menuItem); menuItem = new JMenuItem("Lecturer"); submenu.add(menuItem); menuItem = new JMenuItem("Delete"); menu.add(menuItem); menuItem = new JMenuItem("Alter"); menu.add(menuItem);

FH-Hof Aufbau einer Menüleiste - Klassen für CheckBoxes und RadioButtons JRadioButtonMenuItem JCheckBoxMenuItem

FH-Hof Aufbau einer Menüleiste - Programmcode CheckBoxes und RadioButtons ButtonGroup group = new ButtonGroup(); rbMenuItem = new JRadioButtonMenuItem("Alt Option 1"); rbMenuItem.setSelected(true); group.add(rbMenuItem); menu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem("Alt Option 2"); group.add(rbMenuItem); menu.add(rbMenuItem);... cbMenuItem = new JCheckBoxMenuItem("Option 3"); menu.add(cbMenuItem); cbMenuItem = new JCheckBoxMenuItem("Option 4"); menu.add(cbMenuItem);

FH-Hof PopupMenu - Klassen PopupMenu JMenuItem

FH-Hof PopupMenu - Menü erzeugen JPopupMenu menu = new JPopupMenu(); JMenuItem itemRed = new JMenuItem("Red"), itemGreen = new JMenuItem("Green"), itemBlue = new JMenuItem("Blue"); menu.add(itemRed); menu.add(itemGreen); menu.add(itemBlue);

FH-Hof PopupMenu - Menü einbinden.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getModifiers() == MouseEvent.BUTTON3_MASK) { menu.show(e.getComponent(), 0, 0); } });

FH-Hof ActionListener für MenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { label.setText("RED"); } });