use alertclub
This Commad is use for selecting the Existing Database.
Here alertclub is a name of Database
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class CheckBox extends JFrame implements ItemListener
{
JCheckBox ch1,ch2;
JPanel p1,p2;
Container conn;
CheckBox()
{
conn=getContentPane();
conn.setBackground(Color.WHITE);
p1=new JPanel();p1.setBackground(Color.yellow);
p2=new JPanel();p2.setBackground(Color.red);
ch1=new JCheckBox("Blue",false);ch1.setOpaque(false);
ch2=new JCheckBox("Red",false);ch2.setOpaque(false);
conn.add(ch1);conn.add(ch2);
ch1.addItemListener(this);ch2.addItemListener(this);
}
public void itemStateChanged(ItemEvent e )
{
if (ch1.isSelected()==true)
{
conn.add(p1);p1.setBounds(30,40,50,30);
this.repaint();
}
if(ch1.isSelected()==false)
{
conn.remove(p1);p1.setBounds(30,40,50,30);
this.repaint();
}
if (ch2.isSelected()==true)
{
conn.add(p2);p2.setBounds(100,40,50,30);
this.repaint();
}
if (ch2.isSelected()==false)
{
conn.remove(p2);p2.setBounds(100,40,50,30);
this.repaint();
}
}
public static void main(String[] args)
{
JFrame win = new CheckBox();
win.setTitle("CheckBox");
win.setSize(200,120);
win.setLayout(new FlowLayout());
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
win.setVisible(true);
}
}
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class Radiobutton extends JFrame implements ItemListener
{
JRadioButton first,second,third,fourth;
JPanel p1,p2,p3,p4;
Container conn;
Radiobutton()
{
conn=getContentPane();
conn.setBackground(Color.ORANGE);
p1=new JPanel();
p1.setBackground(Color.blue);
p2=new JPanel();
p2.setBackground(Color.red);
p3=new JPanel();
p3.setBackground(Color.black);
p4=new JPanel();
p4.setBackground(Color.yellow);
first = new JRadioButton("Blue");
second = new JRadioButton("red");
third = new JRadioButton("Black");
fourth = new JRadioButton("Yellow");
//Add on Frame
conn.add(first);conn.add(second);conn.add(third);conn.add(fourth);
ButtonGroup bg = new ButtonGroup();
bg.add(first);bg.add(second);bg.add(third);bg.add(fourth);
first.addItemListener(this);
second.addItemListener(this);
third.addItemListener(this);
fourth.addItemListener(this);
}
public void itemStateChanged(ItemEvent e )
{
if (first.isSelected())
{
conn.add(p1);
conn.remove(p2);conn.remove(p3);conn.remove(p4);
p1.setBounds(40,60,30,30);
this.repaint();
}
if (second.isSelected())
{
conn.add(p2);
conn.remove(p1);conn.remove(p3);conn.remove(p4);
p2.setBounds(100,60,30,30);
this.repaint();
}
if (third.isSelected())
{
conn.add(p3);
conn.remove(p2);conn.remove(p1);conn.remove(p4);
p3.setBounds(160,60,30,30);
this.repaint();
}
if (fourth.isSelected())
{
conn.add(p4);
conn.remove(p2);conn.remove(p3);conn.remove(p1);
p4.setBounds(220,60,30,30);
this.repaint();
}
}
public static void main(String[] args)
{
JFrame win = new Radiobutton();
win.setTitle("Radiobutton");
win.setSize(300,200);
win.setLayout(new FlowLayout());
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
win.setVisible(true);
}
}class Sorting
{
public static void main(String s[])
{
int number[]={55,40,70,80,90,21};
int n=number.length;
System.out.println("Given list:");
for(int i=0;i<n;i++)
{
System.out.println(" "+ number[i]);
}
System.out.println("\n");
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(number[i]<number[j])
{
//interchange values
int temp=number[i];
number[i]=number[j];
number[j]=temp;
}
}
}
System.out.println("sorted list in Descending Order :");
for(int i=0;i<n;i++)
{
System.out.println(" "+ number[i]);
}
System.out.println(" ");
}
}
import java.io.*;
class BufferedWriterDemo
{
public static void main(String args[])
{
try
{
DataInputStream in = new DataInputStream(System.in);
FileWriter fw = new FileWriter("c:/Buffered.java");
BufferedWriter bw = new BufferedWriter(fw);
System.out.println("How many lines?");
int numberOfLines = Integer.parseInt(in.readLine());
String line = "";
for(int i = 0; i < numberOfLines; i++)
{
line = in.readLine();
bw.write(line + "\n"); // throws IOException
}
bw.close();
}
catch(Exception e)
{
System.out.println(" Exception : " + e);
}
}
}
import java.util.Scanner;
public class Char
{
public static void main(String args[])
{
// System.in.Read Version
System.out.print("\n\tSystem.in.Read Version..\n\tEnter Char ==> ");
try
{
char temp = (char)System.in.read();
System.out.printf("\n\tYou Entered: " + temp + "\n");
}
catch(Exception exe)
{
exe.printStackTrace();
}
// Scanner Version
System.out.print("\n\tScanner Version..\n\tEnter Char ==> ");
Scanner kb = new Scanner(System.in);
String tString = kb.next();
char temp2 = tString.charAt(0);
System.out.printf("\n\tYou Entered: " + temp2 + "\n");
}
}import java.io.*;
public class Information
{
public static void main(String s[])
{
String Name,emp;
int a;
DataInputStream in=new DataInputStream(System.in);
try
{
System.out.print("\n\tEnter Your Name:");
Name=in.readLine();
System.out.print("\tEnter Your Age:");
a=Integer.parseInt(in.readLine());
System.out.print("\tEnter Your Employee Code:");
emp=in.readLine();
System.out.println("\n\t---You Entered---\n");
System.out.println("\tName="+Name+"");
System.out.println("\tAge="+a+"");
System.out.println("\tEmployee Code="+emp+"");
}
catch(Exception e)
{}
}
}import java.io.*;
public class Add
{
public static void main(String s[])
{
int a, b,sum=0;
DataInputStream in=new DataInputStream(System.in);
try
{
System.out.print("Enter First Number:");
a=Integer.parseInt(in.readLine());
System.out.print("Enter Second Number:");
b=Integer.parseInt(in.readLine());
sum=a+b;
System.out.println("Sum is "+sum+".");
}
catch(Exception e)
{}
}
}