Showing posts with label program. Show all posts
Showing posts with label program. Show all posts

Java Hotel Management Program (Philippine)

*********************************************************************
COMPLETE SOURCE CODE FOR : TTKH.java
BY : Phi
*********************************************************************


/**
* @(#)TTKH.java
*
* TTKH application
*
* @author
* @version 1.00 2010/3/21
*/
import javax.swing.*;
import java.awt.*;

public class TTKH {

public static void main(String[] args) {
try {
// Set System L&F
UIManager.setLookAndFeel(
UIManager.getSystemLookAndFeelClassName());
}
catch (UnsupportedLookAndFeelException e) {
// handle exception
}
catch (ClassNotFoundException e) {
// handle exception
}
catch (InstantiationException e) {
// handle exception
}
catch (IllegalAccessException e) {
// handle exception
}


//=----------------------------------------------------

// TODO, add your application code
JFrame frame = new JFrame();


JPanel panel = new JPanel();
JPanel khungchitiet = new JPanel();
//JPanel p1 = new JPanel();

//JPanel p2 = new JPanel();
//p2.setLayout(new FlowLayout());
JPanel khungtimkiem = new JPanel();
GridLayout g2 = new GridLayout(2,2);
khungtimkiem.setLayout(new GridLayout(5,2,10,10));
GridLayout g1 = new GridLayout(1,1);
khungchitiet.setLayout(new GridLayout(7,2,10,10));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

// frame.setLocationByPlatform(true);

frame.setSize(680,470);


// Giao dien

JLabel ldemuc = new JLabel("Thong Tin Khach Hang");
ldemuc.setFont(new Font("Tahoma", Font.BOLD, 25));
ldemuc.setLayout(new FlowLayout());
panel.add(ldemuc);



// Khung Chi tiet
JLabel ltenKH = new JLabel("Ten KH");
JTextField ttenKH = new JTextField("Nguyen Van A",1);
JLabel lngaynhan = new JLabel("Ngay Nhan Phong");
JTextField tngaynhan = new JTextField("12/05/2009",1);
JLabel lngaysinh = new JLabel("Ngay Sinh");
JTextField tngaysinh = new JTextField("11/09/1986",1);
JLabel lngaytra = new JLabel("Ngay Tra Phong") ;
JTextField tngaytra = new JTextField("22/05/2009",1);
JLabel lgioitinh = new JLabel("Gioi Tinh");
JTextField tgioitinh = new JTextField("Nam",1);
JLabel lsodt = new JLabel("So Dien Thoai");
JTextField tsodt = new JTextField("0912345677",1);
JLabel lloaiphong = new JLabel("Loai Phong");
JTextField tloaiphong = new JTextField("Vip",1);
JLabel lcmnd = new JLabel("So CMND");
JTextField tcmnd = new JTextField("036365888",1);
JLabel lmaKH = new JLabel("Ma KH");
JTextField tmaKH = new JTextField("001",1);
JLabel lemail = new JLabel("Email");
JTextField temail = new JTextField("nguoidep@gmail.com",1);
JLabel lspace = new JLabel("--------------");
JLabel lspace1 = new JLabel(" ");
JLabel lspace2 = new JLabel("");
JLabel lspace3 = new JLabel("--------------");
JLabel lspace4 = new JLabel(" ");
JLabel lspace5 = new JLabel(" ");
JLabel lchitiet = new JLabel("Chi Tiet Khach Hang") ;
lchitiet.setFont(new Font("Tahoma", Font.BOLD, 15));
JLabel ltimkiem = new JLabel("Tim Kiem Nhanh") ;
ltimkiem.setFont(new Font("Tahoma", Font.BOLD, 15));



khungchitiet.add(lchitiet);
khungchitiet.add(lspace);
khungchitiet.add(lspace1);
khungchitiet.add(lspace2);
//khungchitiet.add(lspace3);
khungchitiet.add(lmaKH);
khungchitiet.add(tmaKH);
khungchitiet.add(lngaynhan);
khungchitiet.add(tngaynhan);
khungchitiet.add(ltenKH);
khungchitiet.add(ttenKH);
khungchitiet.add(lngaytra);
khungchitiet.add(tngaytra);
khungchitiet.add(lgioitinh);
khungchitiet.add(tgioitinh);
khungchitiet.add(lsodt);
khungchitiet.add(tsodt);
khungchitiet.add(lngaysinh);
khungchitiet.add(tngaysinh);
khungchitiet.add(lloaiphong);
khungchitiet.add(tloaiphong);
khungchitiet.add(lcmnd);
khungchitiet.add(tcmnd);
khungchitiet.add(lemail);
khungchitiet.add(temail);
khungchitiet.add(ltimkiem);
khungchitiet.add(lspace3);
khungchitiet.add(lspace4);
khungchitiet.add(lspace5);




// phan tim kiem

JLabel lmaKH2 = new JLabel("Ma KH");
lmaKH2.setForeground(Color.red);
JTextField tmaKH2 = new JTextField("Nhap ma khach hang...");
Choice c1 = new Choice();
c1.addItem("Vip");
c1.addItem("Phong Gia dinh");
c1.addItem("Phong Quat");
c1.addItem("Phong May lanh");
//JLabel lgioitinh2 = new JLabel("Gioi tinh");
//JRadioButton rnam = new JRadioButton("Nam",true);
//JRadioButton rnu = new JRadioButton("Nu",false);
JLabel lngaynhan2 = new JLabel("Ngay Nhan");
lngaynhan2.setForeground(Color.red);
JTextField tngaynhan2 = new JTextField("Nhap ngay nhan dd/mm/yyyy");
JLabel lcmnd2 = new JLabel("So CMND");
JTextField tcmnd2 = new JTextField("Nhap so");
JLabel lngaytra2 = new JLabel("Ngay Tra");
lngaytra2.setForeground(Color.red);
JTextField tngaytra2 = new JTextField("Nhap ngay tra dd/mm/yyyy");
JLabel ltenKH2 = new JLabel("Ten KH");
JTextField ttenKH2 = new JTextField("Nhap ten KH");
JLabel ls1 = new JLabel(" ");
JLabel ls2 = new JLabel(" ");
JLabel ls3 = new JLabel(" ");
JLabel ls4 = new JLabel(" ");
JLabel ls5 = new JLabel(" ");
JLabel ls6 = new JLabel(" ");
JButton b1 = new JButton("Lam Moi");
JButton b2 = new JButton("Tim");
JButton b3 = new JButton("Thoat");
//JLabel ls5 = new JLabel(" ");
JLabel loaiphong = new JLabel("Loai Phong");
khungtimkiem.add(lmaKH2);
khungtimkiem.add(tmaKH2);
khungtimkiem.add(lngaynhan2);
khungtimkiem.add(tngaynhan2);
khungtimkiem.add(ltenKH2);
khungtimkiem.add(ttenKH2);
khungtimkiem.add(lngaytra2);
khungtimkiem.add(tngaytra2);
khungtimkiem.add(lcmnd2);
khungtimkiem.add(tcmnd2);
khungtimkiem.add(ls1);
khungtimkiem.add(ls2);
khungtimkiem.add(loaiphong);
khungtimkiem.add(c1);
khungtimkiem.add(ls3);
khungtimkiem.add(b2);
khungtimkiem.add(ls5);
khungtimkiem.add(ls6);
khungtimkiem.add(b1);
khungtimkiem.add(b3);


frame.setLayout(new BorderLayout());
frame.add(panel, BorderLayout.NORTH);
//frame.add(p1, BorderLayout.LINE_START);
frame.add(khungchitiet, BorderLayout.WEST);
//frame.add(p2, BorderLayout.WEST);
//frame.add(p2, BorderLayout.LINE_END);
frame.add(khungtimkiem, BorderLayout.SOUTH);
frame.setVisible(true);
}
}


