public hostelStatus() { setTitle("Hostel"); connect(); updateRecord(); JFrame fr = new JFrame(); Toolkit tkt = fr.getToolkit(); Dimension frsize = tkt.getScreenSize(); setBounds(frsize.width / 4, frsize.height / 12, frsize.width / 2, frsize.height / 8); setLayout(null); cn = getContentPane(); cn.setBackground(new Color(190, 180, 170)); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); tl = new JLabel("Current Hostels Status"); tl.setFont(new Font("Engravers MT", 1, 25)); tl.setForeground(new Color(247, 251, 249)); p1 = new JPanel(); p1.setBounds(0, 0, 600, 50); p1.add(tl); p1.setBackground(new Color(31, 88, 166)); cn.add(p1); b1 = new JButton("LOAD"); b1.setMnemonic('L'); b1.addActionListener(new dispListener()); b1.setBounds(230, 320, 120, 30); b2 = new JButton("EXIT"); b2.setMnemonic('X'); b2.addActionListener(new exitListener()); b2.setBounds(350, 320, 100, 30); cn.add(b1); cn.add(b2); table = new JTable(data, col); table.setFont(new Font("Serif", Font.BOLD, 16)); table.setBackground(new Color(250, 250, 250)); table.setEnabled(false); JScrollPane jsp = new JScrollPane(table); jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); jsp.setBounds(5, 100, 590, 200); cn.add(jsp); screensize = Toolkit.getDefaultToolkit().getScreenSize(); setSize(600, 400); setVisible(true); setVisible(true); setResizable(true); connect(); }
public EchoAWT() throws UnknownHostException { super("채팅 프로그램"); // 각종 정의 h = new JPanel(new GridLayout(2, 3)); m = new JPanel(new BorderLayout()); f = new JPanel(new BorderLayout()); s = new JPanel(new BorderLayout()); login = new JPanel(new BorderLayout()); // name = new JLabel(" 사용자 이름 "); name = new JLabel(" 메세지 입력 "); jta = new JTextArea(); // clientList = new JTextArea(0, 10); clientList = new JList(); jsp = new JScrollPane(jta); list = new JScrollPane(clientList); jtf = new JTextField("입력하세요."); hi = new JTextField("HOST IP 입력"); pi = new JTextField("PORT 입력"); localport = new JTextField("원하는 PORT 입력"); lid = new JTextField("ID를 입력하세요."); lpw = new JTextField("PW를 입력하세요."); serveropen = new JButton("서버 오픈"); textin = new JButton("입력"); clientin = new JButton("서버 접속"); conf = new JButton("로그인"); join = new JButton("회원가입"); addr = InetAddress.getLocalHost(); // 사용자 해상도 및 창 크기 설정 및 가져오기. Toolkit tk = Toolkit.getDefaultToolkit(); Dimension screenSize = tk.getScreenSize(); setSize(500, 500); Dimension d = getSize(); // 각종 버튼 및 텍스트 필드 리스너 jtf.addActionListener(this); hi.addActionListener(this); pi.addActionListener(this); localport.addActionListener(this); lid.addActionListener(this); lpw.addActionListener(this); conf.addActionListener(this); join.addActionListener(this); serveropen.addActionListener(this); clientin.addActionListener(this); textin.addActionListener(this); jtf.addFocusListener(this); hi.addFocusListener(this); pi.addFocusListener(this); localport.addFocusListener(this); lid.addFocusListener(this); lpw.addFocusListener(this); // 서버 접속 h.add(hi); h.add(pi); h.add(clientin); // 서버 생성 h.add(new JLabel("IP : " + addr.getHostAddress(), (int) CENTER_ALIGNMENT)); h.add(localport); h.add(serveropen); // 채팅글창 글 작성 막기 jta.setEditable(false); // 접속자 리스트 width 제한 clientList.setFixedCellWidth(d.width / 3); // 입력 창 f.add(name, "West"); f.add(jtf, "Center"); f.add(textin, "East"); // 접속자 확인창 s.add(new JLabel("접속자", (int) CENTER_ALIGNMENT), "North"); s.add(list, "Center"); // clientList.setEditable(false); // 메인 창 m.add(jsp, "Center"); m.add(s, "East"); // 프레임 설정 add(h, "North"); add(m, "Center"); add(f, "South"); // 로그인 다이얼로그 jd = new JDialog(); jd.setTitle("채팅 로그인"); jd.add(login); jd.setSize(200, 200); Dimension dd = jd.getSize(); jd.setLocation(screenSize.width / 2 - (dd.width / 2), screenSize.height / 2 - (dd.height / 2)); jd.setVisible(true); // 로그인창 JPanel lm = new JPanel(new GridLayout(4, 1)); lm.add(lid); lm.add(new Label()); lm.add(lpw); lm.add(new Label()); JPanel bt = new JPanel(); bt.add(conf); bt.add(join); login.add(new Label(), "North"); login.add(new Label(), "West"); login.add(new Label(), "East"); login.add(lm, "Center"); login.add(bt, "South"); // 창의 위치, 보임, EXIT 단추 활성화. setLocation(screenSize.width / 2 - (d.width / 2), screenSize.height / 2 - (d.height / 2)); setVisible(false); setDefaultCloseOperation(EXIT_ON_CLOSE); }
Head() { setTitle("Head Office"); setLocation(440, 80); f1.setLayout(null); Toolkit kit = Toolkit.getDefaultToolkit(); Dimension screenSize = kit.getScreenSize(); int screenHeight = screenSize.height - 30; // int screenWidth = screenSize.width; setSize(800, 738); // System.out.println(screenHeight); setResizable(false); // setSize(800,800); lno = new JLabel("Head office Number :"); lname = new JLabel(" Name :"); contact = new JLabel(" Contact :"); address = new JLabel(" Address :"); state = new JLabel(" State :"); startdate = new JLabel(" Start Date :"); howmany = new JLabel(" Total Employee :"); t1 = new JTextField(10); t2 = new JTextField(10); t3 = new JTextField(10); t4 = new JTextField(10); t5 = new JTextField(10); t6 = new JTextField(10); t7 = new JTextField(10); add = new JButton(" Add"); ok = new JButton("OK"); ok.addActionListener(this); add.addActionListener(this); taddress = new JTextArea(15, 20); scrpn = new JScrollPane(taddress); f1.add(lno); f1.add(t1); f1.add(lname); f1.add(t2); f1.add(contact); f1.add(t3); f1.add(t4); f1.add(add); f1.add(t5); f1.add(address); f1.add(scrpn); f1.add(state); f1.add(t6); f1.add(t7); f1.add(howmany); f1.add(startdate); b6 = new JButton( "Exit"); // , new ImageIcon(ClassLoader.getSystemResource("Images/update.png"))); b7 = new JButton("View"); b6.setBounds(180, 370, 100, 30); b7.setBounds(50, 370, 100, 30); add(b6); add(b7); b6.addActionListener(this); b7.addActionListener(this); lno.setBounds(10, 25, 150, 25); t1.setBounds(150, 23, 125, 25); lname.setBounds(10, 67, 150, 25); t2.setBounds(150, 67, 150, 25); contact.setBounds(10, 110, 150, 25); t3.setBounds(150, 110, 125, 25); state.setBounds(10, 153, 150, 25); t4.setBounds(150, 153, 125, 25); startdate.setBounds(10, 196, 150, 25); t5.setBounds(150, 196, 125, 25); address.setBounds(10, 239, 150, 25); t7.setBounds(150, 239, 250, 25); // scrpn.setBounds(150,239,200,50); howmany.setBounds(10, 310, 150, 25); t6.setBounds(150, 310, 125, 25); ok.setBounds(190, 420, 90, 25); setSize(445, 500); add(f1, BorderLayout.CENTER); setVisible(true); try { Class.forName("com.mysql.jdbc.Driver"); System.out.println("Driver loaded Succesfull"); cn = DriverManager.getConnection("jdbc:mysql://127.0.0.1/payroll", "root", "root"); System.out.println("Connection Succesfull"); st = cn.createStatement(); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Error is" + e); } }