Java2 Solution Set PDF
Java2 Solution Set PDF
import [Link].*;
try
{
[Link](2000);
}
catch (InterruptedException ex)
{
[Link]();
}
}
/*
Slip no 2 Write a Java program to accept the details of
Employee (Eno, EName, Designation,Salary) from a user and
store it into the database. (Use Swing)
*/
package [Link].prac1;
import [Link].*;
import [Link];
import [Link];
import [Link].*;
import [Link].*;
import [Link].*;
class EmpApp {
private JFrame frame;
private JTextField eno, ename, desig, sal;
private JButton clear, insert;
[Link](new JLabel("Eno."));
[Link](eno);
[Link](new JLabel("EName"));
[Link](ename);
[Link](new JLabel("Designation"));
[Link](desig);
[Link](new JLabel("Salary"));
[Link](sal);
Connection conn =
[Link]("jdbc:postgresql://localhost:5432/postgres",
"postgres", "bhalchandra");
[Link]((ActionEvent e) -> {
try {
insertEmp(conn, eno, ename, desig, sal);
} catch (IOException | SQLException ex) {
[Link]([Link]()).log([Link],
null, ex);
}
});
[Link]((ActionEvent e) -> {
[Link]("");
[Link]("");
[Link]("");
[Link]("");
});
[Link](insert);
[Link](clear);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](true);
}
/*
Slip no 2 Q1 Write a java program to read ‘N’ names of your
friends, store it into HashSet and
display them in ascending order.
*/
package [Link].practical_slip;
import [Link].*;;
public class slip2_1
{
public static void main(String[] args)
{
HashSet<String> friends = new HashSet<>();
[Link]();
for(int i = 0 ; i<n;i++)
{
[Link]("Enter name :");
String name = [Link]();
[Link](name);
}
/*
Slip no 3 Q1. Write a JSP program to display the details of Patient (PNo,
PName, Address, age,
disease) in tabular form on browser*/
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Patient</h1>
<table border="1">
<tr>
<th>PNo</th>
<th>PName</th>
<th>Address</th>
<th>age</th>
<th>disease</th>
</tr>
<tr>
<td>1</td>
<td>John</td>
<td>xyz</td>
<td>45</td>
<td>kovid</td>
</<tr>
<tr>
<td>2</td>
<td>Brock</td>
<td>abc</td>
<td>48</td>
<td>canser</td>
</<tr>
</table>
</body>
</html>
*/
/*
Slip no 3 Q2. Write a Java program to create LinkedList of String objects
and perform the following:
i. Add element at the end of the list
ii. Delete first element of the list
iii. Display the contents of list in reverse order
*/
package [Link];
import [Link].*;
int ch;
do {
[Link]("Menu");
[Link]("1. Insert at tail");
[Link]("2. Delete head.");
[Link]("3. Display in reverse");
[Link]("4. Exit");
[Link]("------------------------------");
[Link]("Enter your choice:");
ch = [Link]();
[Link]();
[Link]();
switch (ch) {
case 1:
[Link]("Enter name.");
[Link]([Link]());
break;
case 2:
[Link]();
break;
case 3:[Link]("Real order");
Iterator itr = [Link]();
while ([Link]())
{
[Link]([Link]());
}
Iterator it = [Link]();
while ([Link]())
{
[Link]([Link]());
break;
default:
[Link]("Invalid choice.");
}
[Link]("-------------------------------");
} while (ch != 4);
}
}
/*
Slip no 4 Q1 Write a Java program using Runnable interface to blink Text
on the JFrame (Use
Swing)
*/
package [Link].practical_slip;
import [Link];
import [Link];
import [Link].*;
public BlinkText() {
frame = new JFrame("Blink Light");
[Link](200, 200);
blink = new JLabel("Blink");
[Link](blink);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](true);
}
@Override
public void run() {
Random rand = new Random();
while(true) {
int r = [Link](255);
int g = [Link](255);
int b = [Link](255);
[Link](new Color(r, g, b));
}
}
}
import [Link].*;
int ch;
String code, city;
do {
[Link]("Menu");
[Link]("1. Add City and std code.(no
duplicates)");
[Link]("2. Remove City.");
[Link]("3. Search city name dsiplay std code");
[Link]("4. Exit");
[Link]("------------------------------");
[Link]("Enter your choice:");
ch = [Link]();
[Link]();
[Link]();
switch(ch) {
case 1: [Link]("Enter std code.");
code = [Link]();
[Link]("Enter City.");
city = [Link]();
[Link](code, city);
break;
case 2: [Link]("Enter std code.");
code = [Link]();
[Link](code);
break;
case 3: [Link]("Enter city:");
city = [Link]();
code = null;
for([Link]<String, String> map :
[Link]()) {
if([Link]().equals(city))
code = [Link]();
}
if(code != null)
[Link]("Code is " + code);
else
[Link]("Not found.");
break;
default: [Link]("Invalid choice.");
}
[Link]("-------------------------------");
} while(ch != 4);
}
}
/*
Slip no5 Q1. Write a Java Program to create the hash table that will
maintain the mobile number and
student name. Display the details of student using Enumeration interface
*/
package [Link];
import [Link].*;
[Link]("1234567890", "john");
[Link]("1239874560", "carry");
/*
slip no 6 Q1 Write a Java program to accept ‘n’ integers from the user
and store them in a Collection.
Display them in the sorted order. The collection should not accept
duplicate elements.
(Use a suitable collection). Search for a particular element using
predefined search
method in the Collection framework
*/
package [Link].practical_slip;
import [Link].*;
[Link](nums);
/*
slip no 6 q2 Write a java program using multithreading to simulate
traffic signal (Use Swing).
*/
package [Link].practical_slip;
import [Link].*;
@Override
public void run() {
int idx = 0;
while(true) {
[Link]("Current Signal : " + lights[idx]);
try {
[Link](getDuration(lights[idx]) * 1000);
} catch (InterruptedException ex) {
[Link]([Link]()).log([Link], null,
ex);
}
idx = (idx + 1) % [Link];
}
}
/*
slip no 7 Q2 Write a java program that implements a multi-thread
application that has three threads.
First thread generates random integer number after every one second, if
the number is
even; second thread computes the square of that number and prints it. If
the number is
odd, the third thread computes the cube of that number and prints it.
*/
package [Link].practical_slip;
import [Link];
import [Link].*;
@Override
public void run() {
while(true) {
n = [Link](100);
[Link]("Generated number: " + n);
try {
[Link](1000);
} catch (InterruptedException ex) {
[Link]([Link]()).log([Link], null,
ex);
}
}
}
}
SqrGenerator(NumGenerator numGenerator) {
[Link] = numGenerator;
}
@Override
public void run() {
while(true) {
int n = numGenerator.n;
if(n % 2 == 0)
[Link]("Square of " + n + " is " + n*n);
try {
[Link](1000);
} catch (InterruptedException ex) {
[Link]([Link]()).log([Link], null,
ex);
}
}
}
}
CubeGenerator(NumGenerator numGenerator) {
[Link] = numGenerator;
}
@Override
public void run() {
while(true) {
int n = numGenerator.n;
if(n % 2 != 0)
[Link]("Cube of " + n + " is " + n*n*n);
try {
[Link](1000);
} catch (InterruptedException ex) {
[Link]([Link]()).log([Link], null,
ex);
}
}
}
}
/*
slip no 7 q2. Write a java program for the following:
i. To create a Product (Pid, Pname, Price) table.
ii. Insert at least five records into the Product table.
iii. Display all the records from a Product table.
Assume Database is already created
*/
package [Link].practical_slip;
import [Link].*;
import [Link];
int ch;
do {
[Link]("Menu");
[Link]("1. Create table Product.");
[Link]("2. Insert into Product.");
[Link]("3. Display records of product.");
[Link]("4. Exit.");
[Link]("------------------------------");
[Link]("Enter your choice:");
ch = [Link]();
switch(ch) {
case 1: create(conn);
break;
case 2: insert(conn);
break;
case 3 : select(conn);
break;
default : [Link]("Invalid choice.");
break;
}
} while(ch != 4);
}
PreparedStatement pt = [Link](sql);
Scanner sc = new Scanner([Link]);
[Link]("Enter pid:");
int pid = [Link]();
[Link]();
[Link]("Enter pname:");
String name = [Link]();
[Link]("Enter price");
float price = [Link]();
[Link](1, pid);
[Link](2, name);
[Link](3, price);
[Link]();
}
while([Link]()) {
[Link]("Pid = " + [Link]("pid"));
[Link]("PName = " + [Link]("pname"));
[Link]("Price = " + [Link]("price"));
[Link]("----------------------------------------------");
}
}
}
/*
slip no 9 Q1. Write a java program to define a thread for printing text on
output screen for ‘n’
number of times. Create 3 threads and run them. Pass the text ‘n’
parameters to the
thread constructor.
Example:
i. First thread prints “COVID19” 10 times.
ii. Second thread prints “LOCKDOWN2020” 20 times
iii. Third thread prints “VACCINATED2021” 30 times
*/
package [Link].practical_slip;
T1(String msg) {
[Link] = msg;
}
public void run() {
for(int i=0; i<10; i++)
[Link](msg);
}
}
T2(String msg) {
[Link] = msg;
}
T3(String msg) {
[Link] = msg;
}
[Link]();
[Link]();
[Link]();
}
}
/*slip no 8 Q2*/
if(n > 1) {
boolean isPrime = true;
for(int i=2; i<n; i++) {
if(n % i == 0) {
isPrime = false;
break;
}
}
if(isPrime) {
%>
<h3 class="prime">Prime number</h3>
<%
} else {
%>
<h3 class="prime">Not a prime number</h3>
<%
}
}
}
%>
</body>
</html>
/*
slip no 9 Q1. Write a Java program to create a thread for moving a ball
inside a panel vertically. The
ball should be created when the user clicks on the start button (Use
Swing).
*/
package [Link].practical_slip;
import [Link].*;
import [Link];
import [Link].*;
import [Link].*;
@Override
protected void paintComponent(Graphics g)
{
[Link](g);
[Link]([Link]);
[Link](175, yDelta, 50, 50);
repaint();
}
void setBallPos(int y) {
[Link] = y;
}
}
slip9_1()
{
frame = new JFrame("Ball Movement App");
[Link](400, 400);
[Link](new BorderLayout());
[Link](ballPanel, [Link]);
[Link](start, [Link]);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](true);
}
y += 5 * dir;
if(y <= 0)
dir = 1;
[Link](y);
}
}
import [Link];
import [Link].*;
import [Link].*;
import [Link].*;
class StudentRec
{
private JFrame frame;
private JTextField tf1, tf2, tf3;
private JButton display;
Connection conn =
[Link]("jdbc:postgresql://localhost:5432/postgres",
"postgres", "postgres");
[Link]((ActionEvent) -> {
try {
select(conn);
} catch (SQLException ex) {
[Link](new GridLayout(4,1));
[Link](tf1);
[Link](tf2);
[Link](tf3);
[Link](display);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](true);
}
while([Link]()) {
[Link](" " + [Link]("rno"));
[Link](" " + [Link]("sname"));
[Link](" " + [Link]("per") + "");
}
}
}
/*
slip no 11 q2 Write a Java program to display information about all
columns in the DONAR table
using ResultSetMetaData.
*/
package [Link];
import [Link].*;
ResultSet rs = [Link]();
ResultSetMetaData rsmd = [Link]();
if(n > 1) {
int sum = 0;
for(int i=1; i<=n/2; i++) {
if(n % i == 0) {
sum += i;
}
}
if(sum == n) {
%>
<h3>Perfect number</h3>
<%
} else {
%>
<h3>Not a perfect number</h3>
<%
}
}
}
%>
</body>
</html>
/*
slip no 12 Q2 Write a Java Program to create a PROJECT table with field’s
project_id, Project_name,
Project_description, Project_Status. Insert values in the table. Display
all the details of
the PROJECT table in a tabular format on the screen.(using swing).
*/
package [Link];
import [Link];
import [Link].*;
import [Link];
import [Link];
import [Link];
class ProjectTable {
private JFrame frame;
private JTable table;
createTable(conn);
insert(conn);
String[] colNames = {"pid", "pname", "description", "status"};
String[][] data = retriveData(conn);
[Link]().add(scrPane, [Link]);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](true);
}
Statement stmt =
[Link](ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = [Link](sql);
ResultSetMetaData rsmd = [Link]();
int noCol = [Link]();
[Link]();
int noRow = [Link]();
[Link]();
int rowCnt = 0;
while ([Link]()) {
for (int i = 1; i <= noCol; i++)
data[rowCnt][i - 1] = [Link](i);
rowCnt++;
}
return data;
}
/*
Slip no 13 Q1 Write a Java program to display information about the
database and list all the tables in
the database. (Use DatabaseMetaData).
*/
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
[Link]("" + [Link]());
[Link]("" + [Link]());
[Link]("" + [Link]());
[Link]("" + [Link]());
/*
Slip no13 Q2 Write a Java program to show lifecycle (creation, sleep, and
dead) of a thread. Program
should print randomly the name of thread and value of sleep time. The name
of the
thread should be hard coded through constructor. The sleep time of a
thread will be a
random integer in the range 0 to 4999.
*/
package [Link];
import [Link];
import [Link];
import [Link];
ThreadLifeCycle(String threadName) {
[Link] = threadName;
}
[Link]([Link]()).log([Link], null,
ex);
}
[Link]();
[Link]();
[Link]();
}
}
/*
slip no 14 Q1 Write a Java program using Multithreading for a simple
search engine. Accept a string
to be searched. Search the string in all text files in the current folder.
Use a separate
thread for each file. The result should display the filename and line
number where the
string is found.
*/
package [Link];
import [Link].*;
import [Link];
if (files != null) {
boolean foundInAnyFile = false;
for (File file : files) {
if ([Link]() && [Link]().endsWith(".txt")) {
SearchThread t = new SearchThread(file, searchStr);
[Link]();
foundInAnyFile = true;
}
}
if (!foundInAnyFile) {
[Link]("No text files found in the current
directory.");
}
} else {
[Link]("Error: Unable to access current
directory.");
}
}
}
/* slipno 14 Q2 */
int fDigit = n;
while(fDigit >= 10) {
fDigit /= 10;
}
int lDigit = n % 10;
int sum = fDigit + lDigit;
%>
<h3 class="res">Sum of first and last digit is <%= sum
%></h3>
<%
}
%>
</body>
</html>
/*
slip no 15 q1 Write a java program to display name and priority of a
Thread.
*/
package [Link];
[Link]();
[Link]();
}
}
/*
slip no 16 Q1. Write a java program to create a TreeSet, add some colors
(String) and print out the
content of TreeSet in ascending order
*/
package [Link];
import [Link].*;
{
public static void main(String[] args) {
Set<String> colors = new TreeSet<>();
[Link]("Red");
[Link]("Blue");
[Link]("Green");
[Link]("Yellow");
[Link]("Black");
[Link](colors);
}
}
/*
slip no 16 Q2 Write a Java program to accept the details of Teacher (TNo,
TName, Subject). Insert at
least 5 Records into Teacher Table and display the details of Teacher who
is teaching
“JAVA” Subject. (Use PreparedStatement Interface)
*/
package [Link];
import [Link].*;
import [Link];
class Teacher {
select(conn);
}
PreparedStatement ps = [Link](sql);
[Link]("Enter tno:");
[Link](1, [Link]());
[Link]();
[Link]("Enter tname:");
[Link](2, [Link]());
[Link]("Enter subject:");
[Link](3, [Link]());
[Link]();
}
/*
Slip no 17 q1Write a java program to accept ‘N’ integers from a user.
Store and display integers in
sorted order having proper collection class. The collection should not
accept duplicate
elements.
*/
package [Link];
import [Link];
import [Link];
import [Link];
[Link](set);
}
}
/*
Slip no 17 Q2 Write a java program using Multithreading to display the
number’s between 1 to 100
continuously in a JTextField by clicking on JButton. (Use Runnable
Interface &
Swing).
*/
package [Link];
import [Link];
import [Link];
import [Link].*;
import [Link].*;
slip17_2() {
frame = new JFrame("Integer printing App");
[Link](300, 200);
[Link](new GridLayout(2,1));
tf = new JTextField();
print = new JButton("Print");
[Link](tf);
[Link](print);
[Link]((ActionEvent e) -> {
[Link]("");
if(intThread == null || ![Link]()) {
intThread = new Thread(new Runnable() {
@Override
public void run() {
while(true) {
for(int i=1; i<=100; i++) {
[Link]([Link](i));
try {
[Link](500);
} catch (InterruptedException ex) {
[Link](JFrame.EXIT_ON_CLOSE);
[Link](true);
}
import [Link];
import [Link].*;
[Link]();
}
}
/*
slip no 19 Q1 Write a java program to accept ‘N’ Integers from a user
store them into LinkedList
Collection and display only negative integers.
*/
package [Link];
import [Link].*;
<%
String numStr = [Link]("num");
t = rev;
rev = 0;
while(t > 0) {
rem = t % 10;
rev = (rev * 10) + rem;
t = t / 10;
switch(rem) {
case 0: [Link]("zero");
break;
case 1: [Link]("one");
break;
case 2: [Link]("two");
break;
case 3: [Link]("three");
break;
case 4: [Link]("four");
break;
case 5: [Link]("five");
break;
case 6: [Link]("six");
break;
case 7: [Link]("seven");
break;
case 8: [Link]("eight");
break;
case 9: [Link]("nine");
break;
}
}
}
%>
</body>
</html>
/*
slip no 20 q2Write a java program using Multithreading to demonstrate
drawing temple (Use
Swing)
*/
package [Link];
import [Link].*;
import [Link].*;
@Override
protected void paintComponent(Graphics g)
{
[Link](g);
drawTemple(g);
}
[Link]([Link]);
[Link](130, 150, 40, 50); // Main Door
[Link]([Link]);
int[] xPoints = {100, 150, 200}; // Triangle for roof
int[] yPoints = {100, 50, 100};
[Link](xPoints, yPoints, 3);
[Link]([Link]);
[Link](150, 40, 20, 10); // Flag
}
}
/*
slip no 21 Q1. Write a java program to accept ‘N’ Subject Names from a
user store them into
LinkedList Collection and Display them by using Iterator interface.
*/
package [Link];
import [Link].*;
/*
slip no 22 Q2 Write a java program using Multithreading to solve producer
consumer problem in
which a producer produces a value and consumer consume the value before
producer
generate the next value. (Hint: use thread synchronization)
*/
package [Link];
import [Link];
class SharedResource {
private LinkedList<String> buffer = new LinkedList<>();
private int capacity = 1;
[Link](value);
[Link]("Produced: " + value);
notifyAll();
}
return value;
}
}
@Override
public void run() {
for(int i=0; i<5; i++) {
String value = "Value " + i;
[Link](value);
try {
sleep(1000);
} catch (InterruptedException e) {
[Link]();
}
}
}
}
class Consumer extends Thread {
private SharedResource sharedResource;
@Override
public void run() {
for(int i=0; i<5; i++) {
String value = "Value " + i;
[Link]();
try {
sleep(1000);
} catch (InterruptedException e) {
[Link]();
}
}
}
}
[Link]();
[Link]();
}
}
/*
slip no 22 Q1 Write a Menu Driven program in Java for the following:
Assume Employee table with
attributes (ENo, EName, Salary) is already created. 1. Insert 2. Update 3.
Display 4.
Exit
*/
package [Link];
import [Link].*;
import [Link];
[Link]("Enter eno:");
[Link](1, [Link]());
[Link]();
[Link]("Enter ename:");
[Link](2, [Link]());
[Link]("Enter salary:");
[Link](3, [Link]());
[Link]();
}
String sql = "update emp2 set ename = '" + ename + "', salary = "
+ salary + " where eno = " + eno;
Statement stmt = [Link]();
[Link](sql);
}
int ch;
do {
[Link]("Menu");
[Link]("1. Insert");
[Link]("2. Update");
[Link]("3. Display");
[Link]("4. Exit");
[Link]("-------------------------");
*/ slip no 22 Q2 */
<%
String user = [Link]("user");
/*
slip no 23 Q1 Write a java program using Multithreading to accept a String
from a user and display
each vowel from a String after every 3 seconds
*/
package [Link];
import [Link];
import [Link].*;
[Link]();
}
}
/*
Slip no 24 Q1 Write a java program using Multithreading to scroll the
text from left to right
continuously (Use Swing).
*/
package [Link];
import [Link].*;
@Override
public void run() {
try {
while (true) {
String labelText = [Link]();
labelText = [Link](1) + [Link](0);
[Link](labelText);
[Link](200); // Adjust scrolling speed
}
} catch (InterruptedException e) {
[Link]();
}
}
}
/*
SLip no 25 Q2 Write a Java Program for the following: Assume database is
already created.
*/
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
tf = new JTextField();
[Link](new GridLayout(1, 2));
[Link](new JLabel("Type your DDL query:"));
[Link](tf);
Connection conn =
[Link]("jdbc:postgresql://localhost:5432/postgres",
"postgres", "postgres");
[Link]((ActionEvent e) -> {
try {
create(conn);
} catch (SQLException ex) {
[Link]([Link]()).log([Link],
null, ex);
}
});
[Link]((ActionEvent e) -> {
try {
alter(conn);
} catch (SQLException ex) {
[Link]([Link]()).log([Link],
null, ex);
}
});
[Link]((ActionEvent e) -> {
try {
drop(conn);
} catch (SQLException ex) {
[Link]([Link]()).log([Link],
null, ex);
}
});
[Link](p1, [Link]);
[Link](p2, [Link]);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](true);
}
private void create(Connection conn) throws SQLException {
String sql = [Link]();
Statement stmt = [Link]();
[Link](sql);
}
/*
Slip no 26 Q1 Write a Java program to delete the details of given employee
(ENo EName Salary).
Accept employee ID through command line. (Use PreparedStatement Interface)
*/
package [Link];
import [Link].*;
/*
slip no 27 Q1 Write a Java Program to display the details of College (CID,
CName, address, Year)
database table on JTable.
*/
package [Link];
import [Link];
import [Link].*;
import [Link].*;
class CollegeTable {
private JFrame frame;
private JTable table;
[Link]().add(scrPane, [Link]);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](true);
}
Statement stmt =
[Link](ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = [Link](sql);
ResultSetMetaData rsmd = [Link]();
int rowCnt = 0;
while ([Link]()) {
for (int i = 1; i <= noCol; i++)
data[rowCnt][i - 1] = [Link](i);
rowCnt++;
}
return data;
}
/*
Slip no 28 Q2 Write a java program to display name of currently executing
Thread in multithreading
*/
package [Link];
[Link]();
}
}
/*
Slip no 29 Q1. Write a Java program to display information about all
columns in the DONAR table
using ResultSetMetaData.
*/
package [Link];
import [Link].*;
ResultSet rs = [Link]();
ResultSetMetaData rsmd = [Link]();
/*
slip no 29 Q2. Write a Java program to create LinkedList of integer
objects and perform the following:
i. Add element at first position
ii. Delete last element
iii. Display the size of link list
*/
package [Link];
import [Link].*;
int ch;
do {
[Link]("Menu");
[Link]("1. Insert at head");
[Link]("2. Delete tail.");
[Link]("3. Display size");
[Link]("4. Exit");
[Link]("------------------------------");
[Link]("Enter your choice:");
ch = [Link]();
[Link]();
switch(ch) {
case 1: [Link]("Enter a number:");
[Link]([Link]());
break;
case 2: [Link]();
break;
case 3:
[Link]("Size : " + [Link]() + "\n" + l);
break;
default: [Link]("Invalid choice.");
}
[Link]("-------------------------------");
} while(ch != 4);
}
}
/*
Slip no 30 Q1. Write a java program using Multithreading to demonstrate
drawing Indian flag (Use
Swing
*/
package [Link];
import [Link].*;
import [Link].*;
public IndianFlag() {
setTitle("Simple Temple Drawing");
setSize(300, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
@Override
protected void paintComponent(Graphics g) {
[Link](g);
drawFlag(g);
}
[Link]([Link]);
[Link](50, 100, 200, 50);
[Link]([Link]);
[Link](50, 150, 200, 50);
}
}
public class slip30_1
{
public static void main(String[] args) {
[Link](() -> {
new IndianFlag();
});
}
}