*********************************************************************
JUST COMPILE AND EXECUTE IT
*********************************************************************

Call jar file from a java program


Complete source code below will show you, how to open or call a jar file (java executable file) from a java program.

Download MyJarFile.jar that will use in this tutorial.Place this file at the same location with java file below before compile and execute it.

*********************************************************************
COMPLETE SOURCE CODE FOR : CallJarFile.java
*********************************************************************


import java.awt.Desktop;

import java.io.File;

public class CallJarFile
{
public static void main(String[]args)
{
try
{
//Call MyJarFile.jar
Desktop.getDesktop().open(new File("MyJarFile.jar"));
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
}


*********************************************************************
JUST COMPILE AND EXECUTE IT
*********************************************************************

Get all JFrame in program

Source code below will show you how to get all JFrame that contains in a program

*************************************************************************
COMPLETE SOURCE CODE FOR : GetAllJFrameInAnApplication.java
*************************************************************************


import javax.swing.JFrame;

import java.awt.Frame;

public class GetAllJFrameInAnApplication
{
public static void main(String[]args)
{
//Create JFrame with title ( HAHAHAHA )
JFrame frame1=new JFrame("HAHAHAHA");

//Create JFrame with title ( HEHEHEHE )
JFrame frame2=new JFrame("HEHEHEHE");

//Create JFrame with title ( HUHUHUHU )
JFrame frame3=new JFrame("HUHUHUHU");

//Create JFrame with title ( HIHIHIHI )
JFrame frame4=new JFrame("HIHIHIHI");

//Create JFrame with title ( ZZZZZZZZ )
JFrame frame5=new JFrame("ZZZZZZZZ");

//Create array from type Frame.
//Store all JFrame into this array.
Frame[]allJFrame=Frame.getFrames();

//Print each JFrame title in this application
for(int i=0; i<allJFrame.length; i++)
{
System.out.println("JFrame "+(i+1)+" :"+allJFrame[i].getTitle());
}
}
}


*************************************************************************
JUST COMPILE AND EXECUTE IT
*************************************************************************

How to make java program output to a file instead of command prompt like usual ???

This source code will show you how to make java output that print in command prompt will be print in a file instead of command prompt.

**************************************************************
COMPLETE SOURCE CODE FOR : PutCommandPromptOutputToFile.java
**************************************************************


import java.io.PrintStream;

public class PutCommandPromptOutputToFile
{
public static void main(String[]args)
{
try
{
PrintStream newOuputChannel=new PrintStream("output.txt");
System.setOut(newOuputChannel);

System.out.println("HI");
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
}


**************************************************************
JUST COMPILE AND EXECUTE IT
**************************************************************

How to make a program that can press keyboard for you ???


*******************************************************
COMPLETE SOURCE CODE FOR : PressKeyboard.java
*******************************************************


import java.awt.Robot;
import java.awt.event.KeyEvent;

public class PressKeyboard
{
public static void main(String[]args)
{
try
{

Robot a=new Robot();

while(true)
{
//THIS PROGRAM WILL PRESS A FOR YOU
a.keyPress(KeyEvent.VK_A);

//THIS PROGRAM WILL SLEEP FOR 5 second
a.delay(5000);
}
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
}


*******************************************************
JUST COMPILE AND EXECUTE IT
*******************************************************

RELAXING NATURE VIDEO