Program:
import java.awt.*;
import java.awt.event.*;
class cs extends Canvas
{
public void paint(Graphics g)
{
Toolkit t=getToolkit();
Image img=t.getImage("/home/nn/Desktop/1.jpg");
setSize(500,500);
g.drawImage(img, 0,0, this);
}
}
class ex10 extends Frame
{
cs t;
ScrollPane sp;
ex10()
{
super("Image Example");
setLayout(null);
setSize(500,500);
setVisible(true);
t=new cs();
sp=new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
sp.add(t);
add(sp);
sp.setBounds(50,50,300,300);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
}
public static void main(String s[])
{
ex10 ob=new ex10();
}
}
Output:
nn@linuxmint ~/Desktop/java 7 $ javac ex10.java
nn@linuxmint ~/Desktop/java 7 $ java ex10
nn@linuxmint ~/Desktop/java 7 $
import java.awt.*;
import java.awt.event.*;
class cs extends Canvas
{
public void paint(Graphics g)
{
Toolkit t=getToolkit();
Image img=t.getImage("/home/nn/Desktop/1.jpg");
setSize(500,500);
g.drawImage(img, 0,0, this);
}
}
class ex10 extends Frame
{
cs t;
ScrollPane sp;
ex10()
{
super("Image Example");
setLayout(null);
setSize(500,500);
setVisible(true);
t=new cs();
sp=new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
sp.add(t);
add(sp);
sp.setBounds(50,50,300,300);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
}
public static void main(String s[])
{
ex10 ob=new ex10();
}
}
Output:
nn@linuxmint ~/Desktop/java 7 $ javac ex10.java
nn@linuxmint ~/Desktop/java 7 $ java ex10
nn@linuxmint ~/Desktop/java 7 $
Hi,Placement of text and graphics is usually a simple drop and place and adjust technique with Web Design Cochin the mouse. It is somewhat like creating a scrapbook page and that may have been the origin of initial website design efforts.Thanks...............
ReplyDelete