Week -1. Try debug step by step with small program of about 10 to 15 lines which contains at least one if else condition and a for loop.
|
|
- Preston Evans
- 5 years ago
- Views:
Transcription
1 Week -1 Try debug step by step with small program of about 10 to 15 lines which contains at least one if else condition and a for loop. Java Code import java.util.scanner; public class TestPrime public static void main(string[] args) Scanner sc = new Scanner(System.in); System.out.println("Enter valid Number"); int n = sc.nextint(); int c = 0; for (int i = 1; i <= n; i++) if (n % i == 0) c++;
2 if (c == 2) System.out.println(n + "is Prime Number"); else System.out.println(n + "is not Prime Number"); Week - 2 Write a Java program that works as a simple calculator. Use a grid layout to arrange buttons for the digits and for the + * % operations. Add a text field to display the result. Handle any possible exceptions like divide by zero Java Code import java.awt.*; import java.awt.event.*; import java.applet.*; import javax.swing.*; /*
3 <applet code="cal" width=300 height=300> </applet> */ public class Cal extends JFrame implements ActionListener String msg=" "; int v1,v2,result; JTextField t1,t2; JButton b; boolean start = true; char OP; Cal() t1=new JTextField(25); t2=new JTextField(25); t1.seteditable(false); //setlayout(new BorderLayout());
4 add(t1, BorderLayout.NORTH); JPanel p = new JPanel(); p.setlayout(new GridLayout(4, 4)); String buttons = "789* /c="; for (int i = 0; i < buttons.length(); i++) b = new JButton(buttons.substring(i, i + 1)); b.addactionlistener(this); p.add(b); add(p, BorderLayout.CENTER); setsize(400,400); setvisible(true);
5 setdefaultcloseoperation(jframe.exit_on_close); public void actionperformed(actionevent ae) String str=ae.getactioncommand(); System.out.println("str="+str); char ch=str.charat(0); if ( Character.isDigit(ch)) if(start == true) t1.settext(str); else t1.settext(t1.gettext()+str);
6 start = false; else if(str.equals("+")) v1=integer.parseint(t1.gettext()); OP='+'; start = true; else if(str.equals("-")) v1=integer.parseint(t1.gettext()); OP='-'; start = true;
7 else if(str.equals("*")) v1=integer.parseint(t1.gettext()); OP='*'; start = true; else if(str.equals("/")) v1=integer.parseint(t1.gettext()); OP='/'; start = true; else if(str.equals("c")) t1.settext("");
8 else if(str.equals("=")) v2=integer.parseint(t1.gettext()); if(op=='+') result=v1+v2; else if(op=='-') result=v1-v2; else if(op=='*') result=v1*v2; else if(op=='/') try
9 result=v1/v2; catch(arithmeticexception e) JOptionPane.showMessageDialog(null,"Should not divide by 0"); t1.settext(""+result); start = true; public static void main(string args[ ])
10 Cal c =new Cal(); Output: Week-3(a) Develop an applet in java that displays a simple message Java Code import java.applet.*; import java.awt.*;
11 /* <applet code="simpleapplet" height=300 width=300> </applet> */ public class SimpleApplet extends Applet public void paint(graphics g) g.setcolor(color.pink); setbackground(color.yellow); g.drawstring("hi APPLET Program",80,150);
12 Output:
13 Week - 3(b) Develop an applet in java that receives an integer in one text field, and computes its factorial value and returns it in another text field, when the button named compute is clicked. Java Code import java.applet.*; import java.awt.*; import java.awt.event.*; /**<applet code=fact width=500 height=500> </applet>*/ public class Fact extends Applet implements ActionListener
14 Button b1,b2; Label l1,l2; TextField t1,t2; public void init() l1=new Label("NUMBER"); t1=new TextField(20); l2=new Label("RESULT"); t2=new TextField(20); b1=new Button("COMPUTE"); b1.addactionlistener(this); b2=new Button("CLEAR"); b2.addactionlistener(this);
15 add(l1); add(t1); add(l2); add(t2); add(b1); add(b2); public void actionperformed(actionevent e) if(e.getsource()==b1) int n=integer.parseint(t1.gettext()); int fact=1; for(int i=1;i<=n;i++) fact*=i; t2.settext(integer.tostring(fact)); else if(e.getsource()==b2)
16 t1.settext(""); t2.settext(""); Output:
17 Week- 4 Write a program that creates a user interface to perform integer divisions. The user enters two numbers in the textfields, Num1 and Num2. The division of Num1 and Num2 is displayed in the Result field when the Divide button is clicked. If Num1 or Num2 were not an integer, the program would throw a NumberFormatException. If Num2 were Zero, the program would throw an ArithmeticException Display the exception in a message dialog box. Java Code import java.applet.*;
18 import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Division extends JFrame implements ActionListener JButton b1,b2; JLabel l1,l2,l3; JTextField tf1,tf2,tf3; Division() l1=new JLabel("Enter the Numerator"); tf1=new JTextField(15); l2=new JLabel("Enter the Denaminator"); tf2=new JTextField(15); b1=new JButton("DIVIDE"); b1.addactionlistener(this);
19 l3=new JLabel("RESULT"); tf3=new JTextField(15); setlayout(new FlowLayout()); add(l1); add(tf1); add(l2); add(tf2); add(l3); add(tf3); add(b1); setsize(400,400); setvisible(true); setdefaultcloseoperation(jframe.exit_on_close);
20 public void actionperformed(actionevent e) if(e.getsource()==b1) try int num1=integer.parseint(tf1.gettext()); int num2=integer.parseint(tf2.gettext()); int result=num1/num2; tf3.settext(integer.tostring(result)); catch(arithmeticexception ex) JOptionPane.showMessageDialog(null, "ArithmeticException: divide by zero"); catch(numberformatexception ex)
21 JOptionPane.showMessageDialog(this,"NumberFormatExc eption"); public static void main(string args[]) Division b=new Division(); Output:
22
23 Week- 5 Write Java Program that implements a multithread application that has three threads. First Thread generates random integer for every second and if the value is even, second thread computes The square of number and prints. If the value is odd, the third thread will print the value of cube of number. Java Code import java.util.*; class even implements Runnable public int x; even(int x) this.x = x;
24 public void run() + x + "is System.out.println("Threa Name: Even Thread and " even Number and Square of " + x +" is: " + x * x); class odd implements Runnable public int x; public odd(int x) this.x = x; public void run()
25 + x + " is System.out.println("Thread Name:ODD Thread and " odd number and Cube of " + x + "is: " + x * x * x); class A extends Thread String tname; Thread t1, t2; public void run() int num = 0; Random r = new Random(); try for (int i = 0; i < 5; i++)
26 num = r.nextint(20); System.out.println("Main Thread and Generated Number is " + num); if (num % 2 == 0) else t1 = new Thread(new even(num)); t1.start(); t2 = new Thread(new odd(num)); t2.start(); Thread.sleep(1000); "); System.out.println(" catch (Exception ex)
27 System.out.println(ex.getMessage()); public class MultiThread public static void main(string[] args) A a = new A(); a.start(); Output:
28
29 Week-6 Write a java program that connects to a database using JDBC and does add, delete, modify and retrieve operations Java Code import java.sql.*; class DBOperations public static void main(string args[])throws Exception Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=drivermanager.getconnection("jdbc:oracle:thin:@localhos t:1521:xe","system","cmrec"); Statement stmt=con.createstatement(); // insert data into emp1 table stmt.executeupdate("insert into emp1 values(33,'sita')"); stmt.executeupdate("insert into emp1 values(34,'gita')"); stmt.executeupdate("insert into emp1 values(35,'rita')");
30 // update emp1 table int result=stmt.executeupdate("update emp1 set ename='mala' where eno=33"); System.out.println(result+"records updated"); //delete from emp1 table result=stmt.executeupdate("delete from emp1 where eno=33"); System.out.println(result+"records deleted"); //retrieving from emp1 table ResultSet rs = stmt.executequery("select * from emp1"); while(rs.next()) System.out.println(rs.getInt(1)+" \t "+rs.getstring(2)); con.close(); Output:
31 Week - 7 Write a java program that simulates a traffic light. The program lets the user select one of three lights: red, yellow, or green with radio buttons. On selecting a button, an
32 appropriate message with stop or ready or go should appear above the buttons in selected color. Initially there is no message shown. Java Code import java.awt.*; import java.awt.event.*; import java.applet.*; import javax.swing.*; /*<applet code="radiotraffic.class" width=400 height=400></applet>*/ public class RadioTraffic extends Applet implements ActionListener int colournum; ButtonGroup bg; JRadioButton red, yellow,green;
33 String msg=" "; public void init () bg=new ButtonGroup(); red=new JRadioButton("RED"); yellow=new JRadioButton("YELLOW"); green=new JRadioButton("GREEN"); bg.add(red); bg.add(yellow); bg.add(green); add(red); add(yellow);
34 add(green); red.addactionlistener(this); yellow.addactionlistener(this); green.addactionlistener(this); public void actionperformed(actionevent ie) if (red.isselected()) colournum = 1; else if (yellow.isselected()) colournum = 2; else colournum = 3; repaint ();
35 public void paint (Graphics g) // responsible for graphics "within" the window g.setcolor(color.black); g.filloval (150, 70, 50, 50); // red light g.filloval (150, 150, 50, 50); // yellow light g.filloval (150, 230, 50, 50); // green light switch (colournum) case 1:g.setColor (Color.red); g.filloval (150,70,50,50); // red light msg="stop"; g.drawstring(msg,210,100); break; case 2:g.setColor(Color.yellow); g.filloval (150,150,50,50); // yellow light
36 msg="ready"; g.drawstring(msg,210,180); break; case 3:g.setColor(Color.green); g.filloval (150,230,50,50); // green light msg="go"; g.drawstring(msg,210,260); break; Output:
37 Week-8 Write a java program to create an abstract class named Shape that contains two integers and an empty method named printarea(). Provide three classes named Rectangle, Triangle, and Cirlce such that each one of the classes extends the class Shape. Each one of the classes contains only the method printarea() that prints the area of the given shape. Java Code abstract class Shape
38 int len,bre; abstract void printarea(); class Rectangle extends Shape int hei; Rectangle(int l,int b,int h) len=l; bre=b; hei=h; void printarea() System.out.println("area of rectangle"+len*bre*hei);
39 class Triangle extends Shape Triangle(int l,int b) len=l; bre=b; void printarea() System.out.println("area of triangle"+0.5*len*bre); class Circle extends Shape Circle(int r) len=r;
40 void printarea() System.out.println("area of circle"+3.14*len*len); class ShapeDemo public static void main(string args[]) Rectangle r=new Rectangle(2,3,6); Triangle t=new Triangle(4,6); Circle c=new Circle(2); Shape d; d=r; d.printarea(); d=t; d.printarea(); d=c;
41 d.printarea(); Output: Week -9 Suppose that a table named Table.txt is stored in a text file. The First line in the file is the header, and the remaining lines correspond rows in table. The elements are separated by commas.
42 Write java program to display the table using Label in Grid Layout. Java Code import java.io.*; import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; class Display extends JFrame public Display() GridLayout g = new GridLayout(0, 3); setlayout(g); try BufferedReader br = new BufferedReader(new FileReader("emp.txt"));
43 String line; while ((line = br.readline())!= null) String datavalue[] = line.split(","); for (int i = 0; i< datavalue.length;i++) add(new JLabel(datavalue[i])); catch (Exception e) System.out.println(e); setsize(400, 400); setvisible(true);
44 setdefaultcloseoperation(jframe.exit_on_close); public class Tbl public static void main(string[] args) Display d = new Display(); Input:
45 Output:
46 Week - 10 Write a java program that handles all mouse events and shows the event name at the center of the window when a mouse event is fired. Java Code import java.awt.*; import java.awt.event.*; import java.applet.*; /* <applet code="mouseevents" width=300 height=100> </applet> */ public class MouseEvents extends Applet implements MouseListener, MouseMotionListener String msg = ""; int mousex = 0, mousey = 0; // coordinates of mouse public void init()
47 addmouselistener(this); addmousemotionlistener(this); // Handle mouseclick event public void mouseclicked(mouseevent me) mousex = 0; mousey = 10; msg = "Mouse clicked."; repaint(); // Handle mouse entered event. public void mouseentered(mouseevent me) mousex = 0;
48 mousey = 10; msg = "Mouse entered."; repaint(); // Handle mouse exit event public void mouseexited(mouseevent me) mousex = 0; mousey = 10; msg = "Mouse exited."; repaint(); // Handle mouse pressed. public void mousepressed(mouseevent me) mousex = me.getx(); mousey = me.gety(); msg = "Down";
49 repaint(); // Handle mouse released. public void mousereleased(mouseevent me) mousex = me.getx(); mousey = me.gety(); msg = "Up"; repaint(); // Handle mouse dragged. public void mousedragged(mouseevent me) mousex = me.getx(); mousey = me.gety(); msg = "*"; showstatus("dragging mouse at " + mousex + ", " + mousey); repaint();
50 // Handle mouse moved. public void mousemoved(mouseevent me) showstatus("moving mouse at " + me.getx() + ", " + me.gety()); // Display msg in applet window at current X,Y location. public void paint(graphics g) Output: g.drawstring(msg, mousex, mousey);
51 Week-11 Write a java program that loads names and phone numbers from a text file where the data is organized as one line per record and each field in a record are separated by a tab(\t). It takes a name or phone number as input and prints the corresponding other value from the hash table ( hint : use Hashtable)
52 Java Code import java.util.*; import java.io.*; class PhoneFromText public static void main(string args[]) throws Exception BufferedReader br = new BufferedReader(new FileReader("phoneno.txt")); Scanner sc=new Scanner(System.in); Hashtable<String,String> hs= new Hashtable<String,String> (); String line; while ((line = br.readline())!= null) String datavalue[] = line.split("\t"); String value1 = datavalue[0]; String value2 = datavalue[1];
53 hs.put(value1,value2); System.out.println("Names of phone directory are :"); Enumeration e = hs.keys(); while(e.hasmoreelements()) System.out.println(e.nextElement()); System.out.print("Enter any name:"); String name = sc.next(); name.trim(); System.out.println(name +" " + "phone no=" + hs.get(name)); Input: br.close();
54 Output: Week -12 implement week -11 program with database instead of text file Java Code import java.util.*; import java.sql.*; import java.io.*; class PhoneFromDatabase
55 public static void main(string args[]) try Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=drivermanager.getconnection( Statement stmt=con.createstatement(); phone"); ResultSet rs=stmt.executequery("select * from Hashtable<String,String> hs= new Hashtable<String,String> (); while(rs.next()) String value1 = rs.getstring(1); String value2 = rs.getstring(2); hs.put(value1,value2);
56 //System.out.println(rs.getString(1)+" "+rs.getstring(2)); System.out.println("Names of phone directory are :"); Enumeration e = hs.keys(); while(e.hasmoreelements()) System.out.println(e.nextElement()); Scanner sc = new Scanner(System.in); System.out.print("enter any name:"); String name = sc.next(); name.trim(); System.out.println(name +" " + "phone no="+hs.get(name)); con.close(); catch(exception e)
57 System.out.println(e); Output:
58
59 Week - 13 Write a java program that takes tab seperated data from (one record per line) from a text file and inserts them into database Java Code import java.sql.*; import java.io.*; class TabSeperatedDatabase public static void main(string args[]) try Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=drivermanager.getconnection( "jdbc:oracle:thin:@localhost:1521:xe","system","cmrec"); Statement stmt=con.createstatement();
60 PreparedStatement ps=con.preparestatement("insert into emp values(?,?,?)"); BufferedReader br = new BufferedReader(new FileReader("phoneno.txt")); String line; while ((line = br.readline())!= null) String datavalue[] = line.split("\t"); String value1 = datavalue[0]; String value2 = datavalue[1]; ps.setint(1,value1); ps.setstring(2,value2); ps.executeupdate(); phone"); ResultSet rs=stmt.executequery("select * from while(rs.next())
61 System.out.println(rs.getString(1)+" "+rs.getstring(2)); con.close(); catch(exception e) System.out.println(e); Output:
62 Week 14: Write a java program that prints the meta-data of a given table. Java Code import java.sql.*; import java.util.stringtokenizer; public class TableMetaData final static String table = "emp"; public static void main(string[] args) System.out.println("--- meta data ---"); try Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=drivermanager.getconnection( "jdbc:oracle:thin:@localhost:1521:xe","system","cmrec"); Statement stmt=con.createstatement();
63 ResultSet rs = stmt.executequery("select * FROM "+ table); ResultSetMetaData rsmd = rs.getmetadata(); int columncount = rsmd.getcolumncount(); for(int col = 1; col <= columncount; col++) System.out.print(rsmd.getColumnLabel(col)); System.out.print(" (" + rsmd.getcolumntypename(col)+")"); if(col < columncount) System.out.print(", "); System.out.println(); while(rs.next()) for(int col = 1; col <= columncount; col++)
64 System.out.print(rs.getString(col)); System.out.print("\t"); System.out.println(); rs.close(); stmt.close(); con.close(); catch (Exception e) class"); System.out.println("Unable to load database driver Output:
65
SIDDHARTHA Institute of Engineering and Technology
SIDDHARTHA Institute of Engineering and Technology Department of Computer Science &Engineering JAVA Programming Lab Manual [Subject Code: A40585] For the Academic year 2015-16 II B Tech II Semester List
More informationNRI INSTITUTE OF TECHNOLOGY
NRI INSTITUTE OF TECHNOLOGY KOTHUR, NEAR GUDUR GATE, HYDERABAD, A.P Java Programming Lab Manual B. Tech, CSE, II Year II Sem. 2014-2015 DEPARTMENT OF COMPUTER SCIENCE &ENGINEERING DEPARTMENT OF COMPUTER
More informationProgram 20: //Design an Applet program to handle Mouse Events. import java.awt.*; import java.applet.*; import java.awt.event.*;
Program 20: //Design an Applet program to handle Mouse Events. import java.awt.*; import java.applet.*; import java.awt.event.*; /* */ public
More informationnavlakhi.com / navlakhi.education / navlakhi.mobi / navlakhi.org 1
Example 1 public class ex1 extends JApplet public void init() Container c=getcontentpane(); c.setlayout(new GridLayout(5,2)); JButton b1=new JButton("Add"); JButton b2=new JButton("Search"); JLabel l1=new
More informationJava Mouse Actions. C&G criteria: 5.2.1, 5.4.1, 5.4.2,
Java Mouse Actions C&G criteria: 5.2.1, 5.4.1, 5.4.2, 5.6.2. The events so far have depended on creating Objects and detecting when they receive the event. The position of the mouse on the screen can also
More informationJRadioButton account_type_radio_button2 = new JRadioButton("Current"); ButtonGroup account_type_button_group = new ButtonGroup();
Q)Write a program to design an interface containing fields User ID, Password and Account type, and buttons login, cancel, edit by mixing border layout and flow layout. Add events handling to the button
More informationB.Sc (Computer Science) Object Oriented Programming with Java and Data Structures Lab Programs
B.Sc (Computer Science) Object Oriented Programming with Java and Data Structures Lab Programs 1 1. Write a java program to determine the sum of the following harmonic series for a given value of n. 1+1/2+1/3+...
More informationComputer Science 210: Data Structures. Intro to Java Graphics
Computer Science 210: Data Structures Intro to Java Graphics Summary Today GUIs in Java using Swing in-class: a Scribbler program READING: browse Java online Docs, Swing tutorials GUIs in Java Java comes
More informationPESIT Bangalore South Campus
INTERNAL ASSESSMENT TEST II Date : 20-09-2016 Max Marks: 50 Subject & Code: JAVA & J2EE (10IS752) Section : A & B Name of faculty: Sreenath M V Time : 8.30-10.00 AM Note: Answer all five questions 1) a)
More informationGraphical User Interfaces 2
Graphical User Interfaces 2 CSCI 136: Fundamentals CSCI 136: Fundamentals of Computer of Science Computer II Science Keith II Vertanen Keith Vertanen Copyright 2011 Extending JFrame Dialog boxes Overview
More informationUser interfaces and Swing
User interfaces and Swing Overview, applets, drawing, action listening, layout managers. APIs: java.awt.*, javax.swing.*, classes names start with a J. Java Lectures 1 2 Applets public class Simple extends
More informationMultiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks)
M257 MTA Spring2010 Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks) 1. If we need various objects that are similar in structure, but
More informationGUI in Java TalentHome Solutions
GUI in Java TalentHome Solutions AWT Stands for Abstract Window Toolkit API to develop GUI in java Has some predefined components Platform Dependent Heavy weight To use AWT, import java.awt.* Calculator
More informationH212 Introduction to Software Systems Honors
Introduction to Software Systems Honors Lecture #19: November 4, 2015 1/14 Third Exam The third, Checkpoint Exam, will be on: Wednesday, November 11, 2:30 to 3:45 pm You will have 3 questions, out of 9,
More informationMYcsvtu Notes. Java Programming Lab Manual
Java Programming Lab Manual LIST OF EXPERIMENTS 1. Write a Program to add two numbers using Command Line Arguments. 2. Write a Program to find the factorial of a given number using while statement. 3.
More informationJAVA PROGRAMMING LABORATORY MANUAL
JAVA PROGRAMMING LABORATORY MANUAL B.TECH (II YEAR II SEM) (2018-19) DEPARTMENT OF INFORMATION TECHNOLOGY MALLA REDDY COLLEGE OF ENGINEERING & TECHNOLOGY (Autonomous Institution UGC, Govt. of India) Recognized
More informationCMP-326 Exam 2 Spring 2018 Solutions Question 1. Version 1. Version 2
Question 1 30 30 60 60 90 20 20 40 40 60 Question 2 a. b. public Song(String title, String artist, int length, String composer) { this.title = title; this.artist = artist; this.length = length; this.composer
More informationVirtualians.ning.pk. 2 - Java program code is compiled into form called 1. Machine code 2. native Code 3. Byte Code (From Lectuer # 2) 4.
1 - What if the main method is declared as private? 1. The program does not compile 2. The program compiles but does not run 3. The program compiles and runs properly ( From Lectuer # 2) 4. The program
More informationChapter #1. Program to demonstrate applet life cycle
Chapter #1. Program to demonstrate applet life cycle import java.applet.applet; import java.awt.*; public class LifeCycle extends Applet{ public void init(){ System.out.println(" init()"); public void
More informationEXCEPTIONS & GUI. Errors are signals that things are beyond help. Review Session for. -Ankur Agarwal
Review Session for EXCEPTIONS & GUI -Ankur Agarwal An Exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions. Errors are signals
More informationJava Programming Lecture 6
Java Programming Lecture 6 Alice E. Fischer Feb 15, 2013 Java Programming - L6... 1/32 Dialog Boxes Class Derivation The First Swing Programs: Snow and Moving The Second Swing Program: Smile Swing Components
More information) / Java ( )
2002 3 2003.1.29 1 3 ( ) ( ) / Java ( ) 1 ( )? ( ) 2 (3 ) 3 Java Java Java (dynamic dispatch) ( ) import java.awt.*; import java.awt.event.*; public class Sample30 extends Frame { boolean go; double time;
More informationCONTENTS S.No Topic Page. No
CONTENTS S.No Topic Page. No 1. Syllabus 3 2. Required Work 5 3. Course Objectives 6 4. Course Outcomes 6 5. Course Assessment 7 6. Program Outcomes 8 7. Program Objective / Outcome Matrix 9 8. Programs
More informationOOP Assignment V. For example, the scrolling text (moving banner) problem without a thread looks like:
OOP Assignment V If we don t use multithreading, or a timer, and update the contents of the applet continuously by calling the repaint() method, the processor has to update frames at a blinding rate. Too
More informationJava Applet & its life Cycle. By Iqtidar Ali
Java Applet & its life Cycle By Iqtidar Ali Java Applet Basic An applet is a java program that runs in a Web browser. An applet can be said as a fully functional java application. When browsing the Web,
More informationAim: Write a java program to demonstrate the use of following layouts. 1.FlowLayout 2.BorderLayout 3.GridLayout 4.GridBagLayout 5.
DEMONSTRATION OF LAYOUT MANAGERS DATE:09.07.11 Aim: Write a java program to demonstrate the use of following layouts. 1.FlowLayout 2.BorderLayout 3.GridLayout 4.GridBagLayout 5.CardLayout Hardware requirements:
More informationChapter 1 GUI Applications
Chapter 1 GUI Applications 1. GUI Applications So far we've seen GUI programs only in the context of Applets. But we can have GUI applications too. A GUI application will not have any of the security limitations
More informationIntroduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008
Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008 Announcements A3 is up, due Friday, Oct 10 Prelim 1 scheduled for Oct 16 if you have a conflict, let us know now 2 Interactive
More informationOutline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics
Topic 9: Swing Outline Swing = Java's GUI library Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 7: Expand moving shapes from Assignment 4 into game. "Programming
More informationG51PRG: Introduction to Programming Second semester Applets and graphics
G51PRG: Introduction to Programming Second semester Applets and graphics Natasha Alechina School of Computer Science & IT nza@cs.nott.ac.uk Previous two lectures AWT and Swing Creating components and putting
More informationProgrammierpraktikum
Programmierpraktikum Claudius Gros, SS2012 Institut für theoretische Physik Goethe-University Frankfurt a.m. 1 of 18 17/01/13 11:46 Java Applets 2 of 18 17/01/13 11:46 Java applets embedding Java applications
More informationPESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Information Science and Engineering
INTERNAL ASSESSMENT TEST 2 Date : 28-09-15 Max Marks :50 Subject & Code : JAVA&J2EE(10IS753) Section: VII A&B Name of faculty : Mr.Sreenath M V Time : 11.30-1.00 PM Note: Answer any five questions 1) a)
More informationGraphic User Interfaces. - GUI concepts - Swing - AWT
Graphic User Interfaces - GUI concepts - Swing - AWT 1 What is GUI Graphic User Interfaces are used in programs to communicate more efficiently with computer users MacOS MS Windows X Windows etc 2 Considerations
More informationCome & Join Us at VUSTUDENTS.net
Come & Join Us at VUSTUDENTS.net For Assignment Solution, GDB, Online Quizzes, Helping Study material, Past Solved Papers, Solved MCQs, Current Papers, E-Books & more. Go to http://www.vustudents.net and
More informationCSEN401 Computer Programming Lab. Topics: Graphical User Interface Window Interfaces using Swing
CSEN401 Computer Programming Lab Topics: Graphical User Interface Window Interfaces using Swing Prof. Dr. Slim Abdennadher 22.3.2015 c S. Abdennadher 1 Swing c S. Abdennadher 2 AWT versus Swing Two basic
More informationMethod Of Key Event Key Listener must implement three methods, keypressed(), keyreleased() & keytyped(). 1) keypressed() : will run whenever a key is
INDEX Event Handling. Key Event. Methods Of Key Event. Example Of Key Event. Mouse Event. Method Of Mouse Event. Mouse Motion Listener. Example of Mouse Event. Event Handling One of the key concept in
More informationPackages: Putting Classes Together
Packages: Putting Classes Together 1 Introduction 2 The main feature of OOP is its ability to support the reuse of code: Extending the classes (via inheritance) Extending interfaces The features in basic
More informationHandout 14 Graphical User Interface (GUI) with Swing, Event Handling
Handout 12 CS603 Object-Oriented Programming Fall 15 Page 1 of 12 Handout 14 Graphical User Interface (GUI) with Swing, Event Handling The Swing library (javax.swing.*) Contains classes that implement
More informationJava. GUI building with the AWT
Java GUI building with the AWT AWT (Abstract Window Toolkit) Present in all Java implementations Described in most Java textbooks Adequate for many applications Uses the controls defined by your OS therefore
More informationAP CS Unit 12: Drawing and Mouse Events
AP CS Unit 12: Drawing and Mouse Events A JPanel object can be used as a container for other objects. It can also be used as an object that we can draw on. The first example demonstrates how to do that.
More informationWhich of the following syntax used to attach an input stream to console?
Which of the following syntax used to attach an input stream to console? FileReader fr = new FileReader( input.txt ); FileReader fr = new FileReader(FileDescriptor.in); FileReader fr = new FileReader(FileDescriptor);
More informationAdvanced Java Programming
Advanced Java Programming Shmulik London Lecture #5 GUI Programming Part I AWT & Basics Advanced Java Programming / Shmulik London 2006 Interdisciplinary Center Herzeliza Israel 1 Agenda AWT & Swing AWT
More informationprotected void printserial() { System.out.println("> NO." + this.serialno); this.serialno++; }
NumberedTicketGenerator.java package j2.exam.ex01; public abstract class NumberedTicketGenerator { protected int serialno; public NumberedTicketGenerator() { super(); this.serialno = 1000; public void
More informationCSIS 10A Assignment 7 SOLUTIONS
CSIS 10A Assignment 7 SOLUTIONS Read: Chapter 7 Choose and complete any 10 points from the problems below, which are all included in the download file on the website. Use BlueJ to complete the assignment,
More informationQuestion 1. Show the steps that are involved in sorting the string SORTME using the quicksort algorithm given below.
Name: 1.124 Quiz 2 Thursday November 9, 2000 Time: 1 hour 20 minutes Answer all questions. All questions carry equal marks. Question 1. Show the steps that are involved in sorting the string SORTME using
More informationCS 120 Fall 2008 Practice Final Exam v1.0m. Name: Model Solution. True/False Section, 20 points: 10 true/false, 2 points each
CS 120 Fall 2008 Practice Final Exam v1.0m Name: Model Solution True/False Section, 20 points: 10 true/false, 2 points each Multiple Choice Section, 32 points: 8 multiple choice, 4 points each Code Tracing
More informationAP CS Unit 11: Graphics and Events
AP CS Unit 11: Graphics and Events This packet shows how to create programs with a graphical interface in a way that is consistent with the approach used in the Elevens program. Copy the following two
More informationGraphical User Interfaces 2
Graphical User Interfaces 2 CSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2014 2011 Extending JFrame Dialog boxes Overview Ge
More informationCS2110. GUIS: Listening to Events
CS2110. GUIS: Listening to Events Also anonymous classes Download the demo zip file from course website and look at the demos of GUI things: sliders, scroll bars, combobox listener, etc 1 mainbox boardbox
More informationJAVA PROGRAMMING LABORATORY MANUAL B.TECH (II YEAR II SEM) ( )
JAVA PROGRAMMING LABORATORY MANUAL B.TECH (II YEAR II SEM) (2016-17) Department of Computer Science and Engineering MALLA REDDY COLLEGE OF ENGINEERING & TECHNOLOGY (Autonomous Institution UGC, Govt. of
More informationGraphical User Interfaces 2
Graphical User Interfaces 2 CSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2011 Extending JFrame Dialog boxes Ge?ng user input Overview Displaying message or error Listening for
More informationG51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread
G51PGP Programming Paradigms Lecture 008 Inner classes, anonymous classes, Swing worker thread 1 Reminder subtype polymorphism public class TestAnimals public static void main(string[] args) Animal[] animals
More informationAdvanced Java Unit 6: Review of Graphics and Events
Advanced Java Unit 6: Review of Graphics and Events This is a review of the basics of writing a java program that has a graphical interface. To keep things simple, all of the graphics programs will follow
More informationMaharashtra State Board of Technical Education
Maharashtra State Board of Technical Education (Autonomous) (ISO 9001:2008) (ISO/IEC 27001:2005) Welcome M2001 [117.239.186.68] My Home Log Out e-exam Manage Questions for Advanced Java Programming (17625)
More informationSE1021 Exam 2. When returning your exam, place your note-sheet on top. Page 1: This cover. Page 2 (Multiple choice): 10pts
SE1021 Exam 2 Name: You may use a note-sheet for this exam. But all answers should be your own, not from slides or text. Review all questions before you get started. The exam is printed single-sided. Write
More informationCSIS 10A Practice Final Exam Solutions
CSIS 10A Practice Final Exam Solutions 1) (5 points) What would be the output when the following code block executes? int a=3, b=8, c=2; if (a < b && b < c) b = b + 2; if ( b > 5 a < 3) a = a 1; if ( c!=
More informationAn array is a type of variable that is able to hold more than one piece of information under a single variable name.
Arrays An array is a type of variable that is able to hold more than one piece of information under a single variable name. Basically you are sub-dividing a memory box into many numbered slots that can
More informationApplet which displays a simulated trackball in the upper half of its window.
Example: Applet which displays a simulated trackball in the upper half of its window. By dragging the trackball using the mouse, you change its state, given by its x-y position relative to the window boundaries,
More informationFrames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling
Frames, GUI and events Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling Introduction to Swing The Java AWT (Abstract Window Toolkit)
More informationJAVA PROGRAMMIMG LABORATORY MANUAL
JAVA PROGRAMMIMG LABORATORY MANUAL B.TECH (II YEAR II SEM) (2017-18) DEPARTMENT OF INFORMATION TECHNOLOGY MALLA REDDY COLLEGE OF ENGINEERING & TECHNOLOGY (Autonomous Institution UGC, Govt. of India) Recognized
More informationISO-2022-JP (JIS ) 1 2. (Windows95/98 MacOS ) Java UNICODE UNICODE. Java. .java.java.txt native2ascii. .java
2000 8 2000.1.24-27 0 4 1 ( (1 8 ) ASCII 1 8 1 1 8 2 ISO-2022-JP (JIS ) 1 2 EUC ( EUC) 8 Unix SJIS (MS ) EUC 8 ( (Windows95/98 MacOS Java UNICODE UNICODE ( Java.java.java.txt native2ascii.java native2ascii
More informationDay before tests of Java Final test. IDM institution of Bandarawela. Project for department of education
Day before tests of Java Final test. IDM institution of Bandarawela Project for department of education import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Doenets extends JApplet
More informationTHE UNIVERSITY OF AUCKLAND
CompSci 101 with answers THE UNIVERSITY OF AUCKLAND FIRST SEMESTER, 2012 Campus: City COMPUTER SCIENCE Principles of Programming (Time Allowed: TWO hours) NOTE: You must answer all questions in this test.
More informationLecture 5: Java Graphics
Lecture 5: Java Graphics CS 62 Spring 2019 William Devanny & Alexandra Papoutsaki 1 New Unit Overview Graphical User Interfaces (GUI) Components, e.g., JButton, JTextField, JSlider, JChooser, Containers,
More informationMidterm assessment - MAKEUP Fall 2010
M257 MTA Faculty of Computer Studies Information Technology and Computing Date: /1/2011 Duration: 60 minutes 1-Version 1 M 257: Putting Java to Work Midterm assessment - MAKEUP Fall 2010 Student Name:
More informationJAVA PROGRAM EXAMPLE WITH OUTPUT PDF
JAVA PROGRAM EXAMPLE WITH OUTPUT PDF Created By: Umar Farooque Khan 1 How to compile and run java programs Compile: - javac JavaFileName Run Java: - java JavaClassName Let s take an example of java program:
More informationBM214E Object Oriented Programming Lecture 13
BM214E Object Oriented Programming Lecture 13 Events To understand how events work in Java, we have to look closely at how we use GUIs. When you interact with a GUI, there are many events taking place
More informationFirst Name: AITI 2004: Exam 2 July 19, 2004
First Name: AITI 2004: Exam 2 July 19, 2004 Last Name: Standard Track Read Instructions Carefully! This is a 3 hour closed book exam. No calculators are allowed. Please write clearly if we cannot understand
More informationAttempt FOUR questions Marking Scheme Time: 120 mins
Ahmadu Bello University Department of Computer Science Second Semester Examinations August 2017 COSC212: Object Oriented Programming II Marking Scheme Attempt FOUR questions Marking Scheme Time: 120 mins
More informationRAIK 183H Examination 2 Solution. November 10, 2014
RAIK 183H Examination 2 Solution November 10, 2014 Name: NUID: This examination consists of 5 questions and you have 110 minutes to complete the test. Show all steps (including any computations/explanations)
More informationLecture 3: Java Graphics & Events
Lecture 3: Java Graphics & Events CS 62 Fall 2017 Kim Bruce & Alexandra Papoutsaki Text Input Scanner class Constructor: myscanner = new Scanner(System.in); can use file instead of System.in new Scanner(new
More informationPART1: Choose the correct answer and write it on the answer sheet:
PART1: Choose the correct answer and write it on the answer sheet: (15 marks 20 minutes) 1. Which of the following is included in Java SDK? a. Java interpreter c. Java disassembler b. Java debugger d.
More informationJava - Applets. public class Buttons extends Applet implements ActionListener
Java - Applets Java code here will not use swing but will support the 1.1 event model. Legacy code from the 1.0 event model will not be used. This code sets up a button to be pushed: import java.applet.*;
More informationIntroduction to the JAVA UI classes Advanced HCI IAT351
Introduction to the JAVA UI classes Advanced HCI IAT351 Week 3 Lecture 1 17.09.2012 Lyn Bartram lyn@sfu.ca About JFC and Swing JFC Java TM Foundation Classes Encompass a group of features for constructing
More informationDatenbank-Praktikum. Universität zu Lübeck Sommersemester 2006 Lecture: Swing. Ho Ngoc Duc 1
Datenbank-Praktikum Universität zu Lübeck Sommersemester 2006 Lecture: Swing Ho Ngoc Duc 1 Learning objectives GUI applications Font, Color, Image Running Applets as applications Swing Components q q Text
More informationJava Applet Basics. Life cycle of an applet:
Java Applet Basics Applet is a Java program that can be embedded into a web page. It runs inside the web browser and works at client side. Applet is embedded in a HTML page using the APPLET or OBJECT tag
More informationCS506 Web Programming and Development Solved Subjective Questions With Reference For Final Term Lecture No 1
P a g e 1 CS506 Web Programming and Development Solved Subjective Questions With Reference For Final Term Lecture No 1 Q1 Describe some Characteristics/Advantages of Java Language? (P#12, 13, 14) 1. Java
More informationExp 6: Develop Java programs to implement Interfaces and Packages. Apply Exception handling and implement multithreaded programs.
CO504.3 CO504.4 Develop Java programs to implement Interfaces and Packages. Apply Exception handling and implement multithreaded programs. CO504.5 CO504.6 Implement Graphics programs using Applet. Develop
More informationRobotPlanning.java Page 1
RobotPlanning.java Page 1 import java.awt.*; import java.awt.event.*; import java.awt.image.*; import javax.swing.*; import javax.swing.border.*; import java.util.*; * * RobotPlanning - 1030 GUI Demonstration.
More informationCSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT
CSE 143 Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/
More informationName Section. CS 21a Introduction to Computing I 1 st Semester Final Exam
CS a Introduction to Computing I st Semester 00-00 Final Exam Write your name on each sheet. I. Multiple Choice. Encircle the letter of the best answer. ( points each) Answer questions and based on the
More informationFirst Name: AITI 2004: Exam 2 July 19, 2004
First Name: AITI 2004: Exam 2 July 19, 2004 Last Name: JSP Track Read Instructions Carefully! This is a 3 hour closed book exam. No calculators are allowed. Please write clearly if we cannot understand
More informationLaborator 3 Aplicatii Java
Laborator 3 Aplicatii Java 1. Programarea vizuala Scrieti, compilati si rulati toate exemplele din acest laborator: 1. Fisierul se numeste testschimbareculori.java: import java.awt.*; import java.awt.event.*;
More informationWindow Interfaces Using Swing Objects
Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs
More informationGracefulness of TP-Tree with Five Levels Obtained by Java Programming
International Journal of Scientific and Research Publications, Volume 2, Issue 12, December 2012 1 Gracefulness of TP-Tree with Five Levels Obtained by Java Programming A.Solairaju 1, N. Abdul Ali 2 and
More informationjavax.swing Swing Timer
27 javax.swing Swing SwingUtilities SwingConstants Timer TooltipManager JToolTip 649 650 Swing CellRendererPane Renderer GrayFilter EventListenerList KeyStroke MouseInputAdapter Swing- PropertyChangeSupport
More informationFirstSwingFrame.java Page 1 of 1
FirstSwingFrame.java Page 1 of 1 2: * A first example of using Swing. A JFrame is created with 3: * a label and buttons (which don t yet respond to events). 4: * 5: * @author Andrew Vardy 6: */ 7: import
More informationWindows and Events. created originally by Brian Bailey
Windows and Events created originally by Brian Bailey Announcements Review next time Midterm next Friday UI Architecture Applications UI Builders and Runtimes Frameworks Toolkits Windowing System Operating
More informationContents Chapter 1 Introduction to Programming and the Java Language
Chapter 1 Introduction to Programming and the Java Language 1.1 Basic Computer Concepts 5 1.1.1 Hardware 5 1.1.2 Operating Systems 8 1.1.3 Application Software 9 1.1.4 Computer Networks and the Internet
More informationGraphical User Interface Programming
Graphical User Interface Programming Michael Brockway January 14, 2015 Graphical User Interfaces Users interact with modern application programs using graphical components such as windows, buttons (plain,
More informationDEPARTMENT VISION AND MISSION
INSTITUTE VISION AND MISSION Vision To emerge as a destination for higher education by transforming learners into achievers by creating, encouraging and thus building a supportive academic environment.
More informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CISC124, WINTER TERM, 2011 FINAL EXAMINATION 7pm to 10pm, 26 APRIL 2011, Ross Gym Instructor: Alan McLeod If the instructor
More informationCS2110. GUIS: Listening to Events. Anonymous functions. Anonymous functions. Anonymous functions. Checkers.java. mainbox
CS2110. GUIS: Listening to Events Lunch with instructors: Visit pinned Piazza post. A4 due tonight. Consider taking course S/U (if allowed) to relieve stress. Need a letter grade of C- or better to get
More informationCS2110. GUIS: Listening to Events
CS2110. GUIS: Listening to Events Lunch with instructors: Visit pinned Piazza post. A4 due tonight. Consider taking course S/U (if allowed) to relieve stress. Need a letter grade of C- or better to get
More informationCS2110. GUIS: Listening to Events Also anonymous classes versus Java 8 functions. Anonymous functions. Anonymous functions. Anonymous functions
CS2110. GUIS: Listening to Events Also anonymous classes versus Java 8 functions Lunch with instructors: Visit Piazza pinned post to reserve a place Download demo zip file from course website, look at
More informationimport javax.swing.*; public class Sample { JFrame f; Sample(){ f=new JFrame(); JButton b=new JButton("click"); b.setbounds(130,100,100, 40); f.add(b); f.setsize(400,500); f.setlayout(null); f.setvisible(true);
More informationRAIK 183H Examination 2 Solution. November 11, 2013
RAIK 183H Examination 2 Solution November 11, 2013 Name: NUID: This examination consists of 5 questions and you have 110 minutes to complete the test. Show all steps (including any computations/explanations)
More informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor:
More informationGive one example where you might wish to use a three dimensional array
CS 110: INTRODUCTION TO COMPUTER SCIENCE SAMPLE TEST 3 TIME ALLOWED: 60 MINUTES Student s Name: MAXIMUM MARK 100 NOTE: Unless otherwise stated, the questions are with reference to the Java Programming
More informationMidterm Test II Object Oriented Programming in Java Computer Science, University of Windsor Fall 2014 Time 2 hours. Answer all questions
Midterm Test II 60-212 Object Oriented Programming in Java Computer Science, University of Windsor Fall 2014 Time 2 hours Answer all questions Name : Student Id # : Only an unmarked copy of a textbook
More information