This document discusses the basics of GUI programming in Java using the AWT API. It explains that AWT provides classes for building graphical user interfaces and that there are three types of GUI classes: container classes, component classes, and helper classes. Container classes hold other components, component classes make up the visual elements, and helper classes provide properties like colors and fonts. Important container classes include Frame and Panel, while common components are buttons, labels, text fields, and checkboxes. The document provides details on constructing and using many of these classes.
This document discusses Java applets and provides examples. It defines an applet as a Java program that can be run in a web browser. Applets must extend the Applet class and override certain methods like init(), start(), stop(), and destroy() that are called at different stages of the applet lifecycle. There are two main types of applets - ones based on the AWT and ones based on Swing. The document also discusses graphics drawing in applets using the Graphics class and setting colors and fonts. It provides examples of a scrolling banner applet and using the status window.
Packages in Java provide a namespace that organizes related classes and interfaces. A package declaration specifies the package that a class belongs to. Packages prevent naming collisions and allow access modifiers like public, protected and private to control visibility. Common packages in Java include java.lang for core language classes, java.util for collections, and java.io for file input/output. The import statement is used to use classes from another package.
This document provides an overview of Java Beans. It defines Java Beans as reusable software components that extend the power of Java by enabling objects to be manipulated visually at design time. The key points covered include: Java Beans specifications which define requirements like having public no-arg constructors and implementing Serializable; getter and setter methods for accessing bean properties; event models for handling bean events; and steps for creating a basic Java Bean component and packaging it in a JAR file.
The document discusses inheritance in Java programming. It defines inheritance as an is-a relationship between a superclass and subclasses, where subclasses inherit and extend the functionality of the superclass. The document covers key inheritance concepts like method overriding, where subclasses can define their own implementation of a method from the superclass, and method overloading, where classes can define multiple methods with the same name but different parameters. It also discusses dynamic method dispatch, where Java determines which version of an overridden method to call based on the object type at runtime.
This document discusses methods, constructors, and interfaces in Java programming. It defines methods as constructs that group statements together to perform a function. Methods can return values or be void. Constructors are special methods used to initialize objects, and must have the same name as the class. Interfaces contain abstract method signatures that classes implement, allowing for multiple inheritance. The document provides examples of defining methods, constructors, abstract classes, and implementing interfaces in Java code.
This document discusses Remote Method Invocation (RMI) in Java. RMI allows a method to be invoked on an object residing in a different Java Virtual Machine (JVM). It works through stubs and skeletons - stubs act as proxies for remote objects on the client side, while skeletons handle incoming calls on the server side. Developing RMI applications involves creating a remote interface, implementing it in a remote class that extends UnicastRemoteObject, compiling the class to generate stubs and skeletons, starting the RMI registry, and having the client access remote objects by lookup or direct construction.
This document provides an introduction to GUI programming using Swing in Java. It discusses the key differences between AWT and Swing, including that Swing components are lightweight and platform independent. The document covers Swing concepts like the model-view-controller architecture, event dispatch thread, common Swing components like JPanel and JScrollPane, and layout managers. It also discusses setting colors, fonts, and default operations in a JFrame. The goal of the document is to introduce developers to essential Swing concepts for GUI programming in Java.
This document discusses Java applets and provides examples. It defines an applet as a Java program that can be run in a web browser. Applets must extend the Applet class and override certain methods like init(), start(), stop(), and destroy() that are called at different stages of the applet lifecycle. There are two main types of applets - ones based on the AWT and ones based on Swing. The document also discusses graphics drawing in applets using the Graphics class and setting colors and fonts. It provides examples of a scrolling banner applet and using the status window.
Packages in Java provide a namespace that organizes related classes and interfaces. A package declaration specifies the package that a class belongs to. Packages prevent naming collisions and allow access modifiers like public, protected and private to control visibility. Common packages in Java include java.lang for core language classes, java.util for collections, and java.io for file input/output. The import statement is used to use classes from another package.
This document provides an overview of Java Beans. It defines Java Beans as reusable software components that extend the power of Java by enabling objects to be manipulated visually at design time. The key points covered include: Java Beans specifications which define requirements like having public no-arg constructors and implementing Serializable; getter and setter methods for accessing bean properties; event models for handling bean events; and steps for creating a basic Java Bean component and packaging it in a JAR file.
The document discusses inheritance in Java programming. It defines inheritance as an is-a relationship between a superclass and subclasses, where subclasses inherit and extend the functionality of the superclass. The document covers key inheritance concepts like method overriding, where subclasses can define their own implementation of a method from the superclass, and method overloading, where classes can define multiple methods with the same name but different parameters. It also discusses dynamic method dispatch, where Java determines which version of an overridden method to call based on the object type at runtime.
This document discusses methods, constructors, and interfaces in Java programming. It defines methods as constructs that group statements together to perform a function. Methods can return values or be void. Constructors are special methods used to initialize objects, and must have the same name as the class. Interfaces contain abstract method signatures that classes implement, allowing for multiple inheritance. The document provides examples of defining methods, constructors, abstract classes, and implementing interfaces in Java code.
This document discusses Remote Method Invocation (RMI) in Java. RMI allows a method to be invoked on an object residing in a different Java Virtual Machine (JVM). It works through stubs and skeletons - stubs act as proxies for remote objects on the client side, while skeletons handle incoming calls on the server side. Developing RMI applications involves creating a remote interface, implementing it in a remote class that extends UnicastRemoteObject, compiling the class to generate stubs and skeletons, starting the RMI registry, and having the client access remote objects by lookup or direct construction.
This document provides an introduction to GUI programming using Swing in Java. It discusses the key differences between AWT and Swing, including that Swing components are lightweight and platform independent. The document covers Swing concepts like the model-view-controller architecture, event dispatch thread, common Swing components like JPanel and JScrollPane, and layout managers. It also discusses setting colors, fonts, and default operations in a JFrame. The goal of the document is to introduce developers to essential Swing concepts for GUI programming in Java.
This document discusses exception handling in Java. It defines exceptions as events that disrupt normal program flow at runtime. There are different types of exceptions like checked exceptions that must be caught or declared, and unchecked exceptions for common errors. Exception handling uses keywords like try, catch, throw and finally. The try block contains code that might throw exceptions. Catch blocks define how to handle specific exceptions. Finally blocks contain cleanup code. Custom exceptions can be created by extending the Exception class.
This document discusses object-oriented programming concepts in Java such as classes, objects, inheritance, encapsulation, and polymorphism. It provides examples of defining classes with variables, methods, and constructors. It also covers creating and initializing objects, accessing instance variables and methods, and the different ways to create objects like using the new keyword, factory methods, and anonymous objects. The document also discusses strings, arrays, and core Java class libraries.
The document discusses object-oriented programming concepts like classes, objects, inheritance, encapsulation, and composition. It provides examples of how these concepts can be implemented in Java. It explains that a class defines common attributes and behaviors of objects, while an object is an instance of a class. Inheritance allows classes to extend and override methods of parent classes. Encapsulation involves making attributes private and accessing them via getter/setter methods. Composition refers to objects having other objects as members.
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 key concepts of object-oriented programming including objects, classes, inheritance, polymorphism, encapsulation, and abstraction. It provides examples of constructors, method overloading and overriding, interfaces, and packages in Java.
The document discusses the final keyword in Java and provides examples of using final with variables, methods, and classes. It then summarizes abstract classes and interfaces in Java, including how to declare abstract classes and methods and how interfaces are used to achieve abstraction and multiple inheritance. The document also covers packages, access modifiers, encapsulation, and arrays in Java.
Classes, objects, methods, constructors, this keyword in javaTharuniDiddekunta
Â
The document discusses classes, objects, methods, constructors and the this keyword in Java. It defines that a class is a blueprint for objects and contains variables and methods, while an object is an instance of a class with state and behavior. It provides examples of creating a class with data members and methods, and then creating objects of that class. The document also covers access modifiers, different types of constructors like default, parameterized and overloaded constructors. It explains the differences between methods and constructors.
oops concept in java | object oriented programming in javaCPD INDIA
Â
The document discusses key concepts in object-oriented programming in Java including classes, objects, inheritance, packages, interfaces, encapsulation, abstraction, and polymorphism. It provides examples to illustrate each concept. Classes define the structure and behavior of objects. Objects are instances of classes. Inheritance allows classes to extend existing classes. Packages organize related classes. Interfaces define behaviors without implementation. Encapsulation hides implementation details. Abstraction models essential features without specifics. Polymorphism allows the same method name with different signatures or overriding.
Interface in java ,multiple inheritance in java, interface implementationHoneyChintal
Â
multiple inheritance in java, interface implementation, abstraction,
multiple inheritance in java using interface, how to use interface,
how to use java, how to execute a java code
StringBuffer implements a mutable sequence of characters that can be modified unlike strings. It has methods to modify the character sequence such as append, insert, delete and replace. It can grow dynamically as characters are added and its methods are used by the compiler to implement string concatenation with the + operator.
Classes allow users to define their own data types that can be used like built-in types. A class defines both data members that represent the internal representation and member functions that define operations on class objects. Classes support information hiding by declaring data members as private and operations as public. An object is an instance of a class that allocates memory for the class's data members. Member functions can access class data members and are declared either inside or outside the class definition.
Interfaces allow classes to represent polymorphic types across inheritance trees without multiple inheritance. A class implements an interface using the implements keyword and must define all interface methods but interfaces contain no code, only public static final attributes. Common uses of interfaces include code reuse through polymorphism and marker interfaces as flags for the JVM.
Constructors and destructors in Python.
Constructors are special methods that are called automatically when an object is created. They initialize variables and ensure objects are properly initialized. There are two types of constructors: default and parameterized. Default don't take arguments, parameterized do.
Destructors are called when an object is destroyed. Defined using __del__(), they are useful for releasing resources like closing files before a program exits.
The document then provides code examples of classes with constructors, parameterized constructors, and destructors. It also discusses Python's garbage collection and how the collector deletes unneeded objects to free memory space.
This document provides an overview of object-oriented programming concepts in Java. It discusses the differences between procedural and object-oriented programming, with OOP comprising objects that communicate with each other. The main OOP concepts covered are objects, classes, inheritance, and encapsulation. Objects have an identity, attributes, and services. Inheritance allows subclasses to inherit and extend superclass attributes and behaviors. Encapsulation separates an object's internal state from its external interface. The document also discusses other Java topics like interfaces, collections framework, exceptions, and final keywords.
Python Programming - VI. Classes and ObjectsRanel Padon
Â
This document discusses classes and objects in Python programming. It covers key concepts like class attributes, instantiating classes to create objects, using constructors and destructors, composition where objects have other objects as attributes, and referencing objects. The document uses examples like a Time class to demonstrate class syntax and how to define attributes and behaviors for classes.
This presentation is ideal for a beginner of Java or someone who wants to brush up their Java Knowledge. It's simple to understand and well organized in a way most of the area in core Java has been covered.
The document discusses Java I/O streams and input/output. It introduces streams as an ordered sequence of data linked to a physical device. Streams can represent different sources and destinations like files, devices, networks. Input streams read data from a source while output streams write data to a destination. Byte streams handle bytes and character streams handle characters. Important stream classes include InputStream, OutputStream, Reader, and Writer. The System class defines predefined input, output, and error streams. Reading input involves wrapping System.in in a BufferedReader while writing uses PrintStream.
The document provides an overview of multi-threading in Java. It discusses key concepts like processes vs threads, the thread life cycle, and how to create threads using the Runnable interface and Thread class. It also covers thread synchronization and inter-thread communication. The document is presented by Ravi Kant Sahu, an assistant professor at Lovely Professional University in Punjab, India.
This document discusses exception handling in Java. It defines exceptions as events that disrupt normal program flow at runtime. There are different types of exceptions like checked exceptions that must be caught or declared, and unchecked exceptions for common errors. Exception handling uses keywords like try, catch, throw and finally. The try block contains code that might throw exceptions. Catch blocks define how to handle specific exceptions. Finally blocks contain cleanup code. Custom exceptions can be created by extending the Exception class.
This document discusses object-oriented programming concepts in Java such as classes, objects, inheritance, encapsulation, and polymorphism. It provides examples of defining classes with variables, methods, and constructors. It also covers creating and initializing objects, accessing instance variables and methods, and the different ways to create objects like using the new keyword, factory methods, and anonymous objects. The document also discusses strings, arrays, and core Java class libraries.
The document discusses object-oriented programming concepts like classes, objects, inheritance, encapsulation, and composition. It provides examples of how these concepts can be implemented in Java. It explains that a class defines common attributes and behaviors of objects, while an object is an instance of a class. Inheritance allows classes to extend and override methods of parent classes. Encapsulation involves making attributes private and accessing them via getter/setter methods. Composition refers to objects having other objects as members.
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 key concepts of object-oriented programming including objects, classes, inheritance, polymorphism, encapsulation, and abstraction. It provides examples of constructors, method overloading and overriding, interfaces, and packages in Java.
The document discusses the final keyword in Java and provides examples of using final with variables, methods, and classes. It then summarizes abstract classes and interfaces in Java, including how to declare abstract classes and methods and how interfaces are used to achieve abstraction and multiple inheritance. The document also covers packages, access modifiers, encapsulation, and arrays in Java.
Classes, objects, methods, constructors, this keyword in javaTharuniDiddekunta
Â
The document discusses classes, objects, methods, constructors and the this keyword in Java. It defines that a class is a blueprint for objects and contains variables and methods, while an object is an instance of a class with state and behavior. It provides examples of creating a class with data members and methods, and then creating objects of that class. The document also covers access modifiers, different types of constructors like default, parameterized and overloaded constructors. It explains the differences between methods and constructors.
oops concept in java | object oriented programming in javaCPD INDIA
Â
The document discusses key concepts in object-oriented programming in Java including classes, objects, inheritance, packages, interfaces, encapsulation, abstraction, and polymorphism. It provides examples to illustrate each concept. Classes define the structure and behavior of objects. Objects are instances of classes. Inheritance allows classes to extend existing classes. Packages organize related classes. Interfaces define behaviors without implementation. Encapsulation hides implementation details. Abstraction models essential features without specifics. Polymorphism allows the same method name with different signatures or overriding.
Interface in java ,multiple inheritance in java, interface implementationHoneyChintal
Â
multiple inheritance in java, interface implementation, abstraction,
multiple inheritance in java using interface, how to use interface,
how to use java, how to execute a java code
StringBuffer implements a mutable sequence of characters that can be modified unlike strings. It has methods to modify the character sequence such as append, insert, delete and replace. It can grow dynamically as characters are added and its methods are used by the compiler to implement string concatenation with the + operator.
Classes allow users to define their own data types that can be used like built-in types. A class defines both data members that represent the internal representation and member functions that define operations on class objects. Classes support information hiding by declaring data members as private and operations as public. An object is an instance of a class that allocates memory for the class's data members. Member functions can access class data members and are declared either inside or outside the class definition.
Interfaces allow classes to represent polymorphic types across inheritance trees without multiple inheritance. A class implements an interface using the implements keyword and must define all interface methods but interfaces contain no code, only public static final attributes. Common uses of interfaces include code reuse through polymorphism and marker interfaces as flags for the JVM.
Constructors and destructors in Python.
Constructors are special methods that are called automatically when an object is created. They initialize variables and ensure objects are properly initialized. There are two types of constructors: default and parameterized. Default don't take arguments, parameterized do.
Destructors are called when an object is destroyed. Defined using __del__(), they are useful for releasing resources like closing files before a program exits.
The document then provides code examples of classes with constructors, parameterized constructors, and destructors. It also discusses Python's garbage collection and how the collector deletes unneeded objects to free memory space.
This document provides an overview of object-oriented programming concepts in Java. It discusses the differences between procedural and object-oriented programming, with OOP comprising objects that communicate with each other. The main OOP concepts covered are objects, classes, inheritance, and encapsulation. Objects have an identity, attributes, and services. Inheritance allows subclasses to inherit and extend superclass attributes and behaviors. Encapsulation separates an object's internal state from its external interface. The document also discusses other Java topics like interfaces, collections framework, exceptions, and final keywords.
Python Programming - VI. Classes and ObjectsRanel Padon
Â
This document discusses classes and objects in Python programming. It covers key concepts like class attributes, instantiating classes to create objects, using constructors and destructors, composition where objects have other objects as attributes, and referencing objects. The document uses examples like a Time class to demonstrate class syntax and how to define attributes and behaviors for classes.
This presentation is ideal for a beginner of Java or someone who wants to brush up their Java Knowledge. It's simple to understand and well organized in a way most of the area in core Java has been covered.
The document discusses Java I/O streams and input/output. It introduces streams as an ordered sequence of data linked to a physical device. Streams can represent different sources and destinations like files, devices, networks. Input streams read data from a source while output streams write data to a destination. Byte streams handle bytes and character streams handle characters. Important stream classes include InputStream, OutputStream, Reader, and Writer. The System class defines predefined input, output, and error streams. Reading input involves wrapping System.in in a BufferedReader while writing uses PrintStream.
The document provides an overview of multi-threading in Java. It discusses key concepts like processes vs threads, the thread life cycle, and how to create threads using the Runnable interface and Thread class. It also covers thread synchronization and inter-thread communication. The document is presented by Ravi Kant Sahu, an assistant professor at Lovely Professional University in Punjab, India.
- 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 discusses event handling in Java. It describes the delegation event model where a source generates an event and sends it to one or more listeners. It outlines several common listener interfaces like ActionListener, ItemListener, KeyListener, MouseListener, and WindowListener. For each interface it provides the listener methods and describes how to write an event handler class to implement the interface. It also discusses the classes for different event types like ActionEvent, ItemEvent, KeyEvent, and MouseEvent.
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.
This document provides an introduction and overview of the Java programming language. It discusses that Java was developed by Sun Microsystems in the 1990s as a general-purpose, object-oriented language designed for easy web and internet applications. The key principles of object-oriented programming like encapsulation, inheritance, and polymorphism are explained. Characteristics of Java like being simple, secure, portable, and having good performance are highlighted. A brief history of Java's development is also presented.
The document discusses building graphical user interfaces (GUIs) in Java. It covers using the Abstract Window Toolkit (AWT) or Swing for GUI components, laying out components, adding event listeners, and drawing graphics. Key topics include choosing between AWT and Swing, using layout managers, implementing listeners for user interactions, and methods for drawing shapes.
The document contains 10 multiple choice questions about Gujarat's culture, handicrafts, and history. It asks about Sardar Vallabhbhai Patel being known as the "Iron Man of India", Kavi Kant being a famous Gujarati poet, glass paintings being made on the back of glass, baskets being made from cane and bamboo, jute being used for clay wall hangings, pottery being one of Gujarat's oldest handicrafts, the wind instrument Turi, Sanskrit classical theatre, Jamnagar's brass industry being one of the largest in India, and Ranchhodbhai Udayaram being called the father of Gujarati theatre.
This document provides an overview of generics in Java. It discusses the benefits of generics, including type safety and compile-time error detection. It also covers generic classes and interfaces, generic methods, wildcard types, and restrictions on generics. Examples are provided to illustrate key concepts like generic classes with multiple type parameters, bounded types, and the implementation of generics using type erasure.
This document provides an overview of Java collections and common collection interfaces like List, Set, Map, Queue, and their implementations. It discusses the core collection interfaces like Collection, List, Set, Map, Queue, and their methods. Specific implementations of these interfaces are covered like ArrayList, LinkedList, HashSet, TreeSet, HashMap, TreeMap, PriorityQueue. The document is presented by Ravi Kant Sahu, Assistant Professor at Lovely Professional University in Punjab, India and provides details on using collections in Java.
The document discusses various Java collection classes - ArrayList, LinkedList, Vector, and Stack. It provides details about their constructors, methods, and differences. The key points are:
- ArrayList and LinkedList store elements in arrays and linked lists respectively, affecting their performance for insertion/deletion.
- Vector is similar to ArrayList but contains synchronized methods for thread-safety.
- Stack extends Vector and defines methods for LIFO (Last In First Out) operations like push, pop.
This document discusses creating graphical user interfaces (GUIs) in Java using Swing. It introduces JFrame for creating windows, layout managers for positioning components, and common Swing components like JButton and JLabel. It also covers event handling using the delegation model with interfaces like ActionListener, creating menus, dialogs using JOptionPane and JFileChooser, and separating GUI code from business logic by implementing listeners.
The document discusses GUI programming concepts in Java. It covers the basics of event-driven programming using Swing components like JLabel, JButton etc. It explains how to create a simple GUI application using a JFrame container, adding components, registering event listeners and writing event handler methods. The key aspects are creating Swing components, adding them to containers using layout managers, registering listeners and writing code to handle events like button clicks.
This document discusses advanced Java programming topics related to networking. It covers network basics like TCP, UDP, IP addresses and ports. It then discusses client-server architecture and how sockets are used for communication. It explains how to create server and client sockets and handle multiple clients. It also discusses how to send and receive objects and provides an overview of the Java Mail API for sending emails.
With Unicode you can program and accomplish many funny, cool and useful programs and tools as for instance, Abjad Calculator, Bubble Text Generator to write letters in circle, Flip Text Generator to write letters upside down, Google Transliteration to convert English names to Persian/Arabic, etc...
The document outlines concepts related to graphical user interfaces (GUIs) and Windows Forms. It discusses key GUI components like windows, forms, controls and events. It covers how controls like labels, textboxes and buttons work. It also describes layout controls like group boxes and panels. Finally, it examines state buttons like checkboxes and radio buttons and how to handle events from these interface elements.
This document provides an overview of GUI programming basics using the AWT API in Java. It discusses the key component, container and layout manager classes used to create graphical user interfaces in Java. Component classes like Button, Label and TextField are used to add interactive elements, while container classes like Frame and Panel hold other components. Layout managers help position and organize components visually. The document also provides examples of creating simple frames and applications using these AWT classes.
This document provides an overview of Applets and Java GUI programming. It discusses Applets, their life cycle, how to run Applets using AppletViewer and HTML, and classes used in Applet programming like Applet, Graphics, Color, Font, and AWT components. It also covers Swing components like JApplet, JComponent, JLabel, JTextField, JButton, and JRadioButton. Code examples and demonstrations are provided for many of the concepts discussed.
The document discusses Java Abstract Window Toolkit (AWT) which provides components to build graphical user interfaces. It describes that AWT components are platform dependent and heavy weight since they are built on top of native OS components. It then discusses the AWT component hierarchy including common components like buttons, text fields and containers like frames and panels that hold components. Specific AWT container types and common methods for working with AWT components are also summarized.
Java AWT (Abstract Windowing Toolkit) is an API for developing GUI applications in Java. It contains components like buttons, text fields, labels etc. that are platform-dependent and heavyweight. The AWT hierarchy includes containers like Frame and Panel that can hold other components. Common methods like add(), setSize() and setLayout() are used to manage components. Event handling in AWT involves implementing listener interfaces, registering components with listeners, and placing event code in the same class, a separate class, or anonymously.
Defaultification Refactoring: A Tool for Automatically Converting Java Method...Raffi Khatchadourian
Â
This document describes a tool that automatically converts Java methods to default methods in interfaces. The tool is implemented as an Eclipse plugin and uses type constraints to identify methods that can be converted from skeletal implementation classes to default methods in corresponding interfaces according to Java 8 features. An evaluation found the tool successfully converted around 20% of candidate methods and was shown to produce compilable and semantically equivalent results through various testing techniques. Future work could include performing additional refactorings simultaneously during the conversion process.
This chapter introduces the Abstract Window Toolkit (AWT) in Java. It discusses creating windows and frames using AWT classes. It covers working with graphics, colors, fonts, and layout managers. It also discusses using AWT controls like buttons, checkboxes, lists, menus and dialog boxes. The chapter describes handling events by extending AWT components and exploring controls, menus and layout managers in more detail.
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.
This document provides an overview of Java basics, including:
- Java is an object-oriented programming language and platform that allows code to run on many systems.
- Java code is compiled to bytecode that runs on a Java Virtual Machine (JVM).
- Key Java technologies include the JVM, Java Runtime Environment (JRE), and Java Software Development Kit (SDK).
- Java supports object-oriented programming concepts like classes, objects, inheritance, interfaces, and polymorphism.
- The document outlines language syntax rules and concepts like variables, methods, and access modifiers.
An applet is a Java program that runs within a web browser. It is embedded in an HTML page using tags and runs on the client-side. Applets allow websites to be more dynamic and interactive. All applets extend the Applet class and run within a browser or applet viewer rather than as standalone programs. The code is downloaded from a web server when the page loads and output is handled using AWT methods rather than System.out. For security, applets have restricted access to client files and networks.
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.
The document provides an overview of the Abstract Window Toolkit (AWT) classes in Java. It discusses that AWT classes are available in the java.awt package and support creating applet windows and standalone GUI applications. It then lists and describes many important AWT classes, including those for buttons, checkboxes, menus, text fields, labels and more.
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.
BCA Department of Software Development and Information Technology shares the detail of Eclipse GUI Pallete and its configuration.
JIMS Vasant Kunj-II is the best BCA College in Delhi NCR. It provides the best BCA Course Curriculum and Top Placements.
The Faculties of the BCA department teach all languages in the latest tools, demand in the IT Companies and used by all Software Developers.
Eclise is one of the most demanding tools and we teach to BCA IV and V semester students. The curriculum includes Java, Advance Java, and web technologies.
Students kindly go through these details.
BCA Admissions are open, interested students can visit our website www.jimssouthdelhi.com
The iterator pattern allows for sequential access to elements in a collection without exposing its underlying implementation. It defines an interface for accessing and traversing elements with methods like hasNext() and next(). Concrete classes implement the iterator interface and container interface which returns the iterator. The demo class uses a name repository container to get an iterator and print out each name.
Java provides two frameworks for building GUI applications: AWT and Swing. AWT (Abstract Window Toolkit) is the older framework and provides platform-dependent components. Swing is more advanced and its components are platform-independent. Both frameworks use containers like frames and panels to hold other components like buttons, text fields, and labels. Applets are Java programs that run in web browsers and extend the Applet class. They have a lifecycle of init(), start(), paint(), stop(), and destroy() methods. Graphics methods like drawString() are used to display graphics in applets. AWT and Swing components can both be used within applets.
A beginner's guide to annotation processing.
In this talk that I gave at Droidcon Tel Aviv in 2016, I walk you through the process of building a custom annotation processor which mimics some of the behavior you may be familiar with from the popular Android library: Butter Knife.
Write code that writes code! A beginner's guide to Annotation Processing - Ja...DroidConTLV
Â
This document provides a summary of creating a custom annotation processor called "Soup Ladle" that allows for view binding in Android with the @Bind annotation. It discusses defining the @Bind annotation, extending the AbstractProcessor class to process the annotation, scanning code for @Bind fields and their parent classes, and generating SoupLadle.java files with binding methods for each parent class. The goal is to allow easy one-line view binding like SoupLadle.bind(this) for learning purposes and as a simpler alternative to libraries like ButterKnife.
Java Swing is an extension of AWT that provides a more robust and platform-independent set of widgets for building GUIs in Java. It is written entirely in Java and provides improved functionality over AWT, including new components, expanded component features, drag and drop support, and better event handling. Swing components are rendered the same on all platforms, unlike AWT which is platform-dependent.
Java Applet Basics, Important points, Life cycle of an applet, AWT, AWT HIERARCHY, Creating Frame by extending Frame class, Creating Frame by creating instance of Frame class, Java Exceptions, Java try and catch, Syntax, Example for try and catch,
The document discusses Java packages and interfaces. It provides details about:
- What packages are and how they are used to prevent naming conflicts and organize classes.
- How to define a user-defined package with an example.
- What interfaces are and how they allow for multiple inheritance by implementing multiple interfaces.
- Examples of defining and implementing interfaces.
Common Programming Errors by Beginners in JavaRavi_Kant_Sahu
Â
This document discusses 10 common errors that beginners encounter when programming in Java.
1) The "javac is not recognized" error occurs when the Java environment variables are not set correctly.
2) When compiling, the file name must have a ".java" extension.
3) When executing, only the class name should be passed without the ".java" extension, and the class must contain a main method.
4) The "file not found" error occurs when the file is not in the current working directory or the file name is incorrect.
This document discusses event handling in Java. It describes the delegation event model where a source generates an event and sends it to one or more listeners. It outlines several common listener interfaces like ActionListener, ItemListener, KeyListener, MouseListener, and WindowListener. For each interface it provides the listener methods and describes how to write an event handler class to implement the interface. It also discusses the classes for different event types like ActionEvent, ItemEvent, KeyEvent, and MouseEvent.
StringBuffer implements a mutable sequence of characters that can be modified unlike strings. It has methods to modify the character sequence such as append, insert, delete and replace. It can grow dynamically as characters are added and its methods are used by the compiler to implement string concatenation with the + operator.
This document discusses string handling in Java. It explains that strings are immutable objects of type String. It describes the four main string classes in Java - String, StringBuffer, StringBuilder, and StringTokenizer. The document outlines various string methods like length(), charAt(), compareTo(), indexOf(), and replace() among others. It also discusses how to create, modify, search and compare strings in Java.
Packages in Java provide a namespace that organizes related classes and interfaces. A package declaration specifies the package that a class belongs to. Packages prevent naming collisions and allow access modifiers like public, protected and private to control visibility. Common packages in Java include java.lang for core language features and java.util for collections. The import statement is used to use classes from another package.
The document discusses arrays in Java. Some key points:
- Arrays allow storing multiple values of the same type together and accessing using an index.
- One-dimensional arrays store elements in a list. Two-dimensional arrays represent tables/matrices.
- Arrays are initialized with a size, then individual elements can be assigned and accessed using indexes.
- Methods demonstrate declaring, initializing, and manipulating values in one and two-dimensional arrays. Arrays can also be passed as arguments or returned from methods.
This document discusses keywords in Java including this, super, and final. It explains that this refers to the current object instance and is used to call methods or access fields of the current class. Super is used to call methods or access fields of the parent class. Final is used to declare variables that cannot be reassigned, prevent method overriding, and prevent class inheritance. The document also covers static keywords and how static methods can be called on a class without creating an instance.
This document discusses Java wrapper classes. It explains that wrapper classes allow primitive types to be used as objects. Each primitive type has a corresponding wrapper class (e.g. Integer for int). Wrapper classes provide methods to convert between primitive types and their object equivalents. They allow primitives to be used in contexts that require objects, like collections, and provide additional functionality like constants and parsing/formatting methods.
This document discusses keywords in Java including this, super, and final. It explains that this refers to the current object instance and is used to call methods or access fields of the current class. Super is used to call methods or access fields of the parent class. Final is used to declare variables that cannot be reassigned, prevent method overriding, and prevent class inheritance. The document also covers static keywords and how static methods can be called on a class without creating an instance.
The document outlines Java Database Connectivity (JDBC) and its key concepts. JDBC provides a standard interface for connecting Java applications to various databases. It defines APIs for establishing a connection to a database, issuing queries and updates, and processing result sets. The document discusses the JDBC architecture, driver types, and interfaces like Connection, Statement, PreparedStatement, CallableStatement, and ResultSet.
The document discusses objects and classes in Java. It defines a class as a template for creating objects with common properties and behaviors. A class contains fields to store data and methods to perform actions on that data. The document uses the Circle class as an example, defining fields like radius and center coordinates, and methods like circumference() and area(). It explains how to define classes, create objects from classes using the new keyword, access object fields and methods, and use nested classes, inner classes, local classes and anonymous classes in Java.
This document summarizes a lecture on operators and expressions in Java. It discusses the four main categories of operators: arithmetic, bitwise, relational, and logical. It provides examples of common operators like addition, subtraction, logical AND, OR, and describes operator precedence. Key concepts covered include arithmetic assignment operators, increment/decrement operators, bitwise operators, relational operators for comparison, short-circuit logical operators, and the ternary conditional operator.
The document discusses control structures in Java, including selection statements like if-else and switch statements, and iteration statements like for, while, do-while loops. It provides examples and explanations of how each statement works. Key points covered include how if-else statements evaluate conditions and execute the appropriate block, how switch statements can be used as a replacement for long if-else-if chains, and how the different loop constructs like for, while, do-while iterate until a condition is met. It also discusses concepts like break, continue and return which change the flow of control.
This document provides an introduction and overview of the Java programming language presented by Ravi Kant Sahu. It defines Java as an object-oriented language based on C++ that is designed for easy web and internet applications. The key characteristics of Java discussed include being simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high-performance, multithreaded, and dynamic. The principles of object-oriented programming such as encapsulation, inheritance, and polymorphism are also explained.
This document provides an overview of Java basics including keywords, data types, variables, and constants. It discusses object-oriented programming concepts like objects, classes, encapsulation, inheritance, and polymorphism. It also describes the primitive data types in Java like integer, floating-point, character, and boolean types. Finally, it covers identifiers, keywords, constants, and variables in Java.
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slackshyamraj55
Â
Discover the seamless integration of RPA (Robotic Process Automation), COMPOSER, and APM with AWS IDP enhanced with Slack notifications. Explore how these technologies converge to streamline workflows, optimize performance, and ensure secure access, all while leveraging the power of AWS IDP and real-time communication via Slack notifications.
Main news related to the CCS TSI 2023 (2023/1695)Jakub Marek
Â
An English 🇬🇧 translation of a presentation to the speech I gave about the main changes brought by CCS TSI 2023 at the biggest Czech conference on Communications and signalling systems on Railways, which was held in Clarion Hotel Olomouc from 7th to 9th November 2023 (konferenceszt.cz). Attended by around 500 participants and 200 on-line followers.
The original Czech 🇨🇿 version of the presentation can be found here: https://www.slideshare.net/slideshow/hlavni-novinky-souvisejici-s-ccs-tsi-2023-2023-1695/269688092 .
The videorecording (in Czech) from the presentation is available here: https://youtu.be/WzjJWm4IyPk?si=SImb06tuXGb30BEH .
Driving Business Innovation: Latest Generative AI Advancements & Success StorySafe Software
Â
Are you ready to revolutionize how you handle data? Join us for a webinar where we’ll bring you up to speed with the latest advancements in Generative AI technology and discover how leveraging FME with tools from giants like Google Gemini, Amazon, and Microsoft OpenAI can supercharge your workflow efficiency.
During the hour, we’ll take you through:
Guest Speaker Segment with Hannah Barrington: Dive into the world of dynamic real estate marketing with Hannah, the Marketing Manager at Workspace Group. Hear firsthand how their team generates engaging descriptions for thousands of office units by integrating diverse data sources—from PDF floorplans to web pages—using FME transformers, like OpenAIVisionConnector and AnthropicVisionConnector. This use case will show you how GenAI can streamline content creation for marketing across the board.
Ollama Use Case: Learn how Scenario Specialist Dmitri Bagh has utilized Ollama within FME to input data, create custom models, and enhance security protocols. This segment will include demos to illustrate the full capabilities of FME in AI-driven processes.
Custom AI Models: Discover how to leverage FME to build personalized AI models using your data. Whether it’s populating a model with local data for added security or integrating public AI tools, find out how FME facilitates a versatile and secure approach to AI.
We’ll wrap up with a live Q&A session where you can engage with our experts on your specific use cases, and learn more about optimizing your data workflows with AI.
This webinar is ideal for professionals seeking to harness the power of AI within their data management systems while ensuring high levels of customization and security. Whether you're a novice or an expert, gain actionable insights and strategies to elevate your data processes. Join us to see how FME and AI can revolutionize how you work with data!
A Comprehensive Guide to DeFi Development Services in 2024Intelisync
Â
DeFi represents a paradigm shift in the financial industry. Instead of relying on traditional, centralized institutions like banks, DeFi leverages blockchain technology to create a decentralized network of financial services. This means that financial transactions can occur directly between parties, without intermediaries, using smart contracts on platforms like Ethereum.
In 2024, we are witnessing an explosion of new DeFi projects and protocols, each pushing the boundaries of what’s possible in finance.
In summary, DeFi in 2024 is not just a trend; it’s a revolution that democratizes finance, enhances security and transparency, and fosters continuous innovation. As we proceed through this presentation, we'll explore the various components and services of DeFi in detail, shedding light on how they are transforming the financial landscape.
At Intelisync, we specialize in providing comprehensive DeFi development services tailored to meet the unique needs of our clients. From smart contract development to dApp creation and security audits, we ensure that your DeFi project is built with innovation, security, and scalability in mind. Trust Intelisync to guide you through the intricate landscape of decentralized finance and unlock the full potential of blockchain technology.
Ready to take your DeFi project to the next level? Partner with Intelisync for expert DeFi development services today!
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc
Â
How does your privacy program stack up against your peers? What challenges are privacy teams tackling and prioritizing in 2024?
In the fifth annual Global Privacy Benchmarks Survey, we asked over 1,800 global privacy professionals and business executives to share their perspectives on the current state of privacy inside and outside of their organizations. This year’s report focused on emerging areas of importance for privacy and compliance professionals, including considerations and implications of Artificial Intelligence (AI) technologies, building brand trust, and different approaches for achieving higher privacy competence scores.
See how organizational priorities and strategic approaches to data security and privacy are evolving around the globe.
This webinar will review:
- The top 10 privacy insights from the fifth annual Global Privacy Benchmarks Survey
- The top challenges for privacy leaders, practitioners, and organizations in 2024
- Key themes to consider in developing and maintaining your privacy program
HCL Notes and Domino License Cost Reduction in the World of DLAUpanagenda
Â
Webinar Recording: https://www.panagenda.com/webinars/hcl-notes-and-domino-license-cost-reduction-in-the-world-of-dlau/
The introduction of DLAU and the CCB & CCX licensing model caused quite a stir in the HCL community. As a Notes and Domino customer, you may have faced challenges with unexpected user counts and license costs. You probably have questions on how this new licensing approach works and how to benefit from it. Most importantly, you likely have budget constraints and want to save money where possible. Don’t worry, we can help with all of this!
We’ll show you how to fix common misconfigurations that cause higher-than-expected user counts, and how to identify accounts which you can deactivate to save money. There are also frequent patterns that can cause unnecessary cost, like using a person document instead of a mail-in for shared mailboxes. We’ll provide examples and solutions for those as well. And naturally we’ll explain the new licensing model.
Join HCL Ambassador Marc Thomas in this webinar with a special guest appearance from Franz Walder. It will give you the tools and know-how to stay on top of what is going on with Domino licensing. You will be able lower your cost through an optimized configuration and keep it low going forward.
These topics will be covered
- Reducing license cost by finding and fixing misconfigurations and superfluous accounts
- How do CCB and CCX licenses really work?
- Understanding the DLAU tool and how to best utilize it
- Tips for common problem areas, like team mailboxes, functional/test users, etc
- Practical examples and best practices to implement right away
5th LF Energy Power Grid Model Meet-up SlidesDanBrown980551
Â
5th Power Grid Model Meet-up
It is with great pleasure that we extend to you an invitation to the 5th Power Grid Model Meet-up, scheduled for 6th June 2024. This event will adopt a hybrid format, allowing participants to join us either through an online Mircosoft Teams session or in person at TU/e located at Den Dolech 2, Eindhoven, Netherlands. The meet-up will be hosted by Eindhoven University of Technology (TU/e), a research university specializing in engineering science & technology.
Power Grid Model
The global energy transition is placing new and unprecedented demands on Distribution System Operators (DSOs). Alongside upgrades to grid capacity, processes such as digitization, capacity optimization, and congestion management are becoming vital for delivering reliable services.
Power Grid Model is an open source project from Linux Foundation Energy and provides a calculation engine that is increasingly essential for DSOs. It offers a standards-based foundation enabling real-time power systems analysis, simulations of electrical power grids, and sophisticated what-if analysis. In addition, it enables in-depth studies and analysis of the electrical power grid’s behavior and performance. This comprehensive model incorporates essential factors such as power generation capacity, electrical losses, voltage levels, power flows, and system stability.
Power Grid Model is currently being applied in a wide variety of use cases, including grid planning, expansion, reliability, and congestion studies. It can also help in analyzing the impact of renewable energy integration, assessing the effects of disturbances or faults, and developing strategies for grid control and optimization.
What to expect
For the upcoming meetup we are organizing, we have an exciting lineup of activities planned:
-Insightful presentations covering two practical applications of the Power Grid Model.
-An update on the latest advancements in Power Grid -Model technology during the first and second quarters of 2024.
-An interactive brainstorming session to discuss and propose new feature requests.
-An opportunity to connect with fellow Power Grid Model enthusiasts and users.
Taking AI to the Next Level in Manufacturing.pdfssuserfac0301
Â
Read Taking AI to the Next Level in Manufacturing to gain insights on AI adoption in the manufacturing industry, such as:
1. How quickly AI is being implemented in manufacturing.
2. Which barriers stand in the way of AI adoption.
3. How data quality and governance form the backbone of AI.
4. Organizational processes and structures that may inhibit effective AI adoption.
6. Ideas and approaches to help build your organization's AI strategy.
Skybuffer SAM4U tool for SAP license adoptionTatiana Kojar
Â
Manage and optimize your license adoption and consumption with SAM4U, an SAP free customer software asset management tool.
SAM4U, an SAP complimentary software asset management tool for customers, delivers a detailed and well-structured overview of license inventory and usage with a user-friendly interface. We offer a hosted, cost-effective, and performance-optimized SAM4U setup in the Skybuffer Cloud environment. You retain ownership of the system and data, while we manage the ABAP 7.58 infrastructure, ensuring fixed Total Cost of Ownership (TCO) and exceptional services through the SAP Fiori interface.
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Jeffrey Haguewood
Â
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on integration of Salesforce with Bonterra Impact Management.
Interested in deploying an integration with Salesforce for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
In the realm of cybersecurity, offensive security practices act as a critical shield. By simulating real-world attacks in a controlled environment, these techniques expose vulnerabilities before malicious actors can exploit them. This proactive approach allows manufacturers to identify and fix weaknesses, significantly enhancing system security.
This presentation delves into the development of a system designed to mimic Galileo's Open Service signal using software-defined radio (SDR) technology. We'll begin with a foundational overview of both Global Navigation Satellite Systems (GNSS) and the intricacies of digital signal processing.
The presentation culminates in a live demonstration. We'll showcase the manipulation of Galileo's Open Service pilot signal, simulating an attack on various software and hardware systems. This practical demonstration serves to highlight the potential consequences of unaddressed vulnerabilities, emphasizing the importance of offensive security practices in safeguarding critical infrastructure.
Generating privacy-protected synthetic data using Secludy and MilvusZilliz
Â
During this demo, the founders of Secludy will demonstrate how their system utilizes Milvus to store and manipulate embeddings for generating privacy-protected synthetic data. Their approach not only maintains the confidentiality of the original data but also enhances the utility and scalability of LLMs under privacy constraints. Attendees, including machine learning engineers, data scientists, and data managers, will witness first-hand how Secludy's integration with Milvus empowers organizations to harness the power of LLMs securely and efficiently.
Generating privacy-protected synthetic data using Secludy and Milvus
Â
Gui programming (awt)
1. Programming in JAVA
Topic: GUI Basics (AWT)
By
Ravi Kant Sahu
Asst. Professor
Lovely Professional University, Punjab
2. Introduction
• AWT is a java API that is used to develop GUI applications in Java.
• API is a collection of classes and interfaces that provide the basic
infrastructure or core functionalities for developing specific type of
application.
•
1)
2)
3)
There are three types of GUI classes:
Container classes
Component classes
Helper classes
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
3. Component Classes
• An instance of Component can be displayed on the screen.
• Component is the root class of all the user-interface classes including
container classes, and JComponent is the root class of all the
lightweight Swing components.
• Button, Label, TextField etc.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
4. Container Classes
• An instance of Container can hold instances of Component.
• Container classes are GUI components that are used to contain other
GUI components.
• Window, Panel, Applet, Frame, and Dialog are the container classes
for AWT components.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
5. Helper Classes
• The helper classes, such as Graphics, Color, Font, FontMetrics,
Dimension, and LayoutManager, are not subclasses of Component.
•
They are used to describe the properties of GUI components, such as
graphics context, colors, fonts, and dimension etc.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
6. AWT classes
Class
Description
AWTEvent
Encapsulates AWT events
Button
Creates a push button control
Canvas
A blank, semantics-free window
Checkbox
Creates a check box control
CheckboxGroup
Creates a group of check box controls
Color
Manages colors in a portable, platform-independent fashion
Font
Encapsulates a type font
Frame
Graphics
Creates a standard window that has a title bar, resize corners,
and a menu bar
Encapsulates the graphics context. This context is used by the
various output methods to display output in a window.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
7. AWT classes
Class
Description
TextField
Creates a single-line edit control
TextArea
Creates a multiline edit control
Window
Creates a window with no frame, no menu bar, and no title
Scrollbar
Creates a scroll bar control
MenuItem
Creates a menu item
Menu
Creates a pull-down menu
MenuBar
Creates a menu bar
MenuShortcut
ScrollPane
Encapsulates a keyboard shortcut for a menu item
A container that provides horizontal and/or vertical scroll bars
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
for another component
8. Component Class Hierarchy of AWT
Component
Container
(Non-Container)
Window
Frame
Button
Label
Panel
Applet
Text Field
Check-Box
Text Area etc.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
9. • Component is an abstract class that describes the basic
functionality supported by all AWT components.
• Container is an abstract sub-class of Component that adds the
functionality of containership to a component.
• A Container component can contain another container or noncontainer components.
• Window and Panel are two non-abstract sub-classes of
Container.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
10. Component Cont…
• Panel represents a rectangular region that does not have a
border and title bar.
• Window is a Panel with border and title bar.
• Window can independently exist whereas panel can’t.
• Frame is a sub-class of Window .
• Button, Label, TextField, CheckBox etc. are non-container
components.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
11. Component
• Component is an abstract class that encapsulates all of the
attributes of a visual component.
• All user interface elements that are displayed on the screen and
that interact with the user are subclasses of Component.
• It defines over a hundred public methods that are responsible for
managing events, such as mouse and keyboard input, positioning
and sizing the window, and repainting.
• A Component object is responsible for remembering the current
foreground and background colors and the currently selected text
font.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
12. Container
• Container class is a subclass of Component.
• It has additional methods that allow other Component objects to be
nested within it.
• Other Container objects can be stored inside of a Container (since
they are themselves instances of Component).
• This makes for a multileveled containment system.
• A container is responsible for laying out (that is, positioning) any
components that it contains. It does this through the use of various
layout managers.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
13. Panel
• Panel is a window that does not contain a title bar, menu bar, or
border.
• The screen output of an applet is drawn on the surface of a Panel
object. but it is not visible when applet is run inside a browser.
• When we run an applet using an applet viewer, the applet viewer
provides the title and border.
• Other components can be added to a Panel object by its add( )
method (inherited from Container).
• We can position and resize the components of a panel manually
using the setLocation( ), setSize( ), setPreferredSize( ), or
setBounds( ) methods defined by Component.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
14. Window
• Window class creates a top-level window.
• A top-level window is not contained within any other object; it
sits directly on the desktop.
• Generally, we won’t create Window objects directly. Instead, we
use a subclass of Window called Frame.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
15. Frame
• It is a subclass of Window and has a title bar, menu bar, borders,
and resizing corners.
• Frame encapsulates what is commonly thought of as a
“window.”
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
16. Frame
Constructor:
public Frame ()
public Frame (String Title)
Methods:
public String getTitle ()
public void setTitle (String Title)
public void setVisibile(boolean Visibility)
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
17. Commonly Used Methods of Component Class
• setBackground(): used to change the background color of a
component.
public void setBackground ( Color c)
Note: color is a helper class.
• setForeground(): used to change the foreground color of a
component.
public void setForeground ( Font obj)
• Font is represented by java.awt.Font.
public Font (String FontName, int Style, int Size)
e.g. : Font f = (“Times New Roman”, Font.BOLD, 20);
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
18. • setBounds(): used to specify size and position of component in
a container.
public void setBounds (int left, int top, int width, int height)
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
19. Commonly used methods of Container Class
• add(): used to add components to a container.
public void add (Component c)
• setSize(): used to specify the size of a container.
public void setSize(int width, int height)
• setLayout(): used to specify the layout manager for a container.
public void setLayout (LayoutManager mgr)
• setVisible(boolean visibility): used to set the visibility of
container.
public void setVisible (boolean visibility)
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
20. Label
• Used to describe other components or to display information on
a container.
Constructors:
public Label()
public Label (String s)
Methods:
• public String getText(): used to display the text on a Label.
• public void setText(): used to change the text.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
21. Button
• Buttons are used to initiate action.
Constructor:
public Button ()
public Button (String Name)
Methods:
public String getLabel()
public void setLabel(String Name)
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
22. TextField
• Used to receive input and display the output/result.
Constructor:
public TextField ()
public TextField (String Text)
public TextField (int No_of Chars)
Methods:
public String getText ()
public void setText (String Text)
public void setEchoChar ( char x)
public void setEditable (boolean editability)
public boolean isEditable()
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
23. TextArea
• Used to display multiple lines of output/result.
Constructor:
public TextArea()
public TextArea (String Text)
public TextArea (int numLines, int numChars)
public TextArea (String str, int numLines, int numChars, int sBars)
sBars Constants: (SCROLLBARS_NONE, SCROLLBARS_BOTH,
SCROLLBARS_HORIZONTAL_ONLY, SCROLLBARS_VERTICAL_ONLY)
Methods:
Supports all the methods of TextArea.
void append(String str)
void insert(String str, int index)
void replaceRange(String str, int startIndex, int endIndex)
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
24. Checkbox and RadioButtons
• Checkbox and CheckboxGroup classes are used to create
RadioButtons.
public Checkbox (String Text)
public Checkbox (String Text, Boolean State)
public Checkbox (String Text, Boolean State,
CheckboxGroup cbg )
public Checkbox (String Text, CheckboxGroup cbg, Boolean
State, )
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
25. Methods
•
•
•
•
boolean getState( )
void setState(boolean on)
String getLabel( )
void setLabel(String str)
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
26. CheckboxGroup
• Used to create a set of mutually exclusive check boxes in which
one and only one check box in the group can be checked at a
time.
Constructor:
public CheckboxGroup()
Methods:
Checkbox getSelectedCheckbox( )
void setSelectedCheckbox(Checkbox which)
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
27. Menu Bars and Menus
•
Menu is implemented in AWT by the following classes:
MenuBar, Menu, and MenuItem.
•
A menu bar displays a list of top-level menu choices. Each choice is
associated with a drop-down menu.
•
A menu bar contains one or more Menu objects. Each Menu object contains
a list of MenuItem objects.
•
Each MenuItem object represents something that can be selected by the user.
•
Since Menu is a subclass of MenuItem, a hierarchy of nested submenus can
be created.
•
Checkable menu items are menu options of type CheckboxMenuItem and
will have a check mark next to them when they are selected.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
28. Creating Menus
• To create a menu bar, first create an instance of MenuBar. This class
only defines the default constructor.
• Next, create instances of Menu that will define the selections
displayed on the bar. Following are the constructors for Menu:
Menu( ) throws HeadlessException
Menu(String optionName) throws HeadlessException
• Individual menu items are of type MenuItem. It defines these
constructors:
MenuItem( ) throws HeadlessException
MenuItem(String itemName) throws HeadlessException
MenuItem(String itemName, MenuShortcut keyAccel) throws
HeadlessException
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
29. • We can disable or enable a menu item by using the setEnabled( )
method.
void setEnabled (boolean enabledFlag)
• If the argument enabledFlag is true, the menu item is enabled. If false,
the menu item is disabled.
• We can determine an item’s status by calling isEnabled( ).
boolean isEnabled( )
• isEnabled( ) returns true if the menu item on which it is called is
enabled. Otherwise, it returns false.
• We can change the name of a menu item by calling setLabel( ). We
can retrieve the current name by using getLabel( ).
void setLabel(String newName)
String getLabel( )
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
30. CheckboxMenuItem
• We can create a checkable menu item by using a subclass of
MenuItem called CheckboxMenuItem.
CheckboxMenuItem( ) throws HeadlessException
CheckboxMenuItem(String itemName) throws HeadlessException
CheckboxMenuItem(String itemName, boolean on) throws
HeadlessException
• We can obtain the status of a checkable item by calling getState( ).
You can set it to a known state by using setState( ).
boolean getState( )
void setState(boolean checked)
Note: HeadlessException is Thrown when code that is dependent on a
keyboard, display, or mouse is called in an environment that does not
support a keyboard, display, or mouse.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
31. Choice
• The Choice class presents a pop-up menu of choices.
• The current choice is displayed as the title of the menu.
Choice c = new Choice();
// Only default constructor available
c.add(“B. Tech.”); c.add(“BCA”); c.add(“B. Arch.”);
Methods:
String getItem(int index)
int getItemCount()
String getSelectedItem()
int getSelectedIndex()
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
32. List
• The List class provides a compact, multiple-choice, scrolling
selection list.
Constructors:
List( )
List(int numRows)
List(int numRows, boolean multipleSelect)
Methods:
void add(String name)
void add(String name, int index)
String getSelectedItem()
int getSelectedIndex()
String[] getSelectedItems()
int[] getSelectedIndexes()
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
33. Layout Manager classes
LayoutManager class
Description
BorderLayout
The border layout manager. Border layouts use five
components: North, South, East, West, and Center
CardLayout
The card layout manager. Card layouts emulate index
cards. Only the one on top is showing.
GridLayout
The grid layout manager. Grid layout displays
components in a two-dimensional grid.
FlowLayout
The flow layout manager. Flow layout positions
components left to right, top to bottom.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
34. FlowLayout
•
•
Arranges the components in left to right, top to bottom fashion.
It is the default layout manager for Frame.
public FlowLayout ()
public FlowLayout (int alignment)
public FlowLayout (int alignment, int H_Gap, int V_Gap)
•
Alignments are specified as:
FlowLayout.LEFT
FlowLayout.RIGHT
FlowLayout.CENTER
•
By default 5 pixels is used as horizontal and vertical gap between
components.
FlowLayout fl = new FlowLayout (FlowLayout.CENTER, 30, 20);
frm.setLayout(fl);
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
35. GridLayout
• It divides a container into a grid of specified rows and columns.
Each to display one component.
• Size of component is changed according to the size of the cell.
public GridLayout (int row, int column)
public GridLayout (int row, int column, int H_Gap, int V_Gap)
GridLayout gl = new GridLayout (3, 4);
frm.setLayout (gl);
GridLayout gl1 = new GridLayout (3, 4, 20, 30);
frm.setLayout (gl2);
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
36. BorderLayout
• It divides the container into 5 regions ( NORTH, SOUTH,
EAST, WEST and CENTER).
• It is the default layout manager for Window.
public BorderLayout()
• To add a component at a specific region, following method is
used:
public void add ( Component c, int Region)
Example:
Button btn = new Button(“OK”);
frm.add( btn, BorderLayout.EAST);
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
37. CardLayout
• It is used to arrange containers in the form of deck of cards.
Methods:
first() / last()/ next()/ previous(): is used to make the first/ last/
next/ previous card visible.
show(): is used to make a specified card visible.
public void show ( Container deck, String CardName)
• To give a name to the container while it is added to the deck:
public void add ( Container card, String CardName)
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
38. Steps to Create a Frame-based Interface
1)
2)
3)
4)
Create a Frame object.
Create Component Objects.
Add the Component objects to Frame.
Set the size of the Frame and make it visible.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
39. My First Application
import java.awt.*;
class MyFirstApp
{
static TextField t1,t2,t3; static Button b1;
public static void main(String arr[])
{
Frame f = new Frame ("My Calculator");
Label l1 = new Label (“1st Number"); Label l2 = new Label (“2nd Number");
Label l3 = new Label ("Result");
t1 = new TextField(20); t2 = new TextField(20);
t3 = new TextField(20); t3.setEditable(false);
b1 = new Button("Add");
f.setLayout(new FlowLayout());
f.add(l1); f.add(t1); f.add(l2); f.add(t2); f.add(l3); f.add(t3); f.add(b1);
f.setSize(200,250); f.setVisible(true);
}
}
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)