42. an example of creating menu inside the main window –

import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class menu extends Applet implements ActionListener {                 Button b1;                 frame menuWindow;                 public void init()                 {                                 b1=new Button("Display the menu window");                                 add(b1);                                 b1.addActionListener(this);                                 menuWindow=new frame("Menus");                                 menuWindow.setSize(200,200);                 }                 public void actionPerformed(ActionEvent event)                 {                                 if(event.getSource()==b1)                                 {                                                 … Continue reading 42. an example of creating menu inside the main window –

Advertisements

41. an example in which we handle mouse event in the frame window adopted over the previous window by the implementing the methods in the MouseListener interface and display what the mouse is doing with the message in the label in that window.

import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class Frames extends Applet implements ActionListener {                 Button b1,b2;                 labelFrame window;                 public void init()                 {                                 b1=new Button("Display the window");                                 add(b1);                                 b1.addActionListener(this);                                 b2=new Button("Hide the window");                                 add(b2);                                 b2.addActionListener(this);                                 window=new labelFrame("Java window");                                 window.setSize(400,300);                 }                 public void … Continue reading 41. an example in which we handle mouse event in the frame window adopted over the previous window by the implementing the methods in the MouseListener interface and display what the mouse is doing with the message in the label in that window.

40. An example of a java program for font class –

import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class Fonts extends Applet implements ActionListener,KeyListener {                 String text="";                 Button boldbutton,italicbutton,largebutton;                 boolean bold=false;                 boolean italic=false;                 boolean large=false;                 public void init()                 {                                 boldbutton=new Button("Bold Font");                                 italicbutton=new Button("Italic Font");                                 largebutton=new Button("Large Font");                                 boldbutton.addActionListener(this);                                 italicbutton.addActionListener(this);                                 largebutton.addActionListener(this);                                 add(boldbutton); … Continue reading 40. An example of a java program for font class –

39. An example for creating window –

import java.awt.Color; import java.awt.Component; import java.awt.Frame; import java.awt.Graphics; import java.awt.image.VolatileImage; public class Windows extends Component {                 public VolatileImage buffer=null;                 void createBackBuffer()                 {                                 if(buffer!=null)                                 {                                                 buffer.flush();                                                 buffer=null;                                 }                                 buffer=createVolatileImage(getWidth(),getHeight());                 }                 public void paint(Graphics g)                 {                                 if(buffer==null)                                 {                                                 createBackBuffer();                                 }                                 … Continue reading 39. An example for creating window –

38. An example of applet with three button and text button with the scroll bar –

import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class MButton extends Applet implements FocusListener,MouseWheelListener {                 TextArea text1;                 Button button1,button2,button3;                 public void init()                 {                                 text1=new TextArea("",8,18);                                 add(text1);                                 button1=new Button("Press Tab1!");                                 button2=new Button("Press Tab2!");                                 button3=new Button("Press Tab3!");                                 add(button1);                                 add(button2);                                 add(button3);                                 button1.addFocusListener(this);                                 button2.addFocusListener(this);                                 button3.addFocusListener(this); … Continue reading 38. An example of applet with three button and text button with the scroll bar –

Drawing graphics: –

Drawing graphics: - The user can draw lines, rectangles, ovals and other free hand drawing using the mouse. The real care of awt graphics is the hug awt graphic class, which is derived directly from java.lang.object. Drawing free hand drawing with the mouse is a little different. In that case, we store up to one … Continue reading Drawing graphics: –

Design image: –

Design image: - User can design image using java applet. We can use java image to display it on the screen. Java image is supported by the image class. Images are manipulated using the classes found in the java.awt.image package. To read in the image, we use get image method. To draw the image using … Continue reading Design image: –

Menu item object: –

Menu item object: - Java provide to create new menu and add menu item inside the menu. Adding menu item is not so hard but it can be used only when MenuItem class added in Applet programming. Each menu item we add to an AWT menu is actually an object of the MenuItem class. To … Continue reading Menu item object: –

Creating menus: –

Creating menus: - Inside the window, user can create menus. We can add AWT menus to frame class windows using three AWT classes such as menu bar, menu and menu item. The first class we use is the menu bar class, which adds a menu bar to a frame window. After we have added a … Continue reading Creating menus: –

Creating frame window: –

Creating frame window: - The frame window used in java for creating a new window inside the main window just as we can handle them anywhere by implementing the method of listener interface. Here is an example in which we handle mouse event in the frame window adopted over the previous window by the implementing … Continue reading Creating frame window: –