Java Swing Controls. JButton One of the most commonly used swing component is Push Button or simply button which is created through JButton class of Swing.

Slides:



Advertisements
Similar presentations
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 17 Creating User Interfaces.
Advertisements

Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 16 Creating User Interfaces.
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 03.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 15 Creating User.
ListBoxes The list box control allows the user to view and select from multiple items in a list. CheckedListBox control extends a list box by including.
Group Boxes and Panels Arrange components on a GUI Buttons and etc. can be placed inside a group box or panel. All these buttons move together when the.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L04 (Chapter 15) Creating.
1 Creating User Interfaces. 2 Motivations A graphical user interface (GUI) makes a system user-friendly and easy to use. Creating a GUI requires creativity.
CA 121 Intro to Programming Tariq Aziz and Kevin Jones GUI Programming in Visual Studio.NET Chapter 3 Tariq Aziz and Kevin Jones.
Compunet Corporation Programming with Visual Basic.NET GUI Chapter 3 Week 13 Tariq Aziz and Kevin Jones.
Tutorial 6 Forms Section A - Working with Forms in JavaScript.
CST JavaScript Validating Form Data with JavaScript.
PROGRAMMING REVIEW Lab 2 EECS 448 Dr Fengjun Li and Meenakshi Mishra.
BIM313 – Advanced Programming Simple Controls 1. Contents Traditional Controls – Labels, Text Boxes, Buttons, Check Boxes, List Boxes, Combo Boxes Advanced.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
Combo Box, Check Boxes, and Radio Buttons. Radio Buttons User can click radio buttons, just like other buttons BUT Radio buttons are mutually exclusive.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
1 Graphical User Interfaces Part 2 Outline ListBoxes and CheckedListBoxes ListBoxes CheckedListBoxes ComboBoxes.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 13 Creating User.
ListBox, ComboBox, Menu Chapter 5.4, ComboBox Control: Properties & Methods u Combines TextBox features with a short drop- down list  cboOne.AddItem(string)
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
Java Swing. Swing is a set of classes that provides more powerful and flexible components than are possible with the AWT. In addition to the familiar.
Dale Roberts GUI Programming using Java - GUI Components Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
Microsoft FrontPage 2003 Illustrated Complete Creating a Form.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 35 MVC and Swing MVC.
GUI Programming using NetBeans. RHS – SOC 2 GUI construction We have previously talked about elements in a (simple) GUI –Frames, Panes and Dialogs –Text.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 15 Creating User.
CHAPTER:07 JAVA IDE PROGRAMMING-II Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Getting Input. Text Fields A text field is a box that the user can type in Use the JTextField class JTextField tf1 = new JTextField(15); 15 is the field.
CHAPTER:08 JAVA IDE PROGRAMMING-III Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
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.
Creating User Interfaces Chapter 13 CSCI CSCI 1302 – Creating User Interfaces2 Outline Introduction Common Features of Swing GUI Components Buttons.
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.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al- ajmi Chapter 3 Some Visual Basic Controls and Events Visual Basic. NET.
CSI 3125, Preliminaries, page 1 AWT Control. CSI 3125, Preliminaries, page 2 AWT Control The AWT supports the following types of controls: ■ Labels ■
Java Programming, Second Edition Chapter Thirteen Understanding Swing Components.
TIU Note Templates. Learning Objectives Discuss Human Factor Internationals (HFIs) recommendations for Text Integration Utility (TIU) Templates Become.
Computer Science [3] Java Programming II - Laboratory Course Lab 4 -1 : Introduction to Graphical user interface GUI Components Faculty of Engineering.
Creating Menus Menu Bar – behaves like standard Windows menus Can be used in place of or in addition to buttons to execute a procedure Menu items are controls.
 Figure illustrates a hierarchy containing many event classes from the package java.awt.event.  Used with both AWT and Swing components.  Additional.
IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked.
Chapter 5 Introduction To Form Builder. Lesson C Objectives  Use sequences to automatically generate primary key values in a form  Create lists of values.
MATLAB and SimulinkLecture 61 To days Outline Graphical User Interface (GUI) Exercise on this days topics.
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
COMPUTER PROGRAMMING I Apply Procedures to Develop List Box and Combo Box Objects.
CSCI 6962: Server-side Desig n and Programming ASP Server Controls.
GUIs & Event-Driven Programming Chapter 11 Review.
Chapter 5 Validating Form Data with JavaScript
TIU Note Templates.
A First Look at GUI Applications Radio Buttons and Check Boxes
Topics Graphical User Interfaces Using the tkinter Module
Christopher Budo, Davis Nygren, spencer franks, Luke miller
Graphical User Interface in MATLAB
Java GUI.
Chap 7. Building Java Graphical User Interfaces
Graphical User Interfaces -- Introduction
Chapter 7 Creating User Interfaces
Chapter 17 Creating User Interfaces
Chapter 17 Creating User Interfaces
Presentation transcript:

Java Swing Controls

JButton One of the most commonly used swing component is Push Button or simply button which is created through JButton class of Swing API. Buttons are action components ie, these can be programmed for an action. When user clicks on a button, during runtime, corresponding action takes place.

