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.
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.
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 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 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.
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 object-oriented programming concepts in Java including encapsulation, inheritance, polymorphism, and abstraction. It also discusses key Java features like classes, interfaces, access modifiers, and differences between abstract classes and interfaces. Object-oriented principles like encapsulation, inheritance and polymorphism are explained along with examples. Common questions about Java concepts are also addressed at the end.
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.
The document discusses Java Beans, Applets, JDBC, Networking in Java, JNDI, and some key classes used in these technologies. It provides an overview of concepts like Java Beans components, properties, events, introspection, customization, persistence. It describes the lifecycle and methods of Applets. It outlines the basic steps to use JDBC like loading drivers, establishing connections, executing queries. It discusses connection-oriented and connectionless networking in Java and common network classes like Socket, ServerSocket, URL, URLConnection. It provides a high-level overview of the JNDI architecture.
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.
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 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 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.
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 object-oriented programming concepts in Java including encapsulation, inheritance, polymorphism, and abstraction. It also discusses key Java features like classes, interfaces, access modifiers, and differences between abstract classes and interfaces. Object-oriented principles like encapsulation, inheritance and polymorphism are explained along with examples. Common questions about Java concepts are also addressed at the end.
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.
The document discusses Java Beans, Applets, JDBC, Networking in Java, JNDI, and some key classes used in these technologies. It provides an overview of concepts like Java Beans components, properties, events, introspection, customization, persistence. It describes the lifecycle and methods of Applets. It outlines the basic steps to use JDBC like loading drivers, establishing connections, executing queries. It discusses connection-oriented and connectionless networking in Java and common network classes like Socket, ServerSocket, URL, URLConnection. It provides a high-level overview of the JNDI architecture.
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.
Java is a general-purpose, object-oriented computer programming language that offers special features that allow programs to take advantage of the power and flexibility of the Internet.
The document discusses JPA/Hibernate, object-relational mapping, and web services. It defines Hibernate as an open source ORM for Java that makes data persistent by storing it in a database. It notes that Hibernate automatically generates SQL queries and reduces development time compared to manually handling data with JDBC. The architecture of Hibernate and web services is described, including how Hibernate sits between code and the database to map objects to tables. Common web service types like SOAP and REST are also summarized.
Priyanka Pradhan presents an introduction to the Java programming language. Java is an object-oriented language that is platform independent. The document discusses what Java is, the tools needed like the JDK and text editor, how to set the path and compile/run a "Hello World" program. It also covers Java concepts like classes, objects, inheritance, interfaces, and the basics of creating objects and using constructors.
What are the top 10 Java Interview Questions and Answers in 2014? Based on the most popular java questions asked in interview, we've compiled a list of the 10 most popular java interview questions in 2014.
Appearing for a java interview is not easy but if you brush up enough fundamentals, then you can easily crack the interview. The above questions are the most popular java interview questions asked by major companies so make sure to download this pdf.
This list includes java interview questions in the below categories:
top 10 java interview questions
top 10 java interview questions and answers
10 most popular interview questions
core java interview questions and answers
basic java interview questions and answers
serialization in java interview questions
core java interview questions pdf
multithreading in java interview questions
advanced java interview questions and answers
top 10 java interview questions and answers for freshers
top 100 java interview questions and answers
java interview questions and answers pdf
java interview questions and answers for freshers
java interview questions and answers for experienced
java interview questions and answers for 3 years experience
java interview questions and answers pdf download
java collections interview questions and answers
- Java is a high-level programming language originally developed by Sun Microsystems and released in 1995. It runs on a variety of platforms such as Windows, Mac OS, and UNIX.
- The Java Virtual Machine (JVM) allows Java code to run on different platforms, as the bytecode is interpreted by the JVM rather than being compiled into platform-specific machine code.
- Some key features of Java include being object-oriented, platform independent, robust, interpreted, and multi-threaded.
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...Sagar Verma
16. Threads in Java
Non-Threaded Applications
Threaded Applications
Process based multitasking Vs Thread based multitasking
Thread API in Java
Creating Threads
States of a Thread
Synchronization for threads; static and non-static synchronized methods; blocks; concept of object and class locks
Coordination between threads - wait, notify and notifyAll methods for inter-thread communication
17. Applets
What are applets?
Need for Applets
Different ways of running an applet program
Applet API hierarchy
Life Cycle of an applet
Even Handlers for applets, mouse events, click events
18. Swing GUI
Introduction to AWT
Introduction to Swing GUI
Advantages of Swing over AWT
Swing API
Swing GUI Components
Event Handlers for Swing
Sample Calculator application using Swing GUI and Swing Event handling
19. JDBC
What is JDBC; introduction
JDBC features
JDBC Drivers
Setting up a database and creating a schema
Writing JDBC code to connect to DB
CRUD Operations with JDBC
Statement types in JDBC
Types of Rowset, ResultSet in JDBC
20. Access Modifiers in Java
What are access modifiers?
Default
Protected
Private
Public
This document provides an overview of core Java concepts including object-oriented programming (OOP) principles like classes, objects, encapsulation, abstraction, inheritance, and polymorphism. It also discusses Java language benefits like being simple, portable, robust, and suitable for distributed environments. Finally, it outlines how to set up a Java development environment and write a basic "Hello World" program to get started with Java programming.
Here I discuss about Java programming language and easiest way to solve programming problem. Java basic syntax and their uses are described briefly so that anyone can easily understand within very short time. If anyone follow the slide with proper way,I assure that he or she will find java programming interesting.
This document provides an overview of object-oriented programming and the Java platform. It discusses the history of computing and the development of object-oriented programming. It then covers key concepts of object-oriented programming like classes, objects, encapsulation, inheritance and polymorphism. The document also provides details about the Java programming language, its benefits like portability and its components like the Java Runtime Environment. It concludes with explaining the phases of creating and executing a Java program from writing code to running the compiled bytecode.
This document provides a quick reference guide for J2SE (Core Java). It covers various topics related to Java programming including Java history, features, programming structure, data types, control structures, OOP concepts, exceptions, threads, GUI programming and more. The guide was written by A.R. Kishore Kumar and is intended to be a concise yet comprehensive overview of the Java language.
The document discusses procedural programming versus object-oriented programming and provides examples using Java. It defines procedural programming as dividing a program into subprocedures that perform specific tasks, with most data shared globally. Object-oriented programming is defined as partitioning memory for both data and functions using objects. The document then outlines key concepts of OOP like objects, classes, encapsulation, and polymorphism. It provides history on the development of Java and its advantages over C++ as a simpler, safer, and more robust language.
Java is an object-oriented programming language that is derived from C and C++. It can be used to create a variety of applications including standalone applications, web applications, enterprise applications, and mobile applications. Java programs are compiled to bytecode that can run on any Java Virtual Machine, making Java platform independent. Key features of Java include being simple, object-oriented, platform independent, secure, robust, and multi-threaded. The basic structure of a Java program includes classes that contain methods. Methods can be overloaded by changing their parameters.
The document provides information about Core Java concepts including:
1. James Gosling initiated the Java language project in 1991 and Sun released the first public implementation as Java 1.0 in 1995 with the promise of "Write Once, Run Anywhere".
2. Oracle acquired Sun Microsystems in 2010 and has worked to build fully integrated systems optimized for performance.
3. The document discusses the differences between C++ and Java and covers Java concepts like objects, classes, methods, variables, data types, identifiers, arrays and the Java Virtual Machine (JVM).
The document provides an overview of core Java concepts including:
- Java is an object-oriented programming language and platform that runs on a virtual machine. It is used to create desktop, web, enterprise, mobile and other applications.
- Core Java concepts include objects, classes, inheritance, polymorphism, abstraction and encapsulation. The document also discusses variables and data types, OOP principles, object creation, method overloading and constructors.
- It provides examples of Hello World programs and explains Java memory areas like stack and heap. Key topics like static keyword, method vs constructor and method overloading are also summarized.
java tutorial for beginner - Free DownloadTIB Academy
TIB Academy offering Java tutorial with fundamental for beginner This Java Tutorial going to explain about the fundamentals of Core Java Concepts, you can download Java tutorial as PPT for free of cost
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive function. Exercise causes chemical changes in the brain that may help protect against mental illness and improve symptoms.
This document discusses internationalization in Java programming. It covers key aspects like the Locale class, formatting dates, numbers and currencies based on locale, and using resource bundles to store locale-specific resources. The Locale class represents a specific geographical region and is used to customize program output for that locale. Classes like DateFormat and NumberFormat allow formatting dates, numbers and currencies according to the conventions of a locale. Resource bundles provide a way to externalize locale-specific resources so the same program can support multiple locales.
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 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.
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.
Java is a general-purpose, object-oriented computer programming language that offers special features that allow programs to take advantage of the power and flexibility of the Internet.
The document discusses JPA/Hibernate, object-relational mapping, and web services. It defines Hibernate as an open source ORM for Java that makes data persistent by storing it in a database. It notes that Hibernate automatically generates SQL queries and reduces development time compared to manually handling data with JDBC. The architecture of Hibernate and web services is described, including how Hibernate sits between code and the database to map objects to tables. Common web service types like SOAP and REST are also summarized.
Priyanka Pradhan presents an introduction to the Java programming language. Java is an object-oriented language that is platform independent. The document discusses what Java is, the tools needed like the JDK and text editor, how to set the path and compile/run a "Hello World" program. It also covers Java concepts like classes, objects, inheritance, interfaces, and the basics of creating objects and using constructors.
What are the top 10 Java Interview Questions and Answers in 2014? Based on the most popular java questions asked in interview, we've compiled a list of the 10 most popular java interview questions in 2014.
Appearing for a java interview is not easy but if you brush up enough fundamentals, then you can easily crack the interview. The above questions are the most popular java interview questions asked by major companies so make sure to download this pdf.
This list includes java interview questions in the below categories:
top 10 java interview questions
top 10 java interview questions and answers
10 most popular interview questions
core java interview questions and answers
basic java interview questions and answers
serialization in java interview questions
core java interview questions pdf
multithreading in java interview questions
advanced java interview questions and answers
top 10 java interview questions and answers for freshers
top 100 java interview questions and answers
java interview questions and answers pdf
java interview questions and answers for freshers
java interview questions and answers for experienced
java interview questions and answers for 3 years experience
java interview questions and answers pdf download
java collections interview questions and answers
- Java is a high-level programming language originally developed by Sun Microsystems and released in 1995. It runs on a variety of platforms such as Windows, Mac OS, and UNIX.
- The Java Virtual Machine (JVM) allows Java code to run on different platforms, as the bytecode is interpreted by the JVM rather than being compiled into platform-specific machine code.
- Some key features of Java include being object-oriented, platform independent, robust, interpreted, and multi-threaded.
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...Sagar Verma
16. Threads in Java
Non-Threaded Applications
Threaded Applications
Process based multitasking Vs Thread based multitasking
Thread API in Java
Creating Threads
States of a Thread
Synchronization for threads; static and non-static synchronized methods; blocks; concept of object and class locks
Coordination between threads - wait, notify and notifyAll methods for inter-thread communication
17. Applets
What are applets?
Need for Applets
Different ways of running an applet program
Applet API hierarchy
Life Cycle of an applet
Even Handlers for applets, mouse events, click events
18. Swing GUI
Introduction to AWT
Introduction to Swing GUI
Advantages of Swing over AWT
Swing API
Swing GUI Components
Event Handlers for Swing
Sample Calculator application using Swing GUI and Swing Event handling
19. JDBC
What is JDBC; introduction
JDBC features
JDBC Drivers
Setting up a database and creating a schema
Writing JDBC code to connect to DB
CRUD Operations with JDBC
Statement types in JDBC
Types of Rowset, ResultSet in JDBC
20. Access Modifiers in Java
What are access modifiers?
Default
Protected
Private
Public
This document provides an overview of core Java concepts including object-oriented programming (OOP) principles like classes, objects, encapsulation, abstraction, inheritance, and polymorphism. It also discusses Java language benefits like being simple, portable, robust, and suitable for distributed environments. Finally, it outlines how to set up a Java development environment and write a basic "Hello World" program to get started with Java programming.
Here I discuss about Java programming language and easiest way to solve programming problem. Java basic syntax and their uses are described briefly so that anyone can easily understand within very short time. If anyone follow the slide with proper way,I assure that he or she will find java programming interesting.
This document provides an overview of object-oriented programming and the Java platform. It discusses the history of computing and the development of object-oriented programming. It then covers key concepts of object-oriented programming like classes, objects, encapsulation, inheritance and polymorphism. The document also provides details about the Java programming language, its benefits like portability and its components like the Java Runtime Environment. It concludes with explaining the phases of creating and executing a Java program from writing code to running the compiled bytecode.
This document provides a quick reference guide for J2SE (Core Java). It covers various topics related to Java programming including Java history, features, programming structure, data types, control structures, OOP concepts, exceptions, threads, GUI programming and more. The guide was written by A.R. Kishore Kumar and is intended to be a concise yet comprehensive overview of the Java language.
The document discusses procedural programming versus object-oriented programming and provides examples using Java. It defines procedural programming as dividing a program into subprocedures that perform specific tasks, with most data shared globally. Object-oriented programming is defined as partitioning memory for both data and functions using objects. The document then outlines key concepts of OOP like objects, classes, encapsulation, and polymorphism. It provides history on the development of Java and its advantages over C++ as a simpler, safer, and more robust language.
Java is an object-oriented programming language that is derived from C and C++. It can be used to create a variety of applications including standalone applications, web applications, enterprise applications, and mobile applications. Java programs are compiled to bytecode that can run on any Java Virtual Machine, making Java platform independent. Key features of Java include being simple, object-oriented, platform independent, secure, robust, and multi-threaded. The basic structure of a Java program includes classes that contain methods. Methods can be overloaded by changing their parameters.
The document provides information about Core Java concepts including:
1. James Gosling initiated the Java language project in 1991 and Sun released the first public implementation as Java 1.0 in 1995 with the promise of "Write Once, Run Anywhere".
2. Oracle acquired Sun Microsystems in 2010 and has worked to build fully integrated systems optimized for performance.
3. The document discusses the differences between C++ and Java and covers Java concepts like objects, classes, methods, variables, data types, identifiers, arrays and the Java Virtual Machine (JVM).
The document provides an overview of core Java concepts including:
- Java is an object-oriented programming language and platform that runs on a virtual machine. It is used to create desktop, web, enterprise, mobile and other applications.
- Core Java concepts include objects, classes, inheritance, polymorphism, abstraction and encapsulation. The document also discusses variables and data types, OOP principles, object creation, method overloading and constructors.
- It provides examples of Hello World programs and explains Java memory areas like stack and heap. Key topics like static keyword, method vs constructor and method overloading are also summarized.
java tutorial for beginner - Free DownloadTIB Academy
TIB Academy offering Java tutorial with fundamental for beginner This Java Tutorial going to explain about the fundamentals of Core Java Concepts, you can download Java tutorial as PPT for free of cost
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive function. Exercise causes chemical changes in the brain that may help protect against mental illness and improve symptoms.
This document discusses internationalization in Java programming. It covers key aspects like the Locale class, formatting dates, numbers and currencies based on locale, and using resource bundles to store locale-specific resources. The Locale class represents a specific geographical region and is used to customize program output for that locale. Classes like DateFormat and NumberFormat allow formatting dates, numbers and currencies according to the conventions of a locale. Resource bundles provide a way to externalize locale-specific resources so the same program can support multiple locales.
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 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.
The document provides an overview of servlets and related technologies. It discusses that servlets are Java programs that run on a web or application server, process client requests, and produce dynamic web pages. Servlets act as a middle layer between requests from browsers/clients and databases on the server. The document also covers common gateway interface (CGI), GET and POST methods, query strings, advantages of servlets over CGI, the servlet API, servlet lifecycle, session tracking techniques including cookies, and examples of using cookies to track sessions.
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.
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.
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 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.
Swing is a Java library that provides graphical user interface (GUI) components. It extends and improves upon the Abstract Window Toolkit (AWT) by providing new, enhanced components with better functionality like drag and drop support. Swing components are lightweight and platform independent, use the model-view-controller architecture, and support pluggable look and feel.
Rod Johnson created the Spring Framework, an open-source Java application framework. Spring is considered a flexible, low-cost framework that improves coding efficiency. It helps developers perform functions like creating database transaction methods without transaction APIs. Spring removes configuration work so developers can focus on writing business logic. The Spring Framework uses inversion of control (IoC) and dependency injection (DI) principles to manage application objects and dependencies between them.
Java is a general-purpose computer-programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible.
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 proposes an automated test architecture for the UI Builder application using REST API testing, UI testing, and integration testing. It recommends the Rest Assured library for API testing due to its ability to integrate with Jenkins and remove the need for manual HTTP calls. Protractor is proposed for UI testing as it allows testing Angular applications in JavaScript and integrates well with Selenium. Both test frameworks would be set up with their own Git repositories linked to Jenkins jobs. Integration testing would link the API and UI test repos. The test automation aims to provide faster feedback and reduce regressions as the application grows.
The document provides an agenda and recap for an Angular workshop session. The agenda covers Angular component lifecycle, modularizing Angular applications, Angular routing, and hands-on examples. The recap summarizes key points from the previous session, including why Angular is used for single page applications, its building blocks like components and services, and TypeScript. It also discusses Angular component lifecycle hooks and provides an example flow. The hands-on section describes refactoring a weather application to add routing and modularization. Essential coding practices like separation of concerns and reusability are also covered.
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.
The document provides information about an Object-Oriented Programming Concepts using JAVA course taught by K. Ravi Chythanya. It includes details about the course outcomes, syllabus, and assessment components. The syllabus is divided into 5 units that cover Java programming concepts like conditional statements, loops, arrays, methods, OOP principles, exceptions handling, collections, multithreading and I/O streams. The first unit focuses on Java basics, variables scope, and arrays.
Spring is a lightweight, open-source application framework for Java. It uses dependency injection (DI) and inversion of control (IOC) to decouple application components. Spring's features include AOP, transaction management, JDBC support, and integration with various web frameworks like Struts and MVC. It supports DI through constructor injection and setter injection. Spring applications typically use XML configuration files to wire application components together.
The document discusses professionalizing the front-end developer role. It covers:
1. The responsibilities of a front-end developer in bringing a designer's static design to life, separating concerns between front-end and back-end teams through an API.
2. Techniques, tools, languages, and frameworks a front-end developer uses like test-driven development, automation workflows, preprocessors, frameworks, and more.
3. Introductions to Angular and React, including their conceptual overviews, classic request flows, learning curves, and how to think in the "React way" through components, state, data flow, and more.
This document provides an overview and tutorial on the Spring Framework. It discusses that Spring is an open source Java platform that makes Java enterprise application development easier and faster. It was created by Rod Johnson in 2003. The document then covers Spring Framework concepts like dependency injection, aspect oriented programming, the various Spring modules for different applications, and how to set up a development environment for Spring.
Spring Framework 4 is an open source application framework for Java. It was created to make enterprise Java development easier by promoting best practices. Some key features of Spring include dependency injection for loose coupling, declarative transactions, and aspect oriented programming for separation of concerns. The Spring framework uses an inversion of control container and aspect-oriented programming to configure and manage objects.
JAVA was developed by Sun Microsystems Inc in 1991, later acquired by Oracle Corporation. It was developed by James Gosling and Patrick Naughton. It is a simple programming language. Writing, compiling and debugging a program is easy in java. It helps to create modular programs and reusable code.
1. Pallavi Jindal has over 6 years of experience in full-stack Java/J2EE development including requirement analysis, design, development, testing and deployment of software applications.
2. She has experience working under Agile methodologies and with technologies like Spring, Hibernate, AngularJS, RESTful APIs, and databases like Oracle, SQL Server and MySQL.
3. She is currently a Software Engineer at Pointillist where she leads design and development efforts for a new customer onboarding tool using JavaScript and has developed modules for their behavior analytics product using AngularJS, Spring and JPA.
Synchronization in Java controls access to shared resources by multiple threads so that only one thread can access a resource at a time. The JVM interprets bytecode, making Java platform independent. Interfaces define methods for classes to implement, while abstract classes can include implementations along with abstract methods. Autoboxing converts primitives to wrapper types for object-oriented operations, while unboxing converts wrappers back to primitives.
This document provides an overview of Java GUI programming using AWT and Swing. It discusses:
1. AWT and Swing - the two main sets of visual components for building Java GUIs. AWT relies on native platform components while Swing uses pure Java components.
2. Key concepts of AWT and Swing including lightweight vs heavyweight components, advantages and disadvantages of each, and common GUI component and container classes.
3. The Java GUI API class hierarchy including component classes, container classes, and helper classes for graphics, colors, fonts etc.
4. Event handling in Java GUI programs using the delegation model where components fire events and listener objects handle them. Common user actions, event
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 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 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 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 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.
Have you ever been confused by the myriad of choices offered by AWS for hosting a website or an API?
Lambda, Elastic Beanstalk, Lightsail, Amplify, S3 (and more!) can each host websites + APIs. But which one should we choose?
Which one is cheapest? Which one is fastest? Which one will scale to meet our needs?
Join me in this session as we dive into each AWS hosting service to determine which one is best for your scenario and explain why!
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 .
For the full video of this presentation, please visit: https://www.edge-ai-vision.com/2024/06/building-and-scaling-ai-applications-with-the-nx-ai-manager-a-presentation-from-network-optix/
Robin van Emden, Senior Director of Data Science at Network Optix, presents the “Building and Scaling AI Applications with the Nx AI Manager,” tutorial at the May 2024 Embedded Vision Summit.
In this presentation, van Emden covers the basics of scaling edge AI solutions using the Nx tool kit. He emphasizes the process of developing AI models and deploying them globally. He also showcases the conversion of AI models and the creation of effective edge AI pipelines, with a focus on pre-processing, model conversion, selecting the appropriate inference engine for the target hardware and post-processing.
van Emden shows how Nx can simplify the developer’s life and facilitate a rapid transition from concept to production-ready applications.He provides valuable insights into developing scalable and efficient edge AI solutions, with a strong focus on practical implementation.
Introduction of Cybersecurity with OSS at Code Europe 2024Hiroshi SHIBATA
I develop the Ruby programming language, RubyGems, and Bundler, which are package managers for Ruby. Today, I will introduce how to enhance the security of your application using open-source software (OSS) examples from Ruby and RubyGems.
The first topic is CVE (Common Vulnerabilities and Exposures). I have published CVEs many times. But what exactly is a CVE? I'll provide a basic understanding of CVEs and explain how to detect and handle vulnerabilities in OSS.
Next, let's discuss package managers. Package managers play a critical role in the OSS ecosystem. I'll explain how to manage library dependencies in your application.
I'll share insights into how the Ruby and RubyGems core team works to keep our ecosystem safe. By the end of this talk, you'll have a better understanding of how to safeguard your code.
Best 20 SEO Techniques To Improve Website Visibility In SERPPixlogix Infotech
Boost your website's visibility with proven SEO techniques! Our latest blog dives into essential strategies to enhance your online presence, increase traffic, and rank higher on search engines. From keyword optimization to quality content creation, learn how to make your site stand out in the crowded digital landscape. Discover actionable tips and expert insights to elevate your SEO game.
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.
Ivanti’s Patch Tuesday breakdown goes beyond patching your applications and brings you the intelligence and guidance needed to prioritize where to focus your attention first. Catch early analysis on our Ivanti blog, then join industry expert Chris Goettl for the Patch Tuesday Webinar Event. There we’ll do a deep dive into each of the bulletins and give guidance on the risks associated with the newly-identified vulnerabilities.
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfChart Kalyan
A Mix Chart displays historical data of numbers in a graphical or tabular form. The Kalyan Rajdhani Mix Chart specifically shows the results of a sequence of numbers over different periods.
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.
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
Programming Foundation Models with DSPy - Meetup SlidesZilliz
Prompting language models is hard, while programming language models is easy. In this talk, I will discuss the state-of-the-art framework DSPy for programming foundation models with its powerful optimizers and runtime constraint system.
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
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.
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.
1. Advanced Java Programming
Lecture 1: Introduction to GUI Programming
By
Ravi Kant Sahu
Asst. Professor
Lovely Professional University, PunjabLovely Professional University, Punjab
2. Introduction
• AWT is fine for developing simple graphical user interfaces, but
not for developing comprehensive GUI projects.
• Swing components depend less on the target platform and use
less of the native GUI resource.
• Swing GUI component classes are named with a prefixed J.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
3. Why AWT and Swing?
• Although Swing eliminates a number of the limitations inherent
in the AWT, Swing does not replace it.
• Instead, Swing is built on the foundation of the AWT. This is
why the AWT is still a crucial part of Java.
• Swing also uses the same event handling mechanism as the
AWT.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
4. Java Foundation Classes
• JFC encompass a group of features for building graphical user
interfaces (GUIs) and adding rich graphics functionality and
interactivity to Java applications.
Swing GUI Components
Pluggable Look-and-Feel Support
Java 2D API
Internationalization
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
5. Key Features of Swing
• Swing Components Are Lightweight
Means that they are written entirely in Java and do not map directly to
platform-specific peers.
• Java 2D API
Enables developers to easily incorporate high-quality 2D graphics, text,
and images in applications and applets.
• Internationalization
Allows developers to build applications that can interact with users
worldwide in their own languages and cultural conventions.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
6. Key Features of Swing
• Swing Supports a Pluggable Look and Feel
The look and feel of Swing applications is pluggable, allowing a
choice of look and feel.
• For example, the same program can use either the Java or the Windows
look and feel.
• Additionally, the Java platform supports the GTK+ look and feel, which
makes hundreds of existing look and feels available to Swing programs.
• The Synth package allows you to create your own look and feel.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
7. AWT Vs Swing
AWT SWING
Components are heavy-weight. Light-weight components.
Native look and feel Pluggable look and feel
Does not have MVC Supports MVC
Not available in AWT. Swing has many advanced features like
JTabel, Jtabbedpane.
Components are platform dependent. Components are platform independent.
AWT components require java.awt
package.
Swing components require javax.swing
package.
Slower Faster than AWT
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
8. Swing API
• GUI API contains classes that can be classified into three
groups: component classes, container classes, and helper
classes.
• The component classes, such as JButton, JLabel, and
JTextField, are for creating the user interface.
• The container classes, such as JFrame, JPanel, and JApplet, are
used to contain other components.
• The helper classes, such as Graphics, Color, Font, FontMetrics,
and Dimension, are used to support GUI components.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
10. MVC Connection
• A visual component is a composite of three distinct aspects:
1) The state information associated with the component
2) The way that the component looks when rendered on the screen
3) The way that the component reacts to the user
• Model-View-Controller architecture is successful because each piece
of the design corresponds to an aspect of a component.
• By separating a component into a model, a view, and a controller, the
specific implementation of each can be changed without affecting the
other two.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
11. MVC
• In MVC terminology, the model corresponds to the state information
associated with the component.
• For example, in the case of a check box, the model contains a field
that indicates if the box is checked or unchecked.
• The view determines how the component is displayed on the screen,
including any aspects of the view that are affected by the current state
of the model.
• The controller determines how the component reacts to the user.
For example, when the user clicks a check box, the controller reacts
by changing the model to reflect the user’s choice (checked or
unchecked).
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
12. Swing MVC Architecture
• Swing uses a modified version of MVC that combines the view and
the controller into a single logical entity called the UI delegate.
• For this reason, Swing’s approach is called either the Model Delegate
architecture or the Separable Model architecture.
• Therefore, although Swing’s component architecture is based on
MVC, it does not use a classical implementation of it.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
13. Swing MVC
• Swing’s pluggable look and feel is made possible by its Model-Delegate
architecture.
• Because the view (look) and controller (feel) are separate from the model,
the look and feel can be changed without affecting how the component is
used within a program.
• To support the Model-Delegate architecture, most Swing components
contain two objects.
• The first represents the model and second represents the UI delegate.
• Models are defined by interfaces. For example, the model for a button is
defined by the ButtonModel interface.
• UI delegates are classes that inherit ComponentUI. For example, the UI
delegate for a button is ButtonUI.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
14. Event Dispatching Thread
• Swing programs are event-driven. An event is passed to the
application by calling an event handler defined by the application.
• Swing event handling code runs on a special thread known as the
event dispatch thread.
• Thus, although event handlers are defined by our program, they are
called on a thread that was not created by the program.
• So all Swing GUI components must be created and updated from the
event dispatching thread, not the main thread of the application.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
15. Why EDT?
• Because most Swing object methods are not "thread safe":
invoking them from multiple threads risks thread interference or
memory consistency errors.
• Some Swing component methods are labeled "thread safe" in the
API specification; these can be safely invoked from any thread.
• All other Swing component methods must be invoked from the
event dispatch thread.
• Programs that ignore this rule may function correctly most of the
time, but are subject to unpredictable errors that are difficult to
reproduce.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
16. Event Dispatching Thread
• To enable the GUI code to be created on the event dispatching thread,
we must use one of two methods that are defined by the
SwingUtilities class.
• These methods are invokeLater( ) and invokeAndWait( ).
static void invokeLater (Runnable obj)
static void invokeAndWait(Runnable obj) throws
InterruptedException, InvocationTargetException
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
17. invokeLater() Vs invokeAndWait()
• invokeLater is used to perform task asynchronously in AWT
Event dispatcher thread while InvokeAndWait is used to
perform task synchronously.
• invokeLater is non blocking call while InvokeAndWait will
block until task is completed.
• invokeLater is more flexible in terms of user interaction because
it just adds the task in Event-Queue and allow user to interact
with system while invokeAndWait is preffered way to update
the GUI from application thread (waits for event to be
completed).
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
18. Swing Containers
• Swing defines two types of containers.
• The first are top-level containers: JFrame, JApplet, JWindow, and
JDialog.
• These containers do not inherit JComponent.
• They do, however, inherit the AWT classes Component and
Container.
• Unlike Swing’s other components, which are lightweight, the top-
level containers are heavyweight.
• This makes the top-level containers a special case in the Swing
component library.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
19. Swing Containers
• The second type of containers supported by Swing are
lightweight containers.
• Lightweight containers (e.g. JPanel, JScrollPane) do inherit
JComponent.
• Lightweight containers are used to organize and manage groups
of related components because a lightweight container can be
contained within another container.
• Thus, we can use lightweight containers to create subgroups of
related controls that are contained within an outer container.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
20. JPanel
• JPanel is a generic lightweight container.
Constructors:
• JPanel()
Creates a new JPanel with a double buffer and a flow layout.
• JPanel(LayoutManager layout)
Create a new buffered JPanel with the specified layout
manager.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
21. JPanel…
Methods:
• PanelUI getUI ()
Returns the look and feel (L&F) object.
• void setUI (PanelUI pi)
Sets the look and feel (L&F) object
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
22. JScrollPane
• JScrollPaneis a lightweight container that automatically handles the
scrolling of another component.
• The component being scrolled can either be an individual component,
such as a table, or a group of components contained within another
lightweight container, such as a JPanel.
• The viewable area of a scroll pane is called theviewport. It is a
window in which the component being scrolled is displayed.
JScrollPane(Component comp)
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
23. Steps to create JScrollPane
• Create the component to be scrolled.
• Create an instance of JScrollPane, passing to it the object to scroll.
• Add the scroll pane to the content pane.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
24. JTabbedPane
• It manages a set of components by linking them with tabs.
• The user chooses which component to view by selecting the tab
corresponding to the desired component.
• Selecting a tab causes the component associated with that tab to
come to the forefront.
• If you want similar functionality without the tab interface, you
can use a card layout instead of a tabbed pane.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
26. Top-Level Container Panes
• Each top-level container defines a set of panes.
• At the top of the hierarchy is an instance of JRootPane.
• JRootPane is a lightweight container whose purpose is to manage the
other panes. It also helps manage the optional menu bar.
• The panes that comprise the root pane are called the glass pane, the
content pane, and the layered pane.
• The glass pane is the top-level pane. It sits above and completely
covers all other panes. By default, it is a transparent instance of
JPanel.
• The layered pane is an instance of JLayeredPane. The layered pane
allows components to be given a depth value. The layered pane holds
the content pane and the (optional) menu bar.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
27. Color class
• We can set colors for GUI components by using the java.awt.Color
class.
• We can use one of the 13 standard colors (BLACK, BLUE, CYAN,
DARK_GRAY, GRAY, GREEN, LIGHT_GRAY, MAGENTA, ORANGE,
PINK, RED, WHITE, and YELLOW) defined as constants in
java.awt.Color.
• Colors are made of red, green, and blue components, each represented
by an int value that describes its intensity, ranging from 0(darkest
shade) to 255(lightest shade). This is known as the RGB model.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
28. • We can create a color using the following constructor:
public Color(int r, int g, int b);
• Color color = new Color(128,100,100);
• The arguments r, g, b are between 0 and 255. If a value beyond this
range is passed to the argument, an IllegalArgumentException will
occur.
Example:
JButton jb1 = new JButton("OK");
jb1.setBackground(color);
jb1.setForeground (new Color(100,1,1));
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
29. Font class
• We can create a font using the java.awt.Font class and set fonts for the
components using the setFont method in the Component class.
• The constructor for Font is:
public Font (String name, int style, int size);
• You can choose a font name from SansSerif, Serif, Monospaced,
Dialog, or DialogInput.
• Choose a style from Font.PLAIN(0), Font.BOLD(1),
Font.ITALIC(2), and Font.BOLD+Font.ITALIC(3), and specify a
font size of any positive integer.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
30. • Example:
Font font1 = new Font("SansSerif", Font.BOLD, 16);
Font font2 = new Font("Serif", Font.BOLD + Font.ITALIC, 12);
JButton jbtOK = new JButton("OK");
jbtOK.setFont(font1);
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
31. Setting Default operations in a JFrame
• setDefaultCloseOperation() is used for setting the default operation
for close button of a JFrame.
void setDefaultCloseOperation (int what)
• These constants are declared in WindowConstants, which is an
interface declared in javax.swingthat is implemented by JFrame.
• JFrame.HIDE_ON_CLOSE
• JFrame.DO_NOTHING_ON_CLOSE
• JFrame.EXIT_ON_CLOSE
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
32. 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)
33. FlowLayout
• Arranges the components in left to right, top to bottom fashion.
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)
34. 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)
35. 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)
36. 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. Swing Components
• Swing components are derived from the JComponent class.
• JComponent provides the functionality that is common to all
components.
• For example, JComponent supports the pluggable look and feel.
• JComponent inherits the AWT classes Container and Component.
• Thus, a Swing component is built on and compatible with an AWT
component.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
40. JLabel
• JLabel is used to display text and/or an icon. It is a passive
component in that it does not respond to user input.
JLabel(Icon icon)
JLabel(String str)
JLabel(String str, Icon icon, int align)
• The align argument specifies the horizontal alignment of the text
and/or icon within the dimensions of the label.
• It must be one of the following values: LEFT, RIGHT, CENTER,
LEADING, or TRAILING.
• These constants are defined in the SwingConstants interface.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
41. • The icon and text associated with the label can be obtained by the
following methods:
Icon getIcon( )
String getText( )
• The icon and text associated with a label can be set by these
methods:
void setIcon(Icon icon)
void setText(String str)
42. JTextField
• JTextField allows us to edit one line of text.
JTextField(int cols)
JTextField(String str, int cols)
JTextField(String str)
• The integer argument passed to the JTextField constructor, indicates
the number of columns in the field (Minimum number of characters
displayed in the TextField ‘M’ or ‘W’).
• This number is used along with metrics provided by the field's current
font to calculate the field's preferred width.
• It does not limit the number of characters the user can enter.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
43. JTextArea
• A JTextArea is a multi-line area that displays plain text.
JTextArea ()
JTextArea (String str)
JTextArea (int rows, int cols)
JTextField (String str, int rows, int cols)
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
44. JPasswordField
• The JPasswordField class, a subclass of JTextField, provides
specialized text fields for password entry.
JPasswordField pf = new JPasswordField(10);
• For security reasons, a password field does not show the characters
that the user types.
• Instead, the field displays a character different from the one typed,
such as an asterisk ‘*’.
• As another security precaution, a password field stores its value as an
array of characters, rather than as a string.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
45. JPasswordField…
Reading the Password:
char[] input = passwordField.getPassword();
Setting and Getting Echo-char:
void setEchoChar(char)
char getEchoChar()
• void selectAll() method is used to all characters in the password
field.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
46. Swing Buttons
• Swing defines four types of buttons, all are subclasses of the
AbstractButton class, which extends JComponent.
JButton,
JToggleButton,
JCheckBox, and
JRadioButton
• AbstractButton contains many methods:
String getText( )
void setText(String str)
void setDisabledIcon(Icon di)
void setPressedIcon(Icon pi)
void setSelectedIcon(Icon si)
void setRolloverIcon(Icon ri)
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
47. JButton
• JButton class provides the functionality of a push button.
• JButton allows an icon, a string, or both to be associated with the
push button.
JButton(Icon i)
JButton(String str)
JButton(String str, Icon i)
• When the button is pressed, an ActionEvent is generated.
• We can set the action command by calling setActionCommand( ) on
the button.
• We can obtain the action command by calling getActionCommand( )
on the event object.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
48. JToggleButton
• A toggle button looks just like a push button, but it acts differently
because it has two states: pushed and released.
• Toggle buttons are objects of the JToggleButton class.
• JToggleButton is a super-class for two other Swing components that
also represent two-state controls.
• These are:
JCheckBox and JRadioButton
JToggleButton(String str)
• By default, the button is in the off position.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
49. JCheckBox
• JCheckBox class provides the functionality of a check box.
• Its immediate super class is JToggleButton, which provides support
for two-state buttons.
JCheckBox(String str)
• When the user selects or deselects a check box, an ItemEvent is
generated.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
50. JRadioButton
• Radio buttons are a group of mutually exclusive buttons, in which
only one button can be selected at any one time.
• They are supported by the JRadioButton class, which extends
JToggleButton.
• A button group is created by the ButtonGroup class.
• Its default constructor is invoked for this purpose.
• Elements are added to the button group by using add().
void add(AbstractButton ab)
• JRadioButton generates action events, item events, and change events
each time the button selection changes.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
51. Image Icons
• An icon is a fixed-size picture; typically it is small and used to
decorate components.
• Java supports three image formats: GIF, JPEG, and PNG.
• The image file names for these types end with .gif, .jpg, and .png,
respectively.
• To display an image icon, first create an ImageIcon object using new
javax.swing.ImageIcon(filename).
ImageIcon icon = new ImageIcon (“ravi.jpg");
• An image icon can be displayed in a label or a button using new
JLabel(image-Icon) or new JButton(imageIcon).
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
52. JTable
• JTable is a component that displays rows and columns of data.
• We can drag the cursor on column boundaries to resize columns.
• We can also drag a column to a new position.
• Depending on its configuration, it is also possible to select a row,
column, or cell within the table, and to change the data within a cell.
• JTable does not provide any scrolling capabilities of its own. Instead,
we normally wrap a JTable inside a JScrollPane.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
53. JTable(Object data[ ][ ], Object colHeads[ ])
• data is a two-dimensional array of the information to be presented,
and colHeads is a one-dimensional array with the column headings.
• ListSelectionEvent is generated when the user selects something in
the table.
• By default, JTable allows us to select one or more complete rows, but
we can change this behavior to allow one or more columns, or one or
more individual cells to be selected.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
54. Steps to create a JTable
1. Create an instance of JTable.
2. Create a JScrollPane object, specifying the table as the object to scroll.
3. Add the table to the scroll pane.
4. Add the scroll pane to the content pane.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
55. JList
• It supports the selection of one or more items from a list.
JList(Object [ ] items)
• JListis based on two models.
• The first is ListModel. This interface defines how access to the list
data is achieved.
• The second model is the ListSelectionModel interface, which defines
methods that determine what list item or items are selected.
• A JList generates a ListSelectionEvent when the user makes or
changes a selection.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
56. • JList allows the user to select multiple ranges of items within the list,
but we can change this behavior by calling setSelectionMode( ),
which is defined by JList.
void setSelectionMode(int mode)
• Here, mode specifies the selection mode. It must be one of these
values defined by
– SINGLE_SELECTION
– SINGLE_INTERVAL_SELECTION
– MULTIPLE_INTERVAL_SELECTION
• The default, multiple-interval selection, lets the user select multiple
ranges of items within a list.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
57. JComboBox
• Combo box is a combination of a text field and a drop-down list.
• A combo box normally displays one entry, but it will also display a
drop-down list that allows a user to select a different entry.
JComboBox(Object[ ]items)
• Items can be dynamically added to the list of choices via the addItem(
) method.
void addItem(Object obj)
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
58. JMenu
• A menu provides a space-saving way to let the user choose one of
several options.
• A menu usually appears either in a menu bar or as a popup menu.
• A menu bar contains one or more menus and has a customary,
platform-dependent location, usually along the top of a window.
• A popup menu is a menu that is invisible until the user makes a
platform-specific mouse action, such as pressing the right mouse
button, over a popup-enabled component.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
59. Creating JMenu
• Create a MenuBar
JMenuBar menuBar = new JMenuBar();
• Create Menus
JMenu menu = new JMenu("File");
• Create MenuItems
JMenuItem mi = new JMenuItem(“Open");
• Add MenuItems to Menu.
menu.add(mi);
• Add Menus to MenuBar
menuBar.add(menu);
• Set the MenuBar to the Container
setJMenuBar(menuBar);
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)