SlideShare una empresa de Scribd logo
1 de 4
Descargar para leer sin conexión
Core Java
1

Debasish Pratihari

Setting Fonts
Example :

import java.awt.*;
class FontDemo extends Frame{
Label label;
Font font;
FontDemo(){
super("FontDemo By Debasish Pratihari");
label= new Label("Welcome to Lakshya");
setLayout(new FlowLayout());
// Font Setting for Output-2
font=new Font("Arial",Font.BOLD,20);
// Font Setting for Output-3
//font=new Font("Arial",Font.BOLD+Font.ITALIC,30);
label.setFont(font);
add(label);
pack();
setVisible(true);
}
public static void main(String args[]){
new FontDemo();
}
}

Output 1:

Output 2:

Output 3:

Lecture/core/awt5/17

Page #1

feel the Technology…
Core Java

Debasish Pratihari

Setting Cursors for Components
Example

import java.awt.*;
class CursorDemo extends Frame{
Button button;
Cursor cursor;
CursorDemo(){
super("FontDemo By Debasish Pratihari");
button= new Button("Click Me");
setLayout(new FlowLayout());
cursor= new Cursor(Cursor.HAND_CURSOR);
button.setCursor(cursor);
add(button);
pack();
setVisible(true);
}
public static void main(String args[]){
new CursorDemo();
}
}

ToolKit Object :
 This object represents the environment on your
computer so it encapsulate all the properties
and capabilities of that environment , including
screen size and resolution.


To Obtain toolkit object:
o
o

ToolKit toolkit =
ToolKit.getDefaultToolKit();
Frame f= new Frame();
ToolKit toolkit=f.getToolKit();

Lecture/core/awt5/17

Page #2

feel the Technology…
Core Java

Debasish Pratihari

GraphicsEnvironment:


This object contains information about
graphics device attached to the system.



the

To Obtain GraphicsEnvironment Object :

GraphicsEnvironment graphics=
GraphicsEnvironment.getLocalGraphicsEnvironment();

Steps to create Menu :










create a Menu Bar
create required Menus
create Menu Items for all the menus
make the Menu items event sensitive
provide the event handlers for Menu items
add the menu items into the corresponding
Menus.
add menus to the menu bar
or incase of sub-menu add the menu to the
corresponding main-menu.
add the menu bar to the container

Example of Menu:

Lecture/core/awt5/17

Page #3

feel the Technology…
Core Java

Debasish Pratihari

Code Example :
import java.awt.*;
import java.awt.event.*;
public class MenuDemo extends Frame{
Label label;
MenuBar mb;
Menu col,ft,fname,style;
MenuItem red,green,blue,font1,font2,font3;
MenuShortcut ms;
Font font;
CheckboxMenuItem style1,style2,style3;
public MenuDemo(){
label=new Label("Welcome to Lakshya");
mb = new MenuBar();
col = new Menu("Color");
add(label);
ms=new MenuShortcut(KeyEvent.VK_R);
red=new MenuItem("Red",ms);
green=new MenuItem("Green",new
MenuShortcut(KeyEvent.VK_R,true));
blue=new MenuItem("Blue");
col.add(red);
col.add(green);
col.add(blue);
ft = new Menu("Font");
fname= new Menu("Name");
font1=new MenuItem("Arial");
font2=new MenuItem("Verdana");
font3=new MenuItem("Garamond");
style= new Menu("Style");
style1= new CheckboxMenuItem("Bold");
style2= new CheckboxMenuItem("Italic");
style3= new CheckboxMenuItem("Underline");
fname.add(font1);
fname.add(font2);
fname.add(font3);
style.add(style1);
style.add(style2);
style.add(style3);
ft.add(fname);
ft.add(style);
mb.add(col);
mb.add(ft);
add(back);
setMenuBar(mb);
setTitle("MenuDemo By Debasish Pratihari");
setSize(300,200);
setVisible(true);
}
public static void main(String args[]){
new MenuDemo();
}
}

