SlideShare a Scribd company logo
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…

More Related Content

PDF
Building Testable PHP Applications
PPT
Groovy Introduction - JAX Germany - 2008
PPSX
NOTEPAD MAKING IN PAYTHON BY ROHIT MALAV
KEY
Workshop unittesting
PPTX
Python Programming Essentials - M8 - String Methods
PDF
Coding Guidelines - Crafting Clean Code
PDF
ScalaFlavor4J
Building Testable PHP Applications
Groovy Introduction - JAX Germany - 2008
NOTEPAD MAKING IN PAYTHON BY ROHIT MALAV
Workshop unittesting
Python Programming Essentials - M8 - String Methods
Coding Guidelines - Crafting Clean Code
ScalaFlavor4J

What's hot (8)

PDF
[NHN NEXT] Java 강의 - Week1
PPTX
03 standard class library
PPTX
Typescript tips & tricks
PPTX
PHP function
PPTX
PHP 5.5.0 ChangeLog
PPTX
Test in action week 2
PPTX
Smarter Testing With Spock
ODP
JavaFXScript
[NHN NEXT] Java 강의 - Week1
03 standard class library
Typescript tips & tricks
PHP function
PHP 5.5.0 ChangeLog
Test in action week 2
Smarter Testing With Spock
JavaFXScript
Ad

Viewers also liked (20)

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

Similar to Lecture 17 (20)

PPT
New features and enhancement
PPTX
Understanding java streams
PDF
5java Io
DOCX
JavaExamples
PPTX
interface in java explained in detailed form
PPT
Appletsbjhbjiibibibikbibibjibjbibbjb.ppt
PPT
Applets(1)cusdhsiohisdhfshihfsihfohf.ppt
PPTX
java input & output statements
PPT
Smoothing Your Java with DSLs
PDF
Here is my code for a linefile editor import java.io.BufferedRea.pdf
PPTX
Managing input and output operation in c
PPTX
Input Output function in c programing language.pptx
DOCX
source code which create file and write into it
PPTX
Java Notes
PPTX
Java Notes by C. Sreedhar, GPREC
PPT
Fantom and Tales
PPT
Learning Java 4 – Swing, SQL, and Security API
PPT
Oop lecture2
PPTX
Reading and writting
PPTX
javaprogramming framework-ppt frame.pptx
New features and enhancement
Understanding java streams
5java Io
JavaExamples
interface in java explained in detailed form
Appletsbjhbjiibibibikbibibjibjbibbjb.ppt
Applets(1)cusdhsiohisdhfshihfsihfohf.ppt
java input & output statements
Smoothing Your Java with DSLs
Here is my code for a linefile editor import java.io.BufferedRea.pdf
Managing input and output operation in c
Input Output function in c programing language.pptx
source code which create file and write into it
Java Notes
Java Notes by C. Sreedhar, GPREC
Fantom and Tales
Learning Java 4 – Swing, SQL, and Security API
Oop lecture2
Reading and writting
javaprogramming framework-ppt frame.pptx

More from Debasish Pratihari (19)

PDF
Lecture 24
PDF
Lecture 22
PDF
Lecture 21
PDF
Lecture 20
PDF
Lecture 19
PDF
Lecture 18
PDF
Lecture 16
PDF
Lecture 14
PDF
Lecture 10
PDF
PDF
PDF
PDF
PDF
PDF
PDF
PDF
PDF
PDF

Recently uploaded (20)

PDF
Getting Started with Data Integration: FME Form 101
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Machine learning based COVID-19 study performance prediction
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
Machine Learning_overview_presentation.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Approach and Philosophy of On baking technology
PPTX
1. Introduction to Computer Programming.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Encapsulation_ Review paper, used for researhc scholars
Getting Started with Data Integration: FME Form 101
Reach Out and Touch Someone: Haptics and Empathic Computing
NewMind AI Weekly Chronicles - August'25-Week II
Machine learning based COVID-19 study performance prediction
Advanced methodologies resolving dimensionality complications for autism neur...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Machine Learning_overview_presentation.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
TLE Review Electricity (Electricity).pptx
Approach and Philosophy of On baking technology
1. Introduction to Computer Programming.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Programs and apps: productivity, graphics, security and other tools
Assigned Numbers - 2025 - Bluetooth® Document
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Encapsulation_ Review paper, used for researhc scholars

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…