import java.awt.*;
import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.swing.*;
public class View extends JPanel {
private JFrame f = new JFrame("123");
private JMenuBar menuBar = new JMenuBar();
public View() {
f = new JFrame("호텔 관리 시스템");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(this);
f.setSize(700, 700);
f.setVisible(true);
createMenu();
createNameText();
reservedRoom();
enrollAndcheck();
}
public void paintComponent(Graphics g) {
GregorianCalendar Y = new GregorianCalendar();
int l = Y.get(Calendar.YEAR);
int m = Y.get(Calendar.MONTH) + 1;
int n = Y.get(Calendar.DATE);
g.setColor(Color.BLACK);
g.drawRect(100, 50, 500, 40);
Font f = new Font("", Font.BOLD, 20);
g.setFont(f);
g.drawString("123", 250, 75);
Font k = new Font("", Font.BOLD, 14);
g.setFont(k);
g.drawString("투숙예약", 40, 120);
g.drawString("객실현황", 360, 120);
g.drawString("(" + l + "/0" + m + "/" + n + ")", 550, 120);
g.drawString("등록/조회", 40, 400);
Font j = new Font("", 6, 12);
g.setFont(j);
}
private void createMenu() {
menuBar = new JMenuBar();
JMenu fileMenu = menuBar.add(new JMenu("File"));
JMenuItem saveMenuItem = fileMenu.add(new JMenuItem("Open"));
saveMenuItem.setActionCommand("load");
f.setJMenuBar(menuBar);
}
private void createNameText() {
JPanel formPanel1 = new JPanel();
f.getContentPane().add(BorderLayout.CENTER, formPanel1);
formPanel1.setBounds(30, 130, 300, 250);
formPanel1.setBackground(Color.white);JLabel label1 = new JLabel("고객명");
JLabel label2 = new JLabel("체크인(YYYYMMDD)");
JLabel label3 = new JLabel("박");
JLabel label4 = new JLabel("객실");
label1.setBounds(10, 10, 40, 40);
label2.setBounds(10, 50, 120, 40);
label3.setBounds(10, 90, 40, 40);
label4.setBounds(10, 130, 40, 40);
formPanel1.add(label1);
formPanel1.add(label2);
formPanel1.add(label3);
formPanel1.add(label4);
JTextField field1 = new JTextField(10);
JTextField field2 = new JTextField(10);
field1.setBounds(150, 10, 120, 20);
field2.setBounds(150, 50, 120, 20);
formPanel1.add(field1);
formPanel1.add(field2);
JComboBox jcb1 = new JComboBox();
for (int i = 1; i <= 5; i++) {
jcb1.addItem(i);
}
jcb1.setBounds(150, 90, 120, 20);
formPanel1.add(jcb1);
JComboBox jcb2 = new JComboBox();
for (int i = 0; i < 10; i++) {
jcb2.addItem(101 + i);
}
for (int i = 0; i < 10; i++) {
jcb2.addItem(201 + i);
}
jcb2.setBounds(150, 130, 120, 20);
formPanel1.add(jcb2);
JButton but1 = new JButton("예약 등록/변경");
JButton but2 = new JButton("예약취소");
but1.setBounds(0, 180, 120, 30);
but2.setBounds(150, 180, 120, 30);
formPanel1.add(but1);
formPanel1.add(but2);
this.setVisible(true);
}
private void reservedRoom() {
JPanel formPanel2 = new JPanel();
f.getContentPane().add(BorderLayout.CENTER, formPanel2);
formPanel2.setBounds(350, 130, 330, 250);
formPanel2.setBackground(Color.white);
JButton[] but3 = new JButton[20];
for (int i = 0; i < 5; i++) {
but3[i] = new JButton(i + 101 + "");
}
for (int i = 0; i < 5; i++) {
formPanel2.add(but3[i]);
but3[i].setBounds(56 * i + 10, 5, 55, 45);
but3[i].setBackground(Color.white);
}
for (int i = 5; i < 10; i++) {
but3[i] = new JButton(i + 101 + "");
}
for (int i = 5; i < 10; i++) {
formPanel2.add(but3[i]);
but3[i].setBounds(56 * (i - 5) + 10, 55, 55, 45);
but3[i].setBackground(Color.white);
}
for (int i = 10; i < 15; i++) {
but3[i] = new JButton(i + 191 + "");
}
for (int i = 10; i < 15; i++) {
formPanel2.add(but3[i]);
but3[i].setBounds(56 * (i - 10) + 10, 105, 55, 45);
but3[i].setBackground(Color.white);
}
for (int i = 15; i < 20; i++) {
but3[i] = new JButton(i + 191 + "");
}
for (int i = 15; i < 20; i++) {
formPanel2.add(but3[i]);
but3[i].setBounds(56 * (i - 15) + 10, 155, 55, 45);
but3[i].setBackground(Color.white);
}
this.setVisible(true);
}
public void enrollAndcheck(){
JTabbedPane jtb = new JTabbedPane(JTabbedPane.TOP);
f.getContentPane().add(BorderLayout.CENTER, jtb);
jtb.setBounds(60, 430, 550, 170);
jtb.addTab("손님", customer());
}
public JComponent customer() {
JPanel formPanel4 = new JPanel();
f.getContentPane().add(BorderLayout.CENTER, formPanel4);
formPanel4.setBackground(Color.black);
return formPanel4;
}
}
import javax.swing.*;
public class Hotelreservation extends JPanel {
public static void main(String args[]) {
new View();
}
}
클래스 2개만들어서 짯는데효...
JTabbedPane를 저위치에 하고싶은데 저위치에 하닌깐 계속 망가짐요....
원래상태보고싶으면 enrollAndcheck() 쪽 다지우시면 볼수있어욥...
댓글 0