Tag: BIM
Unit 5: Counters
Counter A counter by function is a sequential circuit consisting a set of flip-flops connected in a suitable manner to count the sequence of the i/p pulses presented to it in digital form. Counters are fundamental components of digital system. Digital counters find wide application like pulse counting, frequency division, time measurement and control and timing operations. There […]
Continue ReadingUnit 4: Using AWT controls, Layout Managers, and Menus
4.2.1Label The object of Label class is a component for placing text in a container. It is used to display a single line of read only text. The text can be changed by an application but a user cannot edit it directly. Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import java.awt.*; class LabelExample{ public static void main(String args[]){ Frame f= new Frame("Label Example"); Label l1,l2; l1=new Label("First Label."); l1.setBounds(50,100, 100,30); l2=new Label("Second Label."); l2.setBounds(50,150, 100,30); f.add(l1); f.add(l2); f.setSize(400,400); f.setLayout(null); f.setVisible(true); } } |
output:- Button The button class is used to create a labeled button that […]
Continue ReadingUnit 1: The Applet Class
Applet Applets are small Java applications that can be accessed on an Internet server, transported over Internet, and can be automatically installed and run as apart of a web document. After a user receives an applet, the applet can produce a graphical user interface. It has limited access to resources so that it can run […]
Continue ReadingUnit 2: Even handling
Event Handling Any program that uses GUI (graphical user interface) such as Java application written for windows, is event driven. Event describes the change in state of any object. For Example : Pressing a button, Entering a character in Textbox, Clicking or Dragging a mouse, etc. Components of Event Handling Event handling has three main components, Events […]
Continue ReadingUnit 6: Exploring Swing
6.2 JTextField JTextField is used for taking input of single line of text. It is most widely used text component. It has three constructors,
1 2 3 |
JTextField(int cols) JTextField(String str, int cols) JTextField(String str) |
xample using JTextField
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import javax.swing.*; import java.awt.event.*; import java.awt.*; public class MyTextField extends JFrame { public MyTextField() { JTextField jtf = new JTextField(20); //creating JTextField. add(jtf); //adding JTextField to frame. setLayout(new FlowLayout()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(400, 400); setVisible(true); } public static void main(String[] args) { new MyTextField(); } } |
6.3 JButton JButton class provides functionality of a button. JButton class has three constuctors,
1 2 3 |
JButton(Icon ic) JButton(String str) JButton(String str, Icon ic) |
It allows a button to be created using icon, a string or […]
Continue Reading