Lecture/core/awt5/17

Page #4

feel the Technology…

Más contenido relacionado

La actualidad más candente (8)

[NHN NEXT] Java 강의 - Week1
[NHN NEXT] Java 강의 - Week1[NHN NEXT] Java 강의 - Week1
[NHN NEXT] Java 강의 - Week1
 
03 standard class library
03 standard class library03 standard class library
03 standard class library
 
Typescript tips & tricks
Typescript tips & tricksTypescript tips & tricks
Typescript tips & tricks
 
PHP function
PHP functionPHP function
PHP function
 
PHP 5.5.0 ChangeLog
PHP 5.5.0 ChangeLogPHP 5.5.0 ChangeLog
PHP 5.5.0 ChangeLog
 
Test in action week 2
Test in action   week 2Test in action   week 2
Test in action week 2
 
Smarter Testing With Spock
Smarter Testing With SpockSmarter Testing With Spock
Smarter Testing With Spock
 
JavaFXScript
JavaFXScriptJavaFXScript
JavaFXScript
 

Destacado

Learning Pool webinar: Engage more to learn more
Learning Pool webinar: Engage more to learn moreLearning Pool webinar: Engage more to learn more
Learning Pool webinar: Engage more to learn more
Paul McElvaney
 
090703 Sns Miyamura
090703 Sns Miyamura090703 Sns Miyamura
090703 Sns Miyamura
yuu_2003
 
15 anni, 6 aziende e tanti errori da cui imparare
15 anni, 6 aziende e tanti errori da cui imparare15 anni, 6 aziende e tanti errori da cui imparare
15 anni, 6 aziende e tanti errori da cui imparare
Marco Magnocavallo
 
U.S. IBA Program 16 Mar2009
U.S. IBA Program 16 Mar2009U.S. IBA Program 16 Mar2009
U.S. IBA Program 16 Mar2009
johncecil
 
Culto De Ferias - 12.07.07
Culto De Ferias - 12.07.07Culto De Ferias - 12.07.07
Culto De Ferias - 12.07.07
Jubrac Jacui
 
The Eastern Origins Of Western Civilization Editted
The Eastern Origins Of Western Civilization EdittedThe Eastern Origins Of Western Civilization Editted
The Eastern Origins Of Western Civilization Editted
guestecd0c6
 

Destacado (20)

Learning Pool webinar: Engage more to learn more
Learning Pool webinar: Engage more to learn moreLearning Pool webinar: Engage more to learn more
Learning Pool webinar: Engage more to learn more
 
ZFS - Zettabyte File System
ZFS - Zettabyte File SystemZFS - Zettabyte File System
ZFS - Zettabyte File System
 
Circuitos De Potencia
Circuitos De PotenciaCircuitos De Potencia
Circuitos De Potencia
 
我们的故事
我们的故事我们的故事
我们的故事
 
Adding A Link To A Flick’R Photo
Adding A Link To A Flick’R PhotoAdding A Link To A Flick’R Photo
Adding A Link To A Flick’R Photo
 
090703 Sns Miyamura
090703 Sns Miyamura090703 Sns Miyamura
090703 Sns Miyamura
 
Kevin Gallagher on Learning Pool's DLE and Authoring Tool
Kevin Gallagher on Learning Pool's DLE and Authoring ToolKevin Gallagher on Learning Pool's DLE and Authoring Tool
Kevin Gallagher on Learning Pool's DLE and Authoring Tool
 
The Mighty Gabby Embodying Resistance in the Creative Process
The Mighty Gabby Embodying Resistance in the Creative Process The Mighty Gabby Embodying Resistance in the Creative Process
The Mighty Gabby Embodying Resistance in the Creative Process
 
15 anni, 6 aziende e tanti errori da cui imparare
15 anni, 6 aziende e tanti errori da cui imparare15 anni, 6 aziende e tanti errori da cui imparare
15 anni, 6 aziende e tanti errori da cui imparare
 
