/***************************************************************
NAME :
CLASS : T.Y.B.Sc(Comp.Sci.)
ROLL NO. :
Write a Java program to display “Hello 2D Graphics” using various fonts and sizes.
***************************************************************/
import java.awt.*;
import javax.swing.*;
class seta1 extends JFrame
{
seta1()
{
setVisible(true);
setSize(500,500);
setTitle("Hello Graphics");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void paint(Graphics g)
{
g.setFont(new Font("Arial",Font.BOLD,40));
g.drawString("Hello 2D Graphics",20,70);
g.setFont(new Font("Times new roman",Font.ITALIC,50));
g.drawString("Hello 2D Graphics",20,200);
g.setFont(new Font("Times new roman",Font.PLAIN,50));
g.drawString("Hello 2D Graphics",20,350);
}
public static void main(String a[])
{
new seta1();
}
}
**********************************************************************************
/***************************************************************
NAME :
CLASS : T.Y.B.Sc(Comp.Sci.)
ROLL NO. :
Write a program to list all machine fonts and their font metrics.
***************************************************************/
import java.awt.*;
import javax.swing.*;
class seta2 extends JFrame
{
seta2()
{
setVisible(true);
setTitle("font family");
setSize(500,500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void paint(Graphics g)
{
GraphicsEnvironment g1= GraphicsEnvironment.getLocalGraphicsEnvironment();
String s[]=g1.getAvailableFontFamilyNames();
FontMetrics fm=g.getFontMetrics();
int x=fm.getHeight();
Font f=fm.getFont();
g.drawString("height="+x+"font="+f.getFontName(),10,40);
int y=50;
for(int i=0;i<s.length;i++)
{
g.drawString(s[i],10,y);
y=y+15;
}
}
public static void main(String a[])
{
new seta2();
}
}
************************************************************************************
/***************************************************************
NAME :
CLASS : T.Y.B.Sc(Comp.Sci.)
ROLL NO. :
Write a Java program to obtain the information of the current font used by the graphics object and displays the information about that font on a screen. ***************************************************************/
import java.awt.*;
import javax.swing.*;
class seta3 extends JFrame
{
seta3()
{
setVisible(true);
setTitle("font family");
setSize(500,500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void paint(Graphics g)
{
Font f=g.getFont();
g.setFont(new Font("Arial",Font.PLAIN,20));
g.drawString("font name="+f.getFontName(),30,50);
g.drawString("font size="+f.getSize(),20,70);
g.drawString("font family="+f.getFamily(),20,90);
g.drawString("font style="+f.getStyle(),20,200);
g.drawString("font logical name="+f.getName(),20,400);
}
public static void main(String a[])
{
new seta3();
}
}
**********************************************************************************
/***************************************************************
NAME :
CLASS : T.Y.B.Sc(Comp.Sci.)
ROLL NO. :
Write a program to accept the name of an image (using file open dialog) and display it on a panel such that it occupies the whole panel area. ***************************************************************/
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import javax.imageio.*;
class seta4 extends JFrame implements ActionListener
{
JPanel p=new JPanel();
JButton b=new JButton("open");
Image img; //object image
int a=1;
seta4()
{
setLayout(new FlowLayout());
add(b);
add(p);
b.addActionListener(this);
setVisible(true);
setTitle("font family");
setSize(500,500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e)
{
try
{
FileDialog f=new FileDialog(this,"open");
f.setVisible(true);
System.out.println("name="+f.getDirectory()+""+f.getFile());
img=ImageIO.read(new File(f.getDirectory()+f.getFile()));
repaint();
}
catch(Exception e1)
{
System.out.println("error="+e1);
}
}
public void paint(Graphics g)
{
if(a==1);
g.drawImage(img,20,20,null);
}
public static void main(String a[])
{
new seta4();
}
}
************************************************************************************
/***************************************************************
NAME :
CLASS : T.Y.B.Sc(Comp.Sci.)
ROLL NO. :
Write a Java program to draw the following graphics:
***************************************************************/
import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;
class setb1 extends JFrame
{
setb1()
{
setVisible(true);
setTitle("font family");
setSize(500,500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void paint(Graphics g)
{
int x[]={110,150,75};
int y[]={30,75,75};
g.drawPolygon(x,y,3);
g.drawOval(100,50,20,20);
g.drawRect(75,75,75,100);
g.drawRect(95,120,30,55);
g.drawRect(210,65,47,55);
g.drawRect(210,120,150,55);
g.drawOval(220,175,20,25);
g.drawOval(300,175,20,25);
}
public static void main(String a[])
{
new setb1();
}
}
Pure Titanium Earrings
ReplyDeleteYou will titanium quartz meaning find titanium iv chloride a beautiful necklace at our store today. A beautiful earrings titanium price per pound with a bright blue beards. The Ring of anodizing titanium Gold tube supplier is the most important of all jewelry.