COMMONLY USED COMPONENT METHODS MethodDescription String getText()Returns the text displayed by the button void setText(String s)Sets the text displayed by the button to String value specified in parenthesis. boolean isSelected()Returns True if the button is selected. Makes sense only for buttons that have on /off state, such as check boxes. void setSelected(boolean)Sets the button to appear as selected. Makes sense only for buttons that have on /off state, such as check boxes. void setIcon(Icon)Sets the Image displayed by the button when the button isn’t selected or pressed.

JButton Events The most common event of Push button is Action Event, The most common event of Push button is Action Event, which is handled by actionPerformed() method of event listener ActionListener.

CHECK BOXES A check box is a control with a rectangular area that can be checked or unchecked. A check box indicates whether a particular condition is On or Off. You can use check boxes in an application to give users True / False or Yes/ No options. As check boxes work independently of each other, a user can select any number of check boxes at the same time.

COMMONLY USED COMPONENT METHODS MethodDescription String getText()Returns the text displayed by the check box boolean isEnabled()Returns True if the check box is enabled. boolean isSelected()Returns True if the button is selected boolean isVisible()Returns True if the button is visible. void setEnabled(boolean b)Enables the button if True is passed otherwise disables the check box. void setVisible(boolean b)Makes the button Visible if True is passed otherwise hides the check box. void setText(String s)Sets the text displayed by the check box to String value specified in parenthesis.

JCheckbox Events The most commonly responded event is Item event which gets fired whenever the check box is selected or unselected. An Item event is handled through event listener Item Listener whose interface has method itemStateChanged() that handles the Item event.

JRADIO BUTTON Radio buttons present a set of two or more choices to the user. Unlike check boxes, radio buttons should always work as part of a group. They provide mutually exclusive options. ie, one out of a group gets selected. To make the radio buttons mutually exclusive, the radio buttons should be made part of a button group. A button group allows only one of its components to be selected.

COMMONLY USED COMPONENT METHODS MethodDescription String getText()Returns the text displayed by the radio button boolean isEnabled()Returns True if the radio button is enabled. boolean isSelected()Returns True if the checkbox is selected boolean isVisible()Returns True if the checkbox is visible. void setEnabled(boolean b)Enables the checkbox if True is passed otherwise disables the radio button. void setVisible(boolean b)Makes the checkbox Visible if True is passed otherwise hides the radio button. void setText(String s)Sets the text displayed by the radio button to String value specified in parenthesis.

JRadio Button Events The most commonly responded event is Item event which gets fired whenever the radio button is selected or unselected. An Item event is handled through event listener Item Listener whose interface has method itemStateChanged() that handles the Item event

JLIST BOX A list is a box shaped control containing a list of values from which single or multiple selections can be made. In addition a list control allows you to display a list of text-items or graphics. Selection model of a list By default, a list selection model allows any combination of items to be selected at a time. You can specify a different selection mode by setting the selectionMode property of the list. It can be set to any one of the following modes: SINGLE -User can select a single item SINGLE_INTERVAL -User can select single range of items (shift+select) MULTIPLE_INTERVAL -User can select multiple ranges of items within a list. (ctrl+select) The model property of a list is an associated object that stores the data displayed by the list.

COMMONLY USED COMPONENT METHODS void addElement(object entry)Adds an item to the item list, in the end of the list box void insertElementAt(object entry,int position)Adds an entry at the position specified int size()Returns the number of entries in the list model int getSelected Index()Returns the index of the selected Item. object getSelected Value()Returns the selected value when only a single item is selected. Boolean isEmpty()Returns true if the list is empty, false otherwise boolean isEditable()Indicates whether the combo box’s text field is editable or not void removeAllItems()Removes all items from the combo box boolean removeElement(object entry)Removes the specified item, returns true if successful. void removeElementAt(int index)Removes the item at the specified index void setEditable(boolean value)Sets the combo box’s text field editable. void setMaximumRowCount(int count)Sets the number of rows displayed when the combo box list is dropped down void setSelectedIndex(int index)Selects the item at specified index void setSelectedItem(object item)Selects the specified item

JCOMBO BOX A combo box appears as a text field along with a drop down list arrow from which the user can choose a value. It is a cross between the text field and a list. By default the text field of a combo box is uneditable, but you can change it to be editable by setting its editable property to true. ie, checked. If the text field portion of the control is editable, the user can enter a value into the field or edit a value retrieved from the drop down list. You can define the elements by clicking the model property and then typing the elements in the model editor dialog.

COMMONLY USED COMPONENT METHODS void addItem(object anobject)Adds an item to the item list, in the end of the combo box Object getItemAt(int index)Returns the item at the specified index. int getItemCount()Returns the number of items in the combo box int getSelected Index()Returns the index of the selected Item. object getSelected Item()Returns the selected item void insertItemAt(object Item, int index)Inserts an item at the specified index boolean isEditable()Indicates whether the combo box’s text field is editable or not void removeAllItems()Removes all items from the combo box void removeItem(object item)Removes the specified item void removeItemAt(int index)Removes the item at the specified index void setEditable(boolean value)Sets the combo box’s text field editable. void setMaximumRowCount(int count)Sets the number of rows displayed when the combo box list is dropped down void setSelectedIndex(int index)Selects the item at specified index void setSelectedItem(object item)Selects the specified item

JCombo Box Events The most commonly used event is Action event when the user selects item. To write action event handler you need to write code in combobox’s Action performed() method