Posts

Showing posts with the label awt

AWT Program to display the given input on button click

Image
This is a program which will accept the input from the keyboard and on clicking the button, it will show the given input. This program is compiled in Eclipse. This is a basic program in Java using AWT where a single TextField, Label and a Button is used. Screenshot The Code: package dProBuk; import java.awt.Button; import java.awt.Frame; import java.awt.GridLayout; import java.awt.Label; import java.awt.TextField; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; public class SimpleLayoutAWT implements ActionListener { TextField t; Label l; Button b; public SimpleLayoutAWT() { // TODO Auto-generated constructor stub Frame f=new Frame("Simple Frame"); t=new TextField("Enter the Name"); l=new Label(""); b=new Button("Show !"); f.setLayout(new GridLayout(3,1)); f.setVisible(true); f.setSize(500,200); f.add(t); f.add(b); ...

Creating a Calculator panel using AWT in Java

Image
The Real power of java comes into the picture in AWT and Applet in java. We can create a popup window and program it according to our use, just like real life applications in the computers. It is a simple design of a calculator using AWT and Swing. Screenshots: Calculator panel in ubuntu Calculator panel in Windows The Code: import java.util.*; import java.awt.*; import javax.swing.*; class calculator extends Frame { Panel number,text_box,operation,buttons; JFrame cal; /*Creating and object for JFrame*/ /*Creating Buttons and TextBox reference variables*/ Button one,two,three,four,five,six,seven,eight,nine,zero,dot,plus,minus,mul,div,percentage,factorial,log,Ln,brac1,brac2; TextField box; public calculator() { /*Configuring frame of the window and Heading, Layout, close button action*/ cal = new JFrame(); cal.setTitle("CALCULATOR"); /*Title of the window*/ cal.setSize(500,500); /*size of the window in pixels*/ cal.setLayout(new F...