0% found this document useful (0 votes)
30 views2 pages

Kabilan Java PRG 11 & 14

Uploaded by

Sakshi Jaiswal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

Kabilan Java PRG 11 & 14

Uploaded by

Sakshi Jaiswal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Program 11: private JRadioButton name.

setFont(new
import java.io.*; female; Font("Arial", Font.PLAIN, 20));
public class Prg11 private ButtonGroup
{ gengp; name.setSize(100, 20);
public static void main(String[] args) private JLabel dob;
{ private JComboBox date;
File f1=new File("D:\\java\\ private JComboBox month; name.setLocation(100,
sample.txt"); private JComboBox year; 100);
if(f1.exists()) private JLabel add; c.add(name);
{ private JTextArea tadd;
System.out.println("File exist"); private JCheckBox term; tname = new
} private JButton sub; JTextField();
else private JButton reset;
{ private JTextArea tout; tname.setFont(new
System.out.println("File does not private JLabel res; Font("Arial", Font.PLAIN, 15));
exist"); private JTextArea resadd;
}
tname.setSize(190, 20);
System.out.println("Filename: private String dates[]=
"+f1.getName()); { "1", "2", "3", "4", "5","6", "7", "8",
System.out.println("Filepath:"); "9", "10","11", "12", "13", "14", tname.setLocation(200,
"15","16", "17", "18", "19", "20","21", 100);
"22", "23", "24", "25","26", "27", "28", c.add(tname);
System.out.println(f1.getAbsolutePath
()); "29", "30","31" };
private String months[] mno = new
if(f1.isDirectory())
= { "Jan", "feb", "Mar", JLabel("Mobile");
{
System.out.println("File is a "Apr","May", "Jun", "July",
directory"); "Aug","Sup", "Oct", "Nov", "Dec" }; mno.setFont(new
} private String years[]= Font("Arial", Font.PLAIN, 20));
else { "1995", "1996", "1997",
{ "1998","1999", "2000", "2001",
"2002","2003", "2004", "2005", mno.setSize(100, 20);
System.out.println("File is not a
directory"); "2006","2007", "2008", "2009",
} "2010","2011", "2012", "2013", mno.setLocation(100, 150);
"2014","2015", "2016", "2017", c.add(mno);
"2018","2019" };
System.out.println(f1.canRead()?"can public MyFrame() tmno = new
be read":"can not be read"); { JTextField();

System.out.println(f1.canWrite()?"can setTitle("Admission Form"); tmno.setFont(new


be write":"can not be write"); setBounds(300, Font("Arial", Font.PLAIN, 15));
System.out.println("Length of file 90, 900, 600);
in bytes: "+f1.length());
} tmno.setSize(150, 20);
}
Output: setDefaultCloseOperation(EXIT_ON_CL
tmno.setLocation(200,
File does not exist OSE); 150);
Filename: sample.txt c.add(tmno);
Filepath: setResizable(false);
D:\java\sample.txt gender = new
File is not a directory c= JLabel("Gender");
can not be read getContentPane();
can not be write gender.setFont(new
Length of file in bytes: 0 c.setLayout(null); Font("Arial", Font.PLAIN, 20));
Program 14: title = new
import javax.swing.*; gender.setSize(100, 20);
JLabel("Admission Form");
import java.awt.*;
import java.awt.event.*; gender.setLocation(100,
title.setFont(new 200);
class MyFrame extends JFrame Font("Arial", Font.PLAIN, 30));
c.add(gender);
implements ActionListener { title.setSize(300,
30);
male = new
private Container c; JRadioButton("Male");
private JLabel title; title.setLocation(300, 30);
private JLabel name; c.add(title); male.setFont(new
private JTextField tname;
Font("Arial", Font.PLAIN, 15));
private JLabel mno; name = new
private JTextField tmno; JLabel("Name");
private JLabel gender; male.setSelected(true);
private JRadioButton male; male.setSize(75,
20);
year.setSize(60,
male.setLocation(200, 200); 20);
c.add(male);
year.setLocation(320, 250);
female = new c.add(year);
JRadioButton("Female");
add = new
female.setFont(new JLabel("Address");
Font("Arial", Font.PLAIN, 15));
add.setFont(new
female.setSelected(false); Font("Arial", Font.PLAIN, 20));
tout.setText("");
resadd.setText("");
female.setSize(80, 20); res.setText("Please accept
the"+ " terms & conditions..");
female.setLocation(275, }
200); }
c.add(female); else if (e.getSource() ==
reset)
gengp = new {
ButtonGroup(); String def = "";
tname.setText(def);
tadd.setText(def);
gengp.add(male);
tmno.setText(def);
res.setText(def);
gengp.add(female); tout.setText(def);
term.setSelected(false);
dob = new date.setSelectedIndex(0);
JLabel("DOB");
month.setSelectedIndex(0);
dob.setFont(new year.setSelectedIndex(0);
Font("Arial", Font.PLAIN, 20)); resadd.setText(def);
dob.setSize(100, }
20); }
}
dob.setLocation(100, 250);
c.add(dob); class Registration
{
date = new public static void
JComboBox(dates); main(String[] args) throws Exception
{
MyFrame f =
date.setFont(new new MyFrame();
Font("Arial", Font.PLAIN, 15)); }
date.setSize(50, }
20);
Output:

date.setLocation(200, 250);
c.add(date);

month = new
JComboBox(months);

month.setFont(new
Font("Arial", Font.PLAIN, 15));

month.setSize(60, 20);

month.setLocation(250,
250);
c.add(month);

year = new
JComboBox(years);

year.setFont(new
Font("Arial", Font.PLAIN, 15));

You might also like