Social media school 2011 webversie
Social media school 2011 webversieSocial media school 2011 webversie
Social media school 2011 webversie
 
IT User Apprenticeship at Happy Computers
IT User Apprenticeship at Happy ComputersIT User Apprenticeship at Happy Computers
IT User Apprenticeship at Happy Computers
 
Introduction to open - libre Tools and Formats
Introduction to open - libre Tools and FormatsIntroduction to open - libre Tools and Formats
Introduction to open - libre Tools and Formats
 
Bitacora personas
Bitacora personasBitacora personas
Bitacora personas
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
 
Codemotion 2012 : Sphinx: Open Source Search Server
Codemotion 2012 : Sphinx: Open Source Search ServerCodemotion 2012 : Sphinx: Open Source Search Server
Codemotion 2012 : Sphinx: Open Source Search Server
 
U.S. IBA Program 16 Mar2009
U.S. IBA Program 16 Mar2009U.S. IBA Program 16 Mar2009
U.S. IBA Program 16 Mar2009
 
Culto De Ferias - 12.07.07
Culto De Ferias - 12.07.07Culto De Ferias - 12.07.07
Culto De Ferias - 12.07.07
 
Starterslift 17 februari
Starterslift 17 februariStarterslift 17 februari
Starterslift 17 februari
 
Ъ-Видео
Ъ-ВидеоЪ-Видео
Ъ-Видео
 
The Eastern Origins Of Western Civilization Editted
The Eastern Origins Of Western Civilization EdittedThe Eastern Origins Of Western Civilization Editted
The Eastern Origins Of Western Civilization Editted
 

Similar a Lecture 17

New features and enhancement
New features and enhancementNew features and enhancement
New features and enhancement
Rakesh Madugula
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streams
Shahjahan Samoon
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLs
intelliyole
 
Here is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdfHere is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdf
pratyushraj61
 
Reading and writting
Reading and writtingReading and writting
Reading and writting
andreeamolnar
 

Similar a Lecture 17 (20)

New features and enhancement
New features and enhancementNew features and enhancement
New features and enhancement
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streams
 
5java Io
5java Io5java Io
5java Io
 
JavaExamples
JavaExamplesJavaExamples
JavaExamples
 
java input & output statements
 java input & output statements java input & output statements
java input & output statements
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLs
 
Here is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdfHere is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdf
 
Managing input and output operation in c
Managing input and output operation in cManaging input and output operation in c
Managing input and output operation in c
 
source code which create file and write into it
source code which create file and write into itsource code which create file and write into it
source code which create file and write into it
 
Java Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPRECJava Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPREC
 
Java Notes
Java Notes Java Notes
Java Notes
 
Fantom and Tales
Fantom and TalesFantom and Tales
Fantom and Tales
 
Learning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security APILearning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security API
 
Oop lecture2
Oop lecture2Oop lecture2
Oop lecture2
 
Reading and writting
Reading and writtingReading and writting
Reading and writting
 
Griffon @ Svwjug
Griffon @ SvwjugGriffon @ Svwjug
Griffon @ Svwjug
 
A la découverte de TypeScript
A la découverte de TypeScriptA la découverte de TypeScript
A la découverte de TypeScript
 
Srgoc dotnet
Srgoc dotnetSrgoc dotnet
Srgoc dotnet
 
Swtbot
SwtbotSwtbot
Swtbot
 
Flutter vs Java Graphical User Interface Frameworks.pptx
Flutter vs Java Graphical User Interface Frameworks.pptx Flutter vs Java Graphical User Interface Frameworks.pptx
Flutter vs Java Graphical User Interface Frameworks.pptx
 

Más de Debasish Pratihari (19)

Lecture 24
Lecture 24Lecture 24
Lecture 24
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
 
Lecture 21
Lecture 21Lecture 21
Lecture 21
 
Lecture 20
Lecture 20Lecture 20
Lecture 20
 
Lecture 19
Lecture 19Lecture 19
Lecture 19
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Lecture 16
Lecture 16Lecture 16
Lecture 16
 
