Memory is organized in a hierarchy with different levels providing trade-offs between speed and cost.
- Cache memory sits between the CPU and main memory for fastest access.
- Main memory (RAM) is where active programs and data reside and is faster than auxiliary memory but more expensive.
- Auxiliary memory (disks, tapes) provides backup storage and is slower than main memory but larger and cheaper.
Virtual memory manages this hierarchy through address translation techniques like paging that map virtual addresses to physical locations, allowing programs to access more memory than physically available. When data is needed from auxiliary memory a page fault occurs and page replacement algorithms determine what data to remove from main memory.
Data communication involves the exchange of data between two or more parties through various means such as writing, talking, images, and electronic communication like emails and calls. An effective data communication model includes a source that generates data, a transmitter that converts it into signals, a transmission system that carries the data, a receiver that converts it back into data, and a destination that receives the incoming data. Computer networks allow for sharing of resources like files, printers, and applications between connected computers. Common network topologies include bus, star, ring and mesh configurations that determine how the connected computers are physically laid out and communicate with each other.
The document provides instructions for assembling a computer. It describes opening the computer case and installing components like the power supply, motherboard, drives, adapter cards and connecting internal cables. Key steps include installing the power supply, attaching components like the CPU and RAM to the motherboard, installing the motherboard in the case, installing internal drives and drives in external bays, connecting power and data cables between components, and booting the computer for the first time. The document provides detailed guidance on installing specific components like network interface cards, video cards and connecting various power and data cables.
Chat GPT is an advanced language model that has revolutionized the field of education. This cutting-edge technology is transforming the way students learn and interact with the world around them. With Chat GPT, students can now have access to personalized learning experiences, instant feedback, and a wealth of knowledge that was once unimaginable.
This SlideShare presentation will explore the various ways Chat GPT is changing the face of education. From intelligent tutoring systems to virtual assistants, this technology is creating a new era of learning that is more personalized, efficient, and engaging than ever before. We'll look at some real-world examples of how Chat GPT is being used in education today, and how it is transforming the classroom experience for both students and teachers.
The presentation will also delve into some of the potential benefits and challenges of using Chat GPT in education. We'll discuss how this technology can help bridge the learning gap for students with disabilities or learning difficulties, and how it can make education more accessible to students in remote or underserved areas.
Finally, the presentation will provide some practical tips and advice for educators who want to incorporate Chat GPT into their teaching practice. From choosing the right technology to developing effective lesson plans, we'll cover everything you need to know to get started with this game-changing tool.
Whether you're a teacher, a student, or simply interested in the future of education, this SlideShare presentation is for you. Join us as we explore the world of Chat GPT and discover how this technology is transforming education for the better.
Here are my responses to the questions about the ethics case study:
1. The action that is cause for concern is that Raj decided to lie and inflate his GPA and SAT scores on his resume in order to improve his chances of getting a summer internship at the Research Institute.
2. The Research Institute may be affected if they hire Raj based on false information. His potential coworkers and bosses may also be affected if he is not actually qualified for the role.
3. The Research Institute could end up hiring someone who is not actually qualified for the job based on inaccurate information. This could negatively impact workplace productivity and morale. Raj's coworkers may have to cover for him or his work may not meet standards.
The document defines various verb tenses and provides examples. It focuses on explaining the present tense, which has four types: present indefinite, present continuous, present perfect, and present perfect continuous. For each tense, it provides the structure, examples, and context in which that tense is used. The present indefinite tense expresses habitual or regular actions, widespread truths, and near future. The present continuous tense expresses ongoing actions. The present perfect tense expresses recently finished actions whose results are still evident. The present perfect continuous tense expresses actions that began in the past and are ongoing.
The document discusses wireless sensor networks and their applications. It describes wireless sensor networks as consisting of individual nodes that can interact with their environment by sensing or controlling physical parameters. It then discusses several applications of wireless sensor networks, including disaster relief, environment monitoring, intelligent buildings, facility management, machine maintenance, agriculture, healthcare, and logistics. Finally, it outlines some key requirements and mechanisms needed to implement wireless sensor networks, including communication, energy efficiency, self-configuration, collaboration, data-centric operation, and exploiting tradeoffs between different needs.
This document provides an overview of Java Swing components. It defines Swing as a GUI toolkit built on top of AWT that provides platform-independent and lightweight components. It describes common Swing components like JButton, JTextField, JTextArea and their usage. It also compares AWT and Swing, explaining how Swing components are more powerful and support pluggable look and feel while AWT is platform-dependent. Examples are given to demonstrate creating and using Swing components like JButton, JTextField, JTextArea etc.
The document discusses various event handling classes in Java including ActionEvent, KeyEvent, MouseEvent, MouseMotionEvent, FocusEvent, WindowEvent, and ItemEvent. It provides examples of how to use each event class by implementing the appropriate listener interface and defining event handling methods. Key points covered include common event handling terms like event, event source, and event listener. It also summarizes the typical methods provided by each event class.
This document discusses interfaces in Java. It defines an interface as a blueprint of a class that defines static constants and abstract methods. Interfaces are used to achieve abstraction and multiple inheritance in Java. They represent an "is-a" relationship. There are three main reasons to use interfaces - for abstraction, to support multiple inheritance functionality, and to achieve loose coupling. The document provides examples of interfaces, such as a Printable interface and implementations in different classes. It also demonstrates multiple inheritance using interfaces and interface inheritance.
The document discusses Java AWT (Abstract Window Toolkit). It describes that AWT is an API that allows developing GUI applications in Java. It provides classes like TextField, Label, TextArea etc. for building GUI components. The document then explains key AWT concepts like containers, windows, panels, events, event handling model, working with colors and fonts.
This document provides an overview of GUI programming in Java, including basic concepts, AWT vs Swing frameworks, common control components, layout managers, and event handling. It discusses the key differences between AWT and Swing, describes common control components in both frameworks, explains different types of layout managers like flow, border, and grid layouts, and lists additional references for further reading.
The document provides an overview of how to build a graphical user interface (GUI) in Java. It discusses the key classes used to create GUI components like JFrame, JPanel, and JButton. It explains how to set layout managers, add components, set frame size and visibility. It also includes sample code to create a simple calculator GUI with a border layout and grid layout. The document is an introduction to developing GUIs in Java using the Swing toolkit.
Threads allow multiple tasks to run concurrently within a single Java program. A thread represents a separate path of execution and threads can be used to improve performance. There are two main ways to create threads: by extending the Thread class or implementing the Runnable interface. Threads transition between different states like new, runnable, running, blocked, and terminated. Synchronization is needed to prevent race conditions when multiple threads access shared resources simultaneously. Deadlocks can occur when threads wait for each other in a circular manner.
An abstract class is a class that is declared abstract —it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed. When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class.
This document discusses inheritance in object-oriented programming. It defines inheritance as establishing a link between classes that allows sharing and accessing properties. There are three types of inheritance: single, multilevel, and hierarchical. Single inheritance involves one parent and one child class, multilevel inheritance adds intermediate classes, and hierarchical inheritance has one parent and multiple child classes. The document provides examples of inheritance code in Java and demonstrates a program using inheritance with interfaces. It notes some limitations of inheritance in Java.
This document provides information about applets including:
- Applets are small programs that can be embedded in web pages and run within web browsers. They allow for dynamic and interactive content.
- There are two types of applets: local applets stored on the local system and remote applets stored on remote servers.
- The lifecycle of a Java applet involves init(), start(), stop(), destroy(), and paint() methods being called in a specific order when the applet loads and runs in the browser.
The document provides an introduction to Java programming language. It discusses that Java was originally developed by James Gosling at Sun Microsystems in 1991 and was named Oak. It was later renamed to Java in 1995. The document also describes Java features such as it is a purely object-oriented language, platform independent, secure, robust, portable, and supports multithreading.
This document provides an overview of Java applets, including:
- Applets are small Java programs that can be transported over the network and embedded in HTML pages.
- The main types of Java programs are standalone programs and web-based programs like applets.
- Applets differ from applications in that they have a predefined lifecycle and are embedded in web pages rather than running independently.
- The Applet class is the superclass for all applets and defines methods corresponding to the applet lifecycle stages like init(), start(), paint(), stop(), and destroy().
- Common methods for applets include drawString() for output, setBackground()/getBackground() for colors, and showStatus() to display in
An interface in Java is a blueprint of a class that defines static constants and abstract methods. Interfaces are implemented by classes where they inherit the properties and must define the body of the abstract methods. Key points are:
- Interfaces can only contain abstract methods and static constants, not method bodies.
- Classes implement interfaces to inherit the properties and must define the abstract method bodies.
- An interface can extend other interfaces and a class can implement multiple interfaces.
The document discusses exception handling in Java. It defines exceptions as abnormal conditions that arise during runtime and disrupt normal program flow. There are three types of exceptions: checked exceptions which must be declared, unchecked exceptions which do not need to be declared, and errors which are rare and cannot be recovered from. The try, catch, and finally blocks are used to handle exceptions, with catch blocks handling specific exception types and finally blocks containing cleanup code.
Introduction to Java Programming Languagejaimefrozr
The document provides an introduction and history of the Java programming language. It discusses that Java was originally developed in 1991 by Sun Microsystems to be portable for consumer electronic devices. The document then summarizes the key capabilities of Java including being a general purpose language that can develop robust applications for desktops, servers, and mobile devices. It also outlines the Java language specifications, application programming interface containing predefined classes, and development tools available. Finally, it explains how Java's use of byte code and the Java Virtual Machine allows it to be highly portable across different operating systems.
The document discusses exception handling in Java. It defines exceptions as runtime errors that occur during program execution. It describes different types of exceptions like checked exceptions and unchecked exceptions. It explains how to use try, catch, throw, throws and finally keywords to handle exceptions. The try block contains code that might throw exceptions. The catch block catches and handles specific exceptions. The finally block contains cleanup code that always executes regardless of exceptions. The document provides examples of exception handling code in Java.
- Java AWT (Abstract Windowing Toolkit) is an API that provides components to build graphical user interfaces (GUIs) in Java. It includes classes like TextField, Label, TextArea, etc.
- AWT components are platform-dependent and heavyweight, using operating system resources. Common containers include Frame, Dialog, and Panel.
- This document provides details on various AWT components like Label, Button, Checkbox, List, and TextField. It also covers events, listeners, and methods of these components.
This document provides an overview of Java servlets technology, including:
1. What Java servlets are and their main purposes and advantages such as portability, power, and integration with server APIs.
2. Key aspects of servlet architecture like the servlet lifecycle, the HttpServletRequest and HttpServletResponse objects, and how different HTTP methods map to servlet methods.
3. Examples of simple servlets that process parameters, maintain a session counter, and examples of deploying servlets in Eclipse IDE.
This document provides an introduction to graphical user interfaces (GUIs) in Java. It discusses GUI components such as buttons, checkboxes, lists, sliders, and menus. It explains how to create simple GUIs using Swing components like JFrames, JLabels, and JButtons. Event handling is demonstrated through examples using interfaces like ItemListener. Different types of buttons are presented, including toggle buttons, radio buttons, and checkboxes. Common GUI elements like text fields, lists, sliders and menus are also introduced through examples. The document provides a high-level overview of creating and working with basic GUI components in Java.
This document discusses the evolution of graphical user interface (GUI) capabilities in the Java programming language. It describes the Abstract Window Toolkit (AWT) introduced in JDK 1.0, which provided basic cross-platform GUI functionality but had limitations. JDK 1.1 improved on AWT with an event delegation model. JDK 1.2 introduced Swing, a richer GUI library that better integrated with native operating system look and feels. Swing components are lightweight compared to heavyweight AWT components. The document also covers GUI component classes, layout managers, menus, labels and event handling in Java GUI programming.
This document provides an overview of Java Swing components. It defines Swing as a GUI toolkit built on top of AWT that provides platform-independent and lightweight components. It describes common Swing components like JButton, JTextField, JTextArea and their usage. It also compares AWT and Swing, explaining how Swing components are more powerful and support pluggable look and feel while AWT is platform-dependent. Examples are given to demonstrate creating and using Swing components like JButton, JTextField, JTextArea etc.
The document discusses various event handling classes in Java including ActionEvent, KeyEvent, MouseEvent, MouseMotionEvent, FocusEvent, WindowEvent, and ItemEvent. It provides examples of how to use each event class by implementing the appropriate listener interface and defining event handling methods. Key points covered include common event handling terms like event, event source, and event listener. It also summarizes the typical methods provided by each event class.
This document discusses interfaces in Java. It defines an interface as a blueprint of a class that defines static constants and abstract methods. Interfaces are used to achieve abstraction and multiple inheritance in Java. They represent an "is-a" relationship. There are three main reasons to use interfaces - for abstraction, to support multiple inheritance functionality, and to achieve loose coupling. The document provides examples of interfaces, such as a Printable interface and implementations in different classes. It also demonstrates multiple inheritance using interfaces and interface inheritance.
The document discusses Java AWT (Abstract Window Toolkit). It describes that AWT is an API that allows developing GUI applications in Java. It provides classes like TextField, Label, TextArea etc. for building GUI components. The document then explains key AWT concepts like containers, windows, panels, events, event handling model, working with colors and fonts.
This document provides an overview of GUI programming in Java, including basic concepts, AWT vs Swing frameworks, common control components, layout managers, and event handling. It discusses the key differences between AWT and Swing, describes common control components in both frameworks, explains different types of layout managers like flow, border, and grid layouts, and lists additional references for further reading.
The document provides an overview of how to build a graphical user interface (GUI) in Java. It discusses the key classes used to create GUI components like JFrame, JPanel, and JButton. It explains how to set layout managers, add components, set frame size and visibility. It also includes sample code to create a simple calculator GUI with a border layout and grid layout. The document is an introduction to developing GUIs in Java using the Swing toolkit.
Threads allow multiple tasks to run concurrently within a single Java program. A thread represents a separate path of execution and threads can be used to improve performance. There are two main ways to create threads: by extending the Thread class or implementing the Runnable interface. Threads transition between different states like new, runnable, running, blocked, and terminated. Synchronization is needed to prevent race conditions when multiple threads access shared resources simultaneously. Deadlocks can occur when threads wait for each other in a circular manner.
An abstract class is a class that is declared abstract —it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed. When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class.
This document discusses inheritance in object-oriented programming. It defines inheritance as establishing a link between classes that allows sharing and accessing properties. There are three types of inheritance: single, multilevel, and hierarchical. Single inheritance involves one parent and one child class, multilevel inheritance adds intermediate classes, and hierarchical inheritance has one parent and multiple child classes. The document provides examples of inheritance code in Java and demonstrates a program using inheritance with interfaces. It notes some limitations of inheritance in Java.
This document provides information about applets including:
- Applets are small programs that can be embedded in web pages and run within web browsers. They allow for dynamic and interactive content.
- There are two types of applets: local applets stored on the local system and remote applets stored on remote servers.
- The lifecycle of a Java applet involves init(), start(), stop(), destroy(), and paint() methods being called in a specific order when the applet loads and runs in the browser.
The document provides an introduction to Java programming language. It discusses that Java was originally developed by James Gosling at Sun Microsystems in 1991 and was named Oak. It was later renamed to Java in 1995. The document also describes Java features such as it is a purely object-oriented language, platform independent, secure, robust, portable, and supports multithreading.
This document provides an overview of Java applets, including:
- Applets are small Java programs that can be transported over the network and embedded in HTML pages.
- The main types of Java programs are standalone programs and web-based programs like applets.
- Applets differ from applications in that they have a predefined lifecycle and are embedded in web pages rather than running independently.
- The Applet class is the superclass for all applets and defines methods corresponding to the applet lifecycle stages like init(), start(), paint(), stop(), and destroy().
- Common methods for applets include drawString() for output, setBackground()/getBackground() for colors, and showStatus() to display in
An interface in Java is a blueprint of a class that defines static constants and abstract methods. Interfaces are implemented by classes where they inherit the properties and must define the body of the abstract methods. Key points are:
- Interfaces can only contain abstract methods and static constants, not method bodies.
- Classes implement interfaces to inherit the properties and must define the abstract method bodies.
- An interface can extend other interfaces and a class can implement multiple interfaces.
The document discusses exception handling in Java. It defines exceptions as abnormal conditions that arise during runtime and disrupt normal program flow. There are three types of exceptions: checked exceptions which must be declared, unchecked exceptions which do not need to be declared, and errors which are rare and cannot be recovered from. The try, catch, and finally blocks are used to handle exceptions, with catch blocks handling specific exception types and finally blocks containing cleanup code.
Introduction to Java Programming Languagejaimefrozr
The document provides an introduction and history of the Java programming language. It discusses that Java was originally developed in 1991 by Sun Microsystems to be portable for consumer electronic devices. The document then summarizes the key capabilities of Java including being a general purpose language that can develop robust applications for desktops, servers, and mobile devices. It also outlines the Java language specifications, application programming interface containing predefined classes, and development tools available. Finally, it explains how Java's use of byte code and the Java Virtual Machine allows it to be highly portable across different operating systems.
The document discusses exception handling in Java. It defines exceptions as runtime errors that occur during program execution. It describes different types of exceptions like checked exceptions and unchecked exceptions. It explains how to use try, catch, throw, throws and finally keywords to handle exceptions. The try block contains code that might throw exceptions. The catch block catches and handles specific exceptions. The finally block contains cleanup code that always executes regardless of exceptions. The document provides examples of exception handling code in Java.
- Java AWT (Abstract Windowing Toolkit) is an API that provides components to build graphical user interfaces (GUIs) in Java. It includes classes like TextField, Label, TextArea, etc.
- AWT components are platform-dependent and heavyweight, using operating system resources. Common containers include Frame, Dialog, and Panel.
- This document provides details on various AWT components like Label, Button, Checkbox, List, and TextField. It also covers events, listeners, and methods of these components.
This document provides an overview of Java servlets technology, including:
1. What Java servlets are and their main purposes and advantages such as portability, power, and integration with server APIs.
2. Key aspects of servlet architecture like the servlet lifecycle, the HttpServletRequest and HttpServletResponse objects, and how different HTTP methods map to servlet methods.
3. Examples of simple servlets that process parameters, maintain a session counter, and examples of deploying servlets in Eclipse IDE.
This document provides an introduction to graphical user interfaces (GUIs) in Java. It discusses GUI components such as buttons, checkboxes, lists, sliders, and menus. It explains how to create simple GUIs using Swing components like JFrames, JLabels, and JButtons. Event handling is demonstrated through examples using interfaces like ItemListener. Different types of buttons are presented, including toggle buttons, radio buttons, and checkboxes. Common GUI elements like text fields, lists, sliders and menus are also introduced through examples. The document provides a high-level overview of creating and working with basic GUI components in Java.
This document discusses the evolution of graphical user interface (GUI) capabilities in the Java programming language. It describes the Abstract Window Toolkit (AWT) introduced in JDK 1.0, which provided basic cross-platform GUI functionality but had limitations. JDK 1.1 improved on AWT with an event delegation model. JDK 1.2 introduced Swing, a richer GUI library that better integrated with native operating system look and feels. Swing components are lightweight compared to heavyweight AWT components. The document also covers GUI component classes, layout managers, menus, labels and event handling in Java GUI programming.
A Graphical User Interface (GUI) is a user interface based on graphics i.e. icons, pictures, menus, etc. instead of just plain text, it uses a mouse as well as a keyboard as an input device.
GUI applications enable the users (especially naive ones) to interact with a system easily and friendly. This presentation is meant for the individual who has little or no experience in Java GUI programming.
Swing and Graphical User Interface in Javababak danyal
The document provides information about the Swing graphical user interface library in Java. It describes that Swing is the official GUI toolkit for Java, released as part of Java Foundation Classes. It discusses the key components, layout managers like BorderLayout and GridLayout, and event handling in Swing using interfaces, anonymous inner classes, and adapter classes.
GUI Programming in JAVA (Using Netbeans) - A ReviewFernando Torres
The powerpoint provides the user with a review of various concepts of GUI programming in JAVA. It covers various concepts like :
1. What is IDE ?
2. Various Methods and Properties of Components
3. Variable declaration
4. Data types
Etc
Java GUI PART II is the continues of JAVA GUI PART I covering and discussing the GUI components as well as the different available Layout Managers which is available in JAVA and you can find dedicated example for each Layout Managers …
The document discusses GUI event handling in Java. It explains that window-based Java programs are event-driven, meaning they wait for and respond to user-initiated events like button clicks or key presses. When an event occurs, an event object is passed to a listener object that handles the event. Listeners implement interfaces that correspond to different event types, like ActionListener for button clicks. The delegation event model in Java handles event passing from components to listeners.
This document provides an overview of Java Swing through a series of slides. It introduces Swing as a GUI toolkit for Java that includes 14 packages and over 450 classes. It discusses how Swing components are lightweight and not thread-safe. The document covers key Swing concepts like layout managers, event handling with listeners, look and feels, common containers like JPanel and JSplitPane, controls like JButton and JTextField, and components like images, scroll bars, check boxes and radio buttons. Code examples are provided for many of the concepts discussed.
The document discusses Java Foundation Classes (JFC) which provide components for building graphical user interfaces in Java. JFC includes Swing components like buttons and menus, pluggable look and feel, accessibility APIs, and drag and drop support. Swing provides standard GUI components and containers to organize components in windows. Top-level containers like JFrame are needed to display components on screen and provide support for painting and events.
Java programming presentations By Daroko blog
Do not just read java as a programmer, find projects and start making some Money, at DAROKO BLOG,WE Guide you through what you have learned in the classroom to a real business Environment, find java applications to a real business Environment, find also all IT Solutions and How you can apply them, find the best companies where you can get the IT jobs worldwide, Find java contract, Complete and start making some cash, find clients within your Country, refer and get paid when you complete the work.
Not Just a contact, at daroko Blog(www.professionalbloggertricks.com/),you are also being taught How you can apply all IT related field in real world.
Simply Google, Daroko Blog or visit (www.professionalbloggertricks.com/) to Know More about all these service now.
Do not just learn and god, Apply them in real world
The document provides an overview of developing user interfaces using Java. It discusses learning GUI programming concepts like components, layouts, and event-based programming. It then covers introductory Java topics like why Java is used, Java materials, key differences from C++, compiling Java code, creating Java applications and applets, and upcoming GUI and Java topics to be covered.
Graphical User Interface (GUI) in Java uses classes from the javax.swing and java.awt packages to implement GUI programs. Swing classes provide greater compatibility across operating systems compared to AWT classes. Common Swing components include JButton, JLabel, JTextField, JTextArea, JCheckBox, JRadioButton, JComboBox, JList, JSlider and more. GUI programs require containers like JFrame and JPanel to hold components. Layout managers determine how components are arranged in containers. Common layouts include FlowLayout, BorderLayout and GridLayout. Menus are implemented using JMenuBar, JMenu and JMenuItem classes.
Graphical User Interface (GUI) is a visual way for users to interact with a computer program using graphical elements like windows, icons, menus, etc. rather than text-based commands. A GUI makes programs easier to use by presenting commands visually and allowing users to perform actions by clicking on screen elements rather than memorizing commands. Well-designed GUIs help users avoid complex text commands by providing intuitive graphical layouts and controls.
This document discusses user interface design. It covers interface design models, principles, characteristics, user guidance, usability testing and examples. Some key points covered include the iterative UI design process of user analysis, prototyping and evaluation. Design principles like consistency and providing feedback are discussed. Interface styles like menus, commands and direct manipulation are presented along with guidelines for elements like color use and error messages. The goals of usability testing like obtaining feedback to improve the interface are outlined.
This document provides an overview of Java Swing, which is a GUI widget toolkit for Java. It discusses the key features of Swing such as look and feel, data transfer, internationalization, and accessibility. It also describes the main Swing components including top-level containers, general purpose containers, special purpose containers, basic controls, and information displays. Additionally, it covers Java layout management, event handling in Swing, and concludes by recommending Java development tools.
This document discusses key concepts in Java programming including classes, methods, parameters, and invoking methods. It explains that a program consists of classes, a class contains methods, and a method contains statements. Methods can take parameters, which are initialized when the method is called and allow passing in values. Parameters act similarly to local variables but are declared in the method signature.
The document discusses several case studies of performance issues with Java EE applications and provides solutions. It emphasizes the importance of understanding the entire system, including infrastructure components, and using tools like monitoring, thread dumps, and logging to observe problems before hypothesizing and testing solutions. The first case study found a server with debug logging enabled slowing it down. The second was due to firewalls terminating idle database connections. The third involved inefficient AJAX and an underpowered load tester.
This document provides an overview of graphical user interfaces (GUIs) in Java. It defines GUIs as interfaces that allow users to interact with programs through graphical icons rather than text-based interfaces. It discusses key GUI components like frames, panels, buttons, labels and text fields. It also covers layout managers that determine how components are positioned, such as flow, border and grid layouts. Finally, it discusses event-driven programming and how listeners define actions in response to user interactions like mouse clicks or key presses.
This presentation discusses Java layout managers. It introduces the different types of layout managers provided by Java: FlowLayout, GridLayout, BorderLayout, and CardLayout. It explains how each layout manager positions and sizes components differently. For example, FlowLayout places components in rows from left to right, GridLayout places components in a rigid grid formation, and BorderLayout divides a container into regions and places components within those regions. The presentation also covers how to set a layout manager on a container and provides details on the constructors for each layout manager type.
Swing is the primary Java GUI widget toolkit. It is highly customizable and extensible, allowing users to override default implementations and extend the framework. Swing components are lightweight because they do not require allocating native operating system resources. Common Swing components include buttons, lists, menus, frames, and panels.
This document contains an outline and sections from a chapter about graphical user interface (GUI) components in Java. It introduces common Swing components like JLabel, JTextField, JButton, JCheckBox, JRadioButton and others. It describes how events are handled in Swings through listeners. It provides examples of creating and handling events from text fields, buttons, checkboxes. The examples demonstrate registering event handlers and handling events from different GUI components.
The document discusses various AWT classes and components for creating graphical user interfaces in Java, including buttons, borders, card layouts, checkboxes, text fields, menus, and handling events from mouse clicks and key presses. Code examples are provided to demonstrate drawing shapes and graphics, as well as handling user input events.
The document discusses Swing, the graphical user interface (GUI) toolkit for Java. It introduces Swing as a replacement for the original Abstract Window Toolkit (AWT) that improved on AWT's weaknesses. Key points covered include:
- Swing was introduced in 1997 as part of the Java Foundation Classes to address AWT's limitations. It uses lightweight components instead of relying on native platform components.
- Swing supports pluggable look-and-feel and is based on the model-view-controller architecture. It includes a variety of common GUI components like tables, trees, sliders.
- Layout managers like FlowLayout, GridLayout, BorderLayout, and BoxLayout are used to position and
The document discusses Swing components in Java, including how to create windows, add components to windows, handle events, and work with text components. Key topics covered include the component hierarchy for common Swing widgets like JFrame, JLabel, JButton, and JTextField. It also discusses how to register listeners, manipulate document content, and build a basic browser component.
The document provides an overview of core Java concepts including Abstract Windowing Toolkit (AWT), event handling, Swing, layout managers, and applets. It discusses AWT components like containers, windows, panels and frames. It also covers creating frames, setting buttons, and different approaches to event handling like within a class, with an outer class, or anonymously. The document reviews Swing components and hierarchies. It includes examples of creating Swing frames and using buttons, radio buttons, and displaying images on buttons.
This document provides information about graphical user interfaces (GUIs) in Java. It discusses the AWT class hierarchy including important classes like Component, Container, Frame, and Panel. It covers event handling using the delegation event model and describes common listener interfaces. It also summarizes common GUI components like labels, buttons, text fields, and menus. Layout managers and concepts of applets versus applications are briefly mentioned.
The document discusses Java GUI components from the Abstract Window Toolkit (AWT) and Swing toolkit. It defines AWT as a set of APIs used to create GUI objects like buttons and windows. It describes common AWT containers like Frame, Panel, Dialog and Applet. It then introduces Swing as an enhanced GUI toolkit and lists some common Swing components in packages like javax.swing. The document provides examples of creating and using common Swing components like JFrame, JLabel, JButton, JCheckBox.
The document discusses Java GUI components from the Abstract Window Toolkit (AWT) and Swing toolkit. It defines AWT as a set of APIs used to create GUI objects like buttons and windows. It describes common AWT containers like Frame, Panel, Dialog and Applet. It then introduces Swing as an enhanced GUI toolkit and lists some common Swing components in packages like javax.swing. The document provides examples of creating and using common Swing components like JFrame, JLabel, JButton, JCheckBox.
This document provides an introduction and overview of Griffon, an open source framework for building desktop applications in Java and Groovy. It discusses key Griffon concepts like the MVC architecture, views, models, controllers and plugins. It also demonstrates common Griffon commands and shows code examples for building a basic todo application with a Griffon including adding tables, binding forms and handling threading.
Basic of Abstract Window Toolkit(AWT) in Javasuraj pandey
The document discusses Java's Abstract Window Toolkit (AWT) which provides components for building graphical user interfaces in Java. It describes common AWT components like frames, panels, buttons, labels and text fields. It also covers how to add components to containers, set properties of components, handle events, and create simple AWT applications using both inheritance and object association approaches.
This document contains a program file for a Java desktop application project created in NetBeans. It includes details of the student and supervisor for the project. It also acknowledges those who helped with the project. The rest of the document contains 13 coding questions and answers demonstrating different Java GUI concepts like buttons, text fields, labels etc. Each question has the coding and result displayed. Concepts covered include concatenation, if statements, checkboxes, lists etc.
Gui programming a review - mixed contentYogesh Kumar
Class 12 IP Chapter 3 PPt, Mixed content ppt, GUI Programming - A review at a glance, (62 Slides, 5 MB), Homework_Ch3_PPT for school, Easy to understand, JAVA Basics PPt
This document provides an overview of Java Swing components for graphical user interfaces (GUIs). It introduces GUIs and discusses the advantages of Swing components over the older Abstract Window Toolkit (AWT) components. Key Swing components are explained, including JFrame for windows, JPanel for sections of a window, layout managers like FlowLayout and GridLayout, and common widgets like JLabel, JButton, JTextField, JTextArea, JComboBox, JCheckBox, JRadioButton, and JMenu. Event handling in Swing is also summarized.
This document discusses how to grow one's career with WordPress. It provides an overview of WordPress, including that it was founded in 2003 by Matt Mullenweg and Mike Little and currently powers 27% of the web. The document then suggests several career paths one can take with WordPress, such as being a blogger, support specialist, designer, developer, content writer, QA engineer, or internet marketer. It encourages the reader to choose one path, get good at it, and notes that one's thinking capacity is the limit.
Caching in WordPress provides three main ways to cache content:
1. Page caching stores entire page outputs to serve static content and avoid database queries on repeat visits.
2. Transients cache query and object results, like recent posts, and are stored in the database for retrieval until expiration.
3. Object caching stores content in memory for faster loading, but requires an external persistent data store like Memcached to remain available between page loads.
Operator overloading allows operators like + and << to be used with user-defined types like classes. It is done by defining corresponding operator functions like operator+() and operator<<(). This allows objects to be used with operators in a natural way while providing custom behavior for that type. The rules for overloading include maintaining precedence and associativity of operators. Common operators like +, -, *, /, <<, >>, ==, =, [] and () can be overloaded to allow user-defined types to work with them.
The document discusses arrays and pointers in C++. It covers:
- How to declare and initialize arrays
- Accessing array elements using subscripts
- Using parallel arrays when subscripts are not sequential numbers
- Special considerations for strings as arrays of characters
- Declaring pointer variables and using pointers to access array elements
- Potential issues with pointers like dangling references
This document provides an overview of C++ programming concepts including:
1. C++ programs consist of functions, with every program containing a main() function. Functions contain declarations, statements, comments, and can call libraries.
2. Variables must be declared with a type and can be used to store values. C++ supports integer, floating point, character, and other variable types.
3. C++ allows selection and decision making using if/else statements, switch statements, logical operators, and loops like while and for. Operators allow comparisons and boolean evaluations.
The document discusses various graph algorithms and representations including:
- Adjacency lists and matrices for representing graphs
- Breadth-first search (BFS) which explores edges from a source vertex s level-by-level
- Depth-first search (DFS) which explores "deeper" first, producing a depth-first forest
- Classifying edges as tree, back, forward, or cross based on vertex colors in DFS
- Topological sorting of directed acyclic graphs (DAGs)
- Strongly connected components (SCCs) in directed graphs and using the transpose
The heap data structure is a nearly complete binary tree implemented as an array. There are two types of heaps: max-heaps and min-heaps. The MAX-HEAPIFY algorithm maintains the heap property by allowing a value to "float down" the tree. BUILD-MAX-HEAP builds a max-heap by calling MAX-HEAPIFY on each node, and HEAPSORT sorts an array using the heap structure.
The document discusses divide and conquer algorithms and merge sort. It provides details on how merge sort works including: (1) Divide the input array into halves recursively until single element subarrays, (2) Sort the subarrays using merge sort recursively, (3) Merge the sorted subarrays back together. The overall running time of merge sort is analyzed to be θ(nlogn) as each level of recursion contributes θ(n) work and there are logn levels of recursion.
The document discusses lower bounds for sorting algorithms and the counting sort algorithm. It begins by explaining that sorting algorithms can only use comparisons between elements to determine their order. It then discusses decision trees that model the comparisons made by sorting algorithms and how the longest path in the tree represents the worst case number of comparisons. Finally, it provides pseudocode for counting sort and analyzes its running time as θ(k+n) where k is the range of input values and n is the number of elements.
The document discusses minimum spanning trees and Kruskal's algorithm. A minimum spanning tree is a subset of edges in a connected, undirected graph that connects all vertices with the minimum total weight. Kruskal's algorithm finds a minimum spanning tree by growing a forest of trees while ensuring each added edge connects two different trees without forming a cycle. It uses a disjoint-set data structure to keep track of the connected components in the forest as edges are added from lowest to highest weight.
The document discusses algorithms for solving single-source shortest path problems on weighted, directed graphs. It describes Dijkstra's algorithm, which finds the shortest paths from a single source node to all other nodes in a graph where all edge weights are non-negative. The algorithm works by repeatedly selecting the node with the smallest estimated shortest path distance, adding it to the set of visited nodes, and relaxing all outgoing edges to update neighboring nodes' distances.
The document discusses priority queues and quicksort. It defines a priority queue as a data structure that maintains a set of elements with associated keys. Heaps can be used to implement priority queues. There are two types: max-priority queues and min-priority queues. Priority queues have applications in job scheduling and event-driven simulation. Quicksort works by partitioning an array around a pivot element and recursively sorting the sub-arrays.
The document describes the quicksort algorithm. Quicksort works by:
1) Partitioning the array around a pivot element into two sub-arrays of less than or equal and greater than elements.
2) Recursively sorting the two sub-arrays.
3) Combining the now sorted sub-arrays.
In the average case, quicksort runs in O(n log n) time due to balanced partitions at each recursion level. However, in the worst case of an already sorted input, it runs in O(n^2) time due to highly unbalanced partitions. A randomized version of quicksort chooses pivots randomly to avoid worst case behavior.
Understanding P–N Junction Semiconductors: A Beginner’s GuideGS Virdi
Dive into the fundamentals of P–N junctions, the heart of every diode and semiconductor device. In this concise presentation, Dr. G.S. Virdi (Former Chief Scientist, CSIR-CEERI Pilani) covers:
What Is a P–N Junction? Learn how P-type and N-type materials join to create a diode.
Depletion Region & Biasing: See how forward and reverse bias shape the voltage–current behavior.
V–I Characteristics: Understand the curve that defines diode operation.
Real-World Uses: Discover common applications in rectifiers, signal clipping, and more.
Ideal for electronics students, hobbyists, and engineers seeking a clear, practical introduction to P–N junction semiconductors.
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetSritoma Majumder
Introduction
All the materials around us are made up of elements. These elements can be broadly divided into two major groups:
Metals
Non-Metals
Each group has its own unique physical and chemical properties. Let's understand them one by one.
Physical Properties
1. Appearance
Metals: Shiny (lustrous). Example: gold, silver, copper.
Non-metals: Dull appearance (except iodine, which is shiny).
2. Hardness
Metals: Generally hard. Example: iron.
Non-metals: Usually soft (except diamond, a form of carbon, which is very hard).
3. State
Metals: Mostly solids at room temperature (except mercury, which is a liquid).
Non-metals: Can be solids, liquids, or gases. Example: oxygen (gas), bromine (liquid), sulphur (solid).
4. Malleability
Metals: Can be hammered into thin sheets (malleable).
Non-metals: Not malleable. They break when hammered (brittle).
5. Ductility
Metals: Can be drawn into wires (ductile).
Non-metals: Not ductile.
6. Conductivity
Metals: Good conductors of heat and electricity.
Non-metals: Poor conductors (except graphite, which is a good conductor).
7. Sonorous Nature
Metals: Produce a ringing sound when struck.
Non-metals: Do not produce sound.
Chemical Properties
1. Reaction with Oxygen
Metals react with oxygen to form metal oxides.
These metal oxides are usually basic.
Non-metals react with oxygen to form non-metallic oxides.
These oxides are usually acidic.
2. Reaction with Water
Metals:
Some react vigorously (e.g., sodium).
Some react slowly (e.g., iron).
Some do not react at all (e.g., gold, silver).
Non-metals: Generally do not react with water.
3. Reaction with Acids
Metals react with acids to produce salt and hydrogen gas.
Non-metals: Do not react with acids.
4. Reaction with Bases
Some non-metals react with bases to form salts, but this is rare.
Metals generally do not react with bases directly (except amphoteric metals like aluminum and zinc).
Displacement Reaction
More reactive metals can displace less reactive metals from their salt solutions.
Uses of Metals
Iron: Making machines, tools, and buildings.
Aluminum: Used in aircraft, utensils.
Copper: Electrical wires.
Gold and Silver: Jewelry.
Zinc: Coating iron to prevent rusting (galvanization).
Uses of Non-Metals
Oxygen: Breathing.
Nitrogen: Fertilizers.
Chlorine: Water purification.
Carbon: Fuel (coal), steel-making (coke).
Iodine: Medicines.
Alloys
An alloy is a mixture of metals or a metal with a non-metal.
Alloys have improved properties like strength, resistance to rusting.
Geography Sem II Unit 1C Correlation of Geography with other school subjectsProfDrShaikhImran
The correlation of school subjects refers to the interconnectedness and mutual reinforcement between different academic disciplines. This concept highlights how knowledge and skills in one subject can support, enhance, or overlap with learning in another. Recognizing these correlations helps in creating a more holistic and meaningful educational experience.
The ever evoilving world of science /7th class science curiosity /samyans aca...Sandeep Swamy
The Ever-Evolving World of
Science
Welcome to Grade 7 Science4not just a textbook with facts, but an invitation to
question, experiment, and explore the beautiful world we live in. From tiny cells
inside a leaf to the movement of celestial bodies, from household materials to
underground water flows, this journey will challenge your thinking and expand
your knowledge.
Notice something special about this book? The page numbers follow the playful
flight of a butterfly and a soaring paper plane! Just as these objects take flight,
learning soars when curiosity leads the way. Simple observations, like paper
planes, have inspired scientific explorations throughout history.
*Metamorphosis* is a biological process where an animal undergoes a dramatic transformation from a juvenile or larval stage to a adult stage, often involving significant changes in form and structure. This process is commonly seen in insects, amphibians, and some other animals.
GDGLSPGCOER - Git and GitHub Workshop.pptxazeenhodekar
This presentation covers the fundamentals of Git and version control in a practical, beginner-friendly way. Learn key commands, the Git data model, commit workflows, and how to collaborate effectively using Git — all explained with visuals, examples, and relatable humor.
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessMark Soia
Boost your chances of passing the 2V0-11.25 exam with CertsExpert reliable exam dumps. Prepare effectively and ace the VMware certification on your first try
Quality dumps. Trusted results. — Visit CertsExpert Now: https://www.certsexpert.com/2V0-11.25-pdf-questions.html
A measles outbreak originating in West Texas has been linked to confirmed cases in New Mexico, with additional cases reported in Oklahoma and Kansas. The current case count is 795 from Texas, New Mexico, Oklahoma, and Kansas. 95 individuals have required hospitalization, and 3 deaths, 2 children in Texas and one adult in New Mexico. These fatalities mark the first measles-related deaths in the United States since 2015 and the first pediatric measles death since 2003.
The YSPH Virtual Medical Operations Center Briefs (VMOC) were created as a service-learning project by faculty and graduate students at the Yale School of Public Health in response to the 2010 Haiti Earthquake. Each year, the VMOC Briefs are produced by students enrolled in Environmental Health Science Course 581 - Public Health Emergencies: Disaster Planning and Response. These briefs compile diverse information sources – including status reports, maps, news articles, and web content– into a single, easily digestible document that can be widely shared and used interactively. Key features of this report include:
- Comprehensive Overview: Provides situation updates, maps, relevant news, and web resources.
- Accessibility: Designed for easy reading, wide distribution, and interactive use.
- Collaboration: The “unlocked" format enables other responders to share, copy, and adapt seamlessly. The students learn by doing, quickly discovering how and where to find critical information and presenting it in an easily understood manner.
A measles outbreak originating in West Texas has been linked to confirmed cases in New Mexico, with additional cases reported in Oklahoma and Kansas. The current case count is 771 from Texas, New Mexico, Oklahoma, and Kansas. 72 individuals have required hospitalization, and 3 deaths, 2 children in Texas and one adult in New Mexico. These fatalities mark the first measles-related deaths in the United States since 2015 and the first pediatric measles death since 2003.
The YSPH Virtual Medical Operations Center Briefs (VMOC) were created as a service-learning project by faculty and graduate students at the Yale School of Public Health in response to the 2010 Haiti Earthquake. Each year, the VMOC Briefs are produced by students enrolled in Environmental Health Science Course 581 - Public Health Emergencies: Disaster Planning and Response. These briefs compile diverse information sources – including status reports, maps, news articles, and web content– into a single, easily digestible document that can be widely shared and used interactively. Key features of this report include:
- Comprehensive Overview: Provides situation updates, maps, relevant news, and web resources.
- Accessibility: Designed for easy reading, wide distribution, and interactive use.
- Collaboration: The “unlocked" format enables other responders to share, copy, and adapt seamlessly.
The students learn by doing, quickly discovering how and where to find critical information and presenting it in an easily understood manner.
How to Subscribe Newsletter From Odoo 18 WebsiteCeline George
Newsletter is a powerful tool that effectively manage the email marketing . It allows us to send professional looking HTML formatted emails. Under the Mailing Lists in Email Marketing we can find all the Newsletter.
The *nervous system of insects* is a complex network of nerve cells (neurons) and supporting cells that process and transmit information. Here's an overview:
Structure
1. *Brain*: The insect brain is a complex structure that processes sensory information, controls behavior, and integrates information.
2. *Ventral nerve cord*: A chain of ganglia (nerve clusters) that runs along the insect's body, controlling movement and sensory processing.
3. *Peripheral nervous system*: Nerves that connect the central nervous system to sensory organs and muscles.
Functions
1. *Sensory processing*: Insects can detect and respond to various stimuli, such as light, sound, touch, taste, and smell.
2. *Motor control*: The nervous system controls movement, including walking, flying, and feeding.
3. *Behavioral responThe *nervous system of insects* is a complex network of nerve cells (neurons) and supporting cells that process and transmit information. Here's an overview:
Structure
1. *Brain*: The insect brain is a complex structure that processes sensory information, controls behavior, and integrates information.
2. *Ventral nerve cord*: A chain of ganglia (nerve clusters) that runs along the insect's body, controlling movement and sensory processing.
3. *Peripheral nervous system*: Nerves that connect the central nervous system to sensory organs and muscles.
Functions
1. *Sensory processing*: Insects can detect and respond to various stimuli, such as light, sound, touch, taste, and smell.
2. *Motor control*: The nervous system controls movement, including walking, flying, and feeding.
3. *Behavioral responses*: Insects can exhibit complex behaviors, such as mating, foraging, and social interactions.
Characteristics
1. *Decentralized*: Insect nervous systems have some autonomy in different body parts.
2. *Specialized*: Different parts of the nervous system are specialized for specific functions.
3. *Efficient*: Insect nervous systems are highly efficient, allowing for rapid processing and response to stimuli.
The insect nervous system is a remarkable example of evolutionary adaptation, enabling insects to thrive in diverse environments.
The insect nervous system is a remarkable example of evolutionary adaptation, enabling insects to thrive
Envenomation is the process by which venom is injected by the bite or sting of a venomous animal such as a snake, scorpion, spider, or insect. Arthropod bite is nothing but a sharp bite or sting by ants, fruit flies, bees, beetles, moths, or hornets. Though not a serious condition, arthropod bite can be extremely painful, with redness and mild to severe swelling around the site of the bite
Vitamins Chapter-7, Biochemistry and clinical pathology, D.Pharm 2nd yearARUN KUMAR
Definition and classification with examples
Sources, chemical nature, functions, coenzyme form, recommended dietary requirements, deficiency diseases of fat- and water-soluble vitamins
Multi-currency in odoo accounting and Update exchange rates automatically in ...Celine George
Most business transactions use the currencies of several countries for financial operations. For global transactions, multi-currency management is essential for enabling international trade.
3. Introduction Graphical User Interface (GUI) Gives program distinctive “look” and “feel” Provides users with basic level of familiarity Built from GUI components (controls, widgets, etc.) User interacts with GUI component via mouse, keyboard, etc.
4. GUI Programming Concepts in Java Java GUI ("Swing") has components Windows GUI has controls Unix GUI has widgets examples: labels, buttons, check boxes, radio buttons, text input boxes, pull down lists Java Swing components: JLabel, JButton, JCheckBox, JRadioButton, JTextField, JTextArea, JComboBox
5. Java GUI history: the AWT AWT(JDK 1.0, 1.1): Abstract Window Toolkit package: java.awt, java.awt.event heavyweight components using native GUI system elements used for applets until most browsers supported JRE 1.2
6. Swing in Java Swing(Java 2, JDK 1.2+) lightweight components that do not rely on the native GUI or OS “ look and feel” of Swing components are identical on different platforms can be customized Swing inherits from AWT AWT still used for events, layouts
7. Swing Components in Java advanced GUI support. e.g. drag-and-drop package names: javax.swing, javax.swing.event components inherit from JComponent components are added to a top-level container: JFrame, JDialog, or JApplet.
8. Lightweight vs. Heavyweight GUI Components Lightweight components Not tied directly to GUI components supported by underlying platform Heavyweight components Tied directly to the local platform AWT components Some Swing components
9. Basic GUI Programming Steps in Java declare a container and components add components to one or more containers using a layout manager register event listener(s) with the components create event listener method(s)
11. AWT Events Component Event Generated Generate When Button ActionEvent Clicked Selected or deselected Moved, resized, hidden or shown Checkbox CheckboxMenuItem Gained or loses fccus Pressed or released ComponentEvent Component Double Clicked ItemEvent Container ContainerEvent Added or removed ItemEvent ItemEvent Selected or deselected Selected or deselected Choice FocusEvent KeyEvent List ActionEvent ItemEvent Selected or deselected Selected ActionEvent MenuItem Moved AdjustmentEvent Scrollbar Changed TextEvent TextComponent Completed editing TextEvent TextField Opened, closed, iconified, deiconified, etc. WindowEvent Window
12. Events Delegation Model User Action Source Object Triggering an event Target/Listener Object Event Object Registering for an event Creating an event Notify Event Listener Handle event Event Handler
14. Swing Overview Swing GUI components Package javax.swing Components originate from AWT (package java.awt ) Contain look and feel Appearance and how users interact with program Lightweight components Written completely in Java
15. 12.2 Swing Overview (cont.) Class Component Contains method paint for drawing Component onscreen Class Container Collection of related components Contains method add for adding components Class JComponent Pluggable look and feel for customizing look and feel Shortcut keys ( mnemonics ) Common event-handling capabilities
16. Fig. 12.3 Common superclasses of many of the Swing components.
17. 12.3 JLabel Label Provide text on GUI Defined with class JLabel Can display: Single line of read-only text Image Text and image
18. 1 // Fig. 12.4: LabelTest.java 2 // Demonstrating the JLabel class. 3 4 // Java core packages 5 import java.awt.*; 6 import java.awt.event.*; 7 8 // Java extension packages 9 import javax.swing.*; 10 11 public class LabelTest extends JFrame { 12 private JLabel label1, label2, label3; 13 14 // set up GUI 15 public LabelTest() 16 { 17 super ( "Testing JLabel" ); 18 19 // get content pane and set its layout 20 Container container = getContentPane(); 21 container.setLayout( new FlowLayout() ); 22 23 // JLabel constructor with a string argument 24 label1 = new JLabel( "Label with text" ); 25 label1.setToolTipText( "This is label1" ); 26 container.add( label1 ); 27 28 // JLabel constructor with string, Icon and 29 // alignment arguments 30 Icon bug = new ImageIcon( "bug1.gif" ); 31 label2 = new JLabel( "Label with text and icon" , 32 bug, SwingConstants. LEFT ); 33 label2.setToolTipText( "This is label2" ); 34 container.add( label2 ); 35 LabelTest.java Line 12 Line 24 Line 25 Lines 31-32 Declare three JLabel s Create first JLabel with text “ Label with text ” Create second JLabel with text to left of image Tool tip is text that appears when user moves cursor over JLabel
19. 36 // JLabel constructor no arguments 37 label3 = new JLabel(); 38 label3.setText( "Label with icon and text at bottom" ); 39 label3.setIcon( bug ); 40 label3.setHorizontalTextPosition( SwingConstants. CENTER ); 41 label3.setVerticalTextPosition( SwingConstants. BOTTOM ); 42 label3.setToolTipText( "This is label3" ); 43 container.add( label3 ); 44 45 setSize( 275 , 170 ); 46 setVisible( true ); 47 } 48 49 // execute application 50 public static void main( String args[] ) 51 { 52 LabelTest application = new LabelTest(); 53 54 application.setDefaultCloseOperation( 55 JFrame. EXIT_ON_CLOSE ); 56 } 57 58 } // end class LabelTest LabelTest.java Lines 37-41 Create third JLabel with text below image
20. 12.4 Event-Handling Model GUIs are event driven Generate events when user interacts with GUI e.g., moving mouse, pressing button, typing in text field, etc. Class java.awt.AWTEvent
21. Fig. 12.5 Some event classes of package java.awt.event
22. 12.4 Event-Handling Model (cont.) Event-handling model Three parts Event source GUI component with which user interacts Event object Encapsulates information about event that occurred Event listener Receives event object when notified, then responds Programmer must perform two tasks Register event listener for event source Implement event-handling method (event handler)
23. Fig. 12.6 Event-listener interfaces of package java.awt.event
24. 12.5 JTextField and JPasswordField JTextField Single-line area in which user can enter text JPasswordField Extends JTextField Hides characters that user enters
25. 1 // Fig. 12.7: TextFieldTest.java 2 // Demonstrating the JTextField class. 3 4 // Java core packages 5 import java.awt.*; 6 import java.awt.event.*; 7 8 // Java extension packages 9 import javax.swing.*; 10 11 public class TextFieldTest extends JFrame { 12 private JTextField textField1, textField2, textField3; 13 private JPasswordField passwordField; 14 15 // set up GUI 16 public TextFieldTest() 17 { 18 super ( "Testing JTextField and JPasswordField" ); 19 20 Container container = getContentPane(); 21 container.setLayout( new FlowLayout() ); 22 23 // construct textfield with default sizing 24 textField1 = new JTextField( 10 ); 25 container.add( textField1 ); 26 27 // construct textfield with default text 28 textField2 = new JTextField( "Enter text here" ); 29 container.add( textField2 ); 30 31 // construct textfield with default text and 32 // 20 visible elements and no event handler 33 textField3 = new JTextField( "Uneditable text field" , 20 ); 34 textField3.setEditable( false ); 35 container.add( textField3 ); TextFieldTest.java Lines 12-13 Line 24 Line 28 Lines 33-34 Declare three JTextField s and one JPasswordField First JTextField contains empty string Second JTextField contains text “ Enter text here ” Third JTextField contains uneditable text
26. 36 37 // construct textfield with default text 38 passwordField = new JPasswordField( "Hidden text" ); 39 container.add( passwordField ); 40 41 // register event handlers 42 TextFieldHandler handler = new TextFieldHandler(); 43 textField1.addActionListener( handler ); 44 textField2.addActionListener( handler ); 45 textField3.addActionListener( handler ); 46 passwordField.addActionListener( handler ); 47 48 setSize( 325 , 100 ); 49 setVisible( true ); 50 } 51 52 // execute application 53 public static void main( String args[] ) 54 { 55 TextFieldTest application = new TextFieldTest(); 56 57 application.setDefaultCloseOperation( 58 JFrame. EXIT_ON_CLOSE ); 59 } 60 61 // private inner class for event handling 62 private class TextFieldHandler implements ActionListener { 63 64 // process text field events 65 public void actionPerformed( ActionEvent event ) 66 { 67 String string = "" ; 68 69 // user pressed Enter in JTextField textField1 70 if ( event.getSource() == textField1 ) TextFieldTest.java Line 38 Lines 43-46 Line 62 Line 65 JPasswordField contains text “ Hidden text ,” but text appears as series of asterisks ( * ) Every TextFieldHandler instance is an ActionListener Register GUI components with TextFieldHandler (register for ActionEvent s) Method actionPerformed invoked when user presses Enter in GUI field
27. 71 string = "textField1: " + event.getActionCommand(); 72 73 // user pressed Enter in JTextField textField2 74 else if ( event.getSource() == textField2 ) 75 string = "textField2: " + event.getActionCommand(); 76 77 // user pressed Enter in JTextField textField3 78 else if ( event.getSource() == textField3 ) 79 string = "textField3: " + event.getActionCommand(); 80 81 // user pressed Enter in JTextField passwordField 82 else if ( event.getSource() == passwordField ) { 83 JPasswordField pwd = 84 ( JPasswordField ) event.getSource(); 85 string = "passwordField: " + 86 new String( passwordField.getPassword() ); 87 } 88 89 JOptionPane.showMessageDialog( null , string ); 90 } 91 92 } // end private inner class TextFieldHandler 93 94 } // end class TextFieldTest TextFieldTest.java
29. 12.5.1 How Event Handling Works Two open questions from Section 12.4 How did event handler get registered? Answer: Through component’s method addActionListener Lines 43-46 of TextFieldTest.java How does component know to call actionPerformed ? Answer: Event is dispatched only to listeners of appropriate type Each event type has corresponding event-listener interface Event ID specifies event type that occurred
30. Fig 12.8 Event registration for JTextField textField1 .
31. 12.6 JButton Button Component user clicks to trigger a specific action Several different types Command buttons Check boxes Toggle buttons Radio buttons javax.swing.AbstractButton subclasses Command buttons are created with class JButton Generate ActionEvent s when user clicks button