Lecture 14
Lecture 14Lecture 14
Lecture 14
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Lecture25
Lecture25Lecture25
Lecture25
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

Lecture 17

  • 1. Core Java 1 Debasish Pratihari Setting Fonts Example : import java.awt.*; class FontDemo extends Frame{ Label label; Font font; FontDemo(){ super("FontDemo By Debasish Pratihari"); label= new Label("Welcome to Lakshya"); setLayout(new FlowLayout()); // Font Setting for Output-2 font=new Font("Arial",Font.BOLD,20); // Font Setting for Output-3 //font=new Font("Arial",Font.BOLD+Font.ITALIC,30); label.setFont(font); add(label); pack(); setVisible(true); } public static void main(String args[]){ new FontDemo(); } } Output 1: Output 2: Output 3: Lecture/core/awt5/17 Page #1 feel the Technology…
  • 2. Core Java Debasish Pratihari Setting Cursors for Components Example import java.awt.*; class CursorDemo extends Frame{ Button button; Cursor cursor; CursorDemo(){ super("FontDemo By Debasish Pratihari"); button= new Button("Click Me"); setLayout(new FlowLayout()); cursor= new Cursor(Cursor.HAND_CURSOR); button.setCursor(cursor); add(button); pack(); setVisible(true); } public static void main(String args[]){ new CursorDemo(); } } ToolKit Object :  This object represents the environment on your computer so it encapsulate all the properties and capabilities of that environment , including screen size and resolution.  To Obtain toolkit object: o o ToolKit toolkit = ToolKit.getDefaultToolKit(); Frame f= new Frame(); ToolKit toolkit=f.getToolKit(); Lecture/core/awt5/17 Page #2 feel the Technology…
  • 3. Core Java Debasish Pratihari GraphicsEnvironment:  This object contains information about graphics device attached to the system.  the To Obtain GraphicsEnvironment Object : GraphicsEnvironment graphics= GraphicsEnvironment.getLocalGraphicsEnvironment(); Steps to create Menu :          create a Menu Bar create required Menus create Menu Items for all the menus make the Menu items event sensitive provide the event handlers for Menu items add the menu items into the corresponding Menus. add menus to the menu bar or incase of sub-menu add the menu to the corresponding main-menu. add the menu bar to the container Example of Menu: Lecture/core/awt5/17 Page #3 feel the Technology…
  • 4. Core Java Debasish Pratihari Code Example : import java.awt.*; import java.awt.event.*; public class MenuDemo extends Frame{ Label label; MenuBar mb; Menu col,ft,fname,style; MenuItem red,green,blue,font1,font2,font3; MenuShortcut ms; Font font; CheckboxMenuItem style1,style2,style3; public MenuDemo(){ label=new Label("Welcome to Lakshya"); mb = new MenuBar(); col = new Menu("Color"); add(label); ms=new MenuShortcut(KeyEvent.VK_R); red=new MenuItem("Red",ms); green=new MenuItem("Green",new MenuShortcut(KeyEvent.VK_R,true)); blue=new MenuItem("Blue"); col.add(red); col.add(green); col.add(blue); ft = new Menu("Font"); fname= new Menu("Name"); font1=new MenuItem("Arial"); font2=new MenuItem("Verdana"); font3=new MenuItem("Garamond"); style= new Menu("Style"); style1= new CheckboxMenuItem("Bold"); style2= new CheckboxMenuItem("Italic"); style3= new CheckboxMenuItem("Underline"); fname.add(font1); fname.add(font2); fname.add(font3); style.add(style1); style.add(style2); style.add(style3); ft.add(fname); ft.add(style); mb.add(col); mb.add(ft); add(back); setMenuBar(mb); setTitle("MenuDemo By Debasish Pratihari"); setSize(300,200); setVisible(true); } public static void main(String args[]){ new MenuDemo(); } } Lecture/core/awt5/17 Page #4 feel the Technology…