public PanelSpec(SmedAction dia) { dlg = dia; setLayout(null); add(getShapeButton(pillarButton, 0, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYSPP)); add(getShapeButton(sparButton, 34, 0, 34, 32, "Spar", Shp.SPAR, Obj.BOYSPP)); add(getShapeButton(canButton, 68, 0, 34, 32, "Can", Shp.CAN, Obj.BOYSPP)); add(getShapeButton(coneButton, 102, 0, 34, 32, "Cone", Shp.CONI, Obj.BOYSPP)); add(getShapeButton(sphereButton, 0, 32, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYSPP)); add(getShapeButton(barrelButton, 34, 32, 34, 32, "Barrel", Shp.BARREL, Obj.BOYSPP)); add(getShapeButton(superButton, 68, 32, 34, 32, "Super", Shp.SUPER, Obj.BOYSPP)); add(getShapeButton(floatButton, 102, 32, 34, 32, "Float", Shp.FLOAT, Obj.LITFLT)); add(getShapeButton(beaconButton, 0, 64, 34, 32, "Beacon", Shp.BEACON, Obj.BCNSPP)); add(getShapeButton(towerButton, 34, 64, 34, 32, "TowerB", Shp.TOWER, Obj.BCNSPP)); add(getShapeButton(stakeButton, 68, 64, 34, 32, "Stake", Shp.STAKE, Obj.BCNSPP)); add(getShapeButton(cairnButton, 102, 64, 34, 32, "CairnB", Shp.CAIRN, Obj.BCNSPP)); categoryLabel = new JLabel(Messages.getString("Category"), SwingConstants.CENTER); categoryLabel.setBounds(new Rectangle(5, 125, 160, 18)); add(categoryLabel); categoryBox = new JComboBox(); categoryBox.setBounds(new Rectangle(5, 142, 160, 18)); add(categoryBox); categoryBox.setVisible(true); categoryBox.addActionListener(alCategoryBox); addCatItem("", Cat.NOCAT); addCatItem(Messages.getString("UKPurpose"), Cat.SPM_UNKN); addCatItem(Messages.getString("Warning"), Cat.SPM_WARN); addCatItem(Messages.getString("ChanSeparation"), Cat.SPM_CHBF); addCatItem(Messages.getString("Yachting"), Cat.SPM_YCHT); addCatItem(Messages.getString("Cable"), Cat.SPM_CABL); addCatItem(Messages.getString("Outfall"), Cat.SPM_OFAL); addCatItem(Messages.getString("ODAS"), Cat.SPM_ODAS); addCatItem(Messages.getString("RecreationZone"), Cat.SPM_RECN); addCatItem(Messages.getString("Mooring"), Cat.SPM_MOOR); addCatItem(Messages.getString("LANBY"), Cat.SPM_LNBY); addCatItem(Messages.getString("Leading"), Cat.SPM_LDNG); addCatItem(Messages.getString("Notice"), Cat.SPM_NOTC); addCatItem(Messages.getString("TSS"), Cat.SPM_TSS); addCatItem(Messages.getString("FoulGround"), Cat.SPM_FOUL); addCatItem(Messages.getString("Diving"), Cat.SPM_DIVE); addCatItem(Messages.getString("FerryCross"), Cat.SPM_FRRY); addCatItem(Messages.getString("Anchorage"), Cat.SPM_ANCH); mooringBox = new JComboBox(); mooringBox.setBounds(new Rectangle(5, 142, 160, 18)); add(mooringBox); mooringBox.setVisible(false); mooringBox.addActionListener(alMooringBox); addMorItem("", Cat.NOCAT); addMorItem(Messages.getString("Dolphin"), Cat.MOR_DLPN); addMorItem(Messages.getString("DevDolphin"), Cat.MOR_DDPN); addMorItem(Messages.getString("Bollard"), Cat.MOR_BLRD); addMorItem(Messages.getString("Wall"), Cat.MOR_WALL); addMorItem(Messages.getString("Post"), Cat.MOR_POST); addMorItem(Messages.getString("Chain"), Cat.MOR_CHWR); addMorItem(Messages.getString("Rope"), Cat.MOR_ROPE); addMorItem(Messages.getString("Automatic"), Cat.MOR_AUTO); addMorItem(Messages.getString("MooringBuoy"), Cat.MOR_BUOY); addMorItem(Messages.getString("CALM"), Cat.INB_CALM); addMorItem(Messages.getString("SBM"), Cat.INB_SBM); topmarkButton.setBounds(new Rectangle(136, 0, 34, 32)); topmarkButton.setToolTipText(Messages.getString("Topmark")); topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder()); topmarkButton.addActionListener(alTop); add(topmarkButton); // noticeButton.setBounds(new Rectangle(136, 32, 34, 32)); // noticeButton.setToolTipText(Messages.getString("Notice")); // noticeButton.setBorder(BorderFactory.createLoweredBevelBorder()); // noticeButton.addActionListener(alNotice); // add(noticeButton); mooringButton.setBounds(new Rectangle(136, 64, 34, 32)); mooringButton.setToolTipText(Messages.getString("Mooring")); mooringButton.setBorder(BorderFactory.createLoweredBevelBorder()); mooringButton.addActionListener(alMooring); add(mooringButton); }
public PanelMore(OSeaMAction dia) { dlg = dia; setLayout(null); panelPat = new PanelPat(dlg, Ent.BODY); panelPat.setBounds(new Rectangle(0, 0, 110, 160)); add(panelPat); add(getRegionButton(regionAButton, 110, 0, 34, 30, "RegionA")); add(getRegionButton(regionBButton, 110, 32, 34, 30, "RegionB")); add(getRegionButton(regionCButton, 110, 64, 34, 30, "RegionC")); elevLabel = new JLabel(Messages.getString("Elevation"), SwingConstants.CENTER); elevLabel.setBounds(new Rectangle(140, 0, 90, 20)); add(elevLabel); elevBox = new JTextField(); elevBox.setBounds(new Rectangle(160, 20, 50, 20)); elevBox.setHorizontalAlignment(SwingConstants.CENTER); add(elevBox); elevBox.addFocusListener(flElev); heightLabel = new JLabel(Messages.getString("Height"), SwingConstants.CENTER); heightLabel.setBounds(new Rectangle(140, 40, 90, 20)); add(heightLabel); heightBox = new JTextField(); heightBox.setBounds(new Rectangle(160, 60, 50, 20)); heightBox.setHorizontalAlignment(SwingConstants.CENTER); add(heightBox); heightBox.addFocusListener(flHeight); sourceLabel = new JLabel(Messages.getString("Source"), SwingConstants.CENTER); sourceLabel.setBounds(new Rectangle(110, 80, 130, 20)); add(sourceLabel); sourceBox = new JTextField(); sourceBox.setBounds(new Rectangle(110, 100, 130, 20)); sourceBox.setHorizontalAlignment(SwingConstants.CENTER); add(sourceBox); sourceBox.addFocusListener(flSource); infoLabel = new JLabel(Messages.getString("Information"), SwingConstants.CENTER); infoLabel.setBounds(new Rectangle(110, 120, 130, 20)); add(infoLabel); infoBox = new JTextField(); infoBox.setBounds(new Rectangle(110, 140, 130, 20)); infoBox.setHorizontalAlignment(SwingConstants.CENTER); add(infoBox); infoBox.addFocusListener(flInfo); statusLabel = new JLabel(Messages.getString("Status"), SwingConstants.CENTER); statusLabel.setBounds(new Rectangle(250, 0, 100, 20)); add(statusLabel); statusBox = new JComboBox(); statusBox.setBounds(new Rectangle(250, 20, 100, 20)); addStsItem("", Sts.UNKSTS); addStsItem(Messages.getString("Permanent"), Sts.PERM); addStsItem(Messages.getString("Occasional"), Sts.OCC); addStsItem(Messages.getString("Recommended"), Sts.REC); addStsItem(Messages.getString("NotInUse"), Sts.NIU); addStsItem(Messages.getString("Intermittent"), Sts.INT); addStsItem(Messages.getString("Reserved"), Sts.RESV); addStsItem(Messages.getString("Temporary"), Sts.TEMP); addStsItem(Messages.getString("Private"), Sts.PRIV); addStsItem(Messages.getString("Mandatory"), Sts.MAND); addStsItem(Messages.getString("Destroyed"), Sts.DEST); addStsItem(Messages.getString("Extinguished"), Sts.EXT); addStsItem(Messages.getString("Illuminated"), Sts.ILLUM); addStsItem(Messages.getString("Historic"), Sts.HIST); addStsItem(Messages.getString("Public"), Sts.PUB); addStsItem(Messages.getString("Synchronized"), Sts.SYNC); addStsItem(Messages.getString("Watched"), Sts.WATCH); addStsItem(Messages.getString("UnWatched"), Sts.UNWAT); addStsItem(Messages.getString("Doubtful"), Sts.DOUBT); add(statusBox); statusBox.addActionListener(alStatus); constrLabel = new JLabel(Messages.getString("Construction"), SwingConstants.CENTER); constrLabel.setBounds(new Rectangle(250, 40, 100, 20)); add(constrLabel); constrBox = new JComboBox(); constrBox.setBounds(new Rectangle(250, 60, 100, 20)); addCnsItem("", Cns.UNKCNS); addCnsItem(Messages.getString("Masonry"), Cns.BRICK); addCnsItem(Messages.getString("Concreted"), Cns.CONC); addCnsItem(Messages.getString("Boulders"), Cns.BOULD); addCnsItem(Messages.getString("HardSurfaced"), Cns.HSURF); addCnsItem(Messages.getString("Unsurfaced"), Cns.USURF); addCnsItem(Messages.getString("Wooden"), Cns.WOOD); addCnsItem(Messages.getString("Metal"), Cns.METAL); addCnsItem(Messages.getString("GRP"), Cns.GLAS); addCnsItem(Messages.getString("Painted"), Cns.PAINT); add(constrBox); constrBox.addActionListener(alConstr); conLabel = new JLabel(Messages.getString("Conspicuity"), SwingConstants.CENTER); conLabel.setBounds(new Rectangle(250, 80, 100, 20)); add(conLabel); conBox = new JComboBox(); conBox.setBounds(new Rectangle(250, 100, 100, 20)); addConItem("", Con.UNKCON); addConItem(Messages.getString("Conspicuous"), Con.CONSP); addConItem(Messages.getString("NotConspicuous"), Con.NCONS); add(conBox); conBox.addActionListener(alCon); reflLabel = new JLabel(Messages.getString("Reflectivity"), SwingConstants.CENTER); reflLabel.setBounds(new Rectangle(250, 120, 100, 20)); add(reflLabel); reflBox = new JComboBox(); reflBox.setBounds(new Rectangle(250, 140, 100, 20)); addReflItem("", Con.UNKCON); addReflItem(Messages.getString("Conspicuous"), Con.CONSP); addReflItem(Messages.getString("NotConspicuous"), Con.NCONS); addReflItem(Messages.getString("Reflector"), Con.REFL); add(reflBox); reflBox.addActionListener(alRefl); }
public static void main(String args[]) { // style that is necessary try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e) { } catch (InstantiationException e) { } catch (IllegalAccessException e) { } catch (UnsupportedLookAndFeelException e) { } // Standard preparation for a frame fmain = new JFrame("Schedule Appointments"); // Create and name frame fmain.setSize(330, 375); // Set size to 400x400 pixels pane = fmain.getContentPane(); pane.setLayout(null); // Apply null layout fmain.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Close when X is clicked // controls and portions of Calendar lmonth = new JLabel("January"); lyear = new JLabel("Change year:"); cyear = new JComboBox(); prev = new JButton("<<"); next = new JButton(">>"); canc = new JButton("Cancel"); mcal = new DefaultTableModel() { public boolean isCellEditable(int rowIndex, int mColIndex) { return false; } }; Cal = new JTable(mcal); scal = new JScrollPane(Cal); pcal = new JPanel(null); canc.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0); } }); // action listeners for buttons and the like prev.addActionListener(new btnPrev_Action()); next.addActionListener(new btnNext_Action()); cyear.addActionListener(new cmbYear_Action()); Cal.addMouseListener(new mouseCont()); // Adding the elements to the pane pane.add(pcal); pcal.add(lmonth); pcal.add(cyear); pcal.add(prev); pcal.add(next); pcal.add(canc); pcal.add(scal); // Setting where the elements are on the pane pcal.setBounds(0, 0, 320, 335); lmonth.setBounds(160 - lmonth.getPreferredSize().width / 2, 25, 100, 25); canc.setBounds(10, 305, 80, 20); cyear.setBounds(215, 305, 100, 20); prev.setBounds(10, 25, 50, 25); next.setBounds(260, 25, 50, 25); scal.setBounds(10, 50, 300, 250); // Make frame visible fmain.setResizable(false); fmain.setVisible(true); // Inner workings for the day mechanism GregorianCalendar cal = new GregorianCalendar(); // Create calendar rday = cal.get(GregorianCalendar.DAY_OF_MONTH); // Get day rmonth = cal.get(GregorianCalendar.MONTH); // Get month ryear = cal.get(GregorianCalendar.YEAR); // Get year currentMonth = rmonth; // Match month and year currentYear = ryear; // Add days String[] days = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; // All of the days for (int i = 0; i < 7; i++) { mcal.addColumn(days[i]); } Cal.getParent().setBackground(Cal.getBackground()); // Set background // No resize/reorder Cal.getTableHeader().setResizingAllowed(false); Cal.getTableHeader().setReorderingAllowed(false); // Single cell selection Cal.setColumnSelectionAllowed(true); Cal.setRowSelectionAllowed(true); Cal.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // Set row/column count Cal.setRowHeight(38); mcal.setColumnCount(7); mcal.setRowCount(6); // Placing the dates in the cells for (int i = ryear - 100; i <= ryear + 100; i++) { cyear.addItem(String.valueOf(i)); } // Refresh calendar refreshCalendar(rmonth, ryear); // Refresh calendar }
/** Create the frame. */ public SotrudnikDialog() { setTitle( "\u041D\u043E\u0432\u044B\u0439 \u0441\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A"); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setBounds(100, 100, 450, 330); contentPane = new JPanel(); contentPane.setBackground(new Color(255, 204, 255)); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JLabel label_familiya = new JLabel("\u0424\u0430\u043C\u0438\u043B\u0438\u044F"); label_familiya.setBounds(10, 37, 110, 14); contentPane.add(label_familiya); JLabel label_imya = new JLabel("\u0418\u043C\u044F"); label_imya.setBounds(10, 62, 110, 14); contentPane.add(label_imya); JLabel label_otchestvo = new JLabel("\u041E\u0442\u0447\u0435\u0441\u0442\u0432\u043E"); label_otchestvo.setBounds(10, 87, 110, 14); contentPane.add(label_otchestvo); textField_otchestvo = new JTextField(); textField_otchestvo.setBounds(167, 84, 186, 20); contentPane.add(textField_otchestvo); textField_otchestvo.setColumns(10); textField_imya = new JTextField(); textField_imya.setBounds(167, 58, 186, 20); contentPane.add(textField_imya); textField_imya.setColumns(10); textField_familiya = new JTextField(); textField_familiya.setBounds(167, 33, 186, 20); contentPane.add(textField_familiya); textField_familiya.setColumns(10); JLabel label_data_priema = new JLabel( "\u0414\u0430\u0442\u0430 \u043F\u0440\u0438\u0435\u043C\u0430 \u043D\u0430 \u0440\u0430\u0431\u043E\u0442\u0443"); label_data_priema.setBounds(10, 112, 147, 14); contentPane.add(label_data_priema); JLabel label_phone = new JLabel("\u0422\u0435\u043B\u0435\u0444\u043E\u043D"); label_phone.setBounds(10, 137, 134, 14); contentPane.add(label_phone); JLabel label_doljnost = new JLabel("\u0414\u043E\u043B\u0436\u043D\u043E\u0441\u0442\u044C"); label_doljnost.setBounds(10, 162, 140, 14); contentPane.add(label_doljnost); JLabel label_kvalification = new JLabel("\u041A\u0432\u0430\u043B\u0438\u0444\u0438\u043A\u0430\u0446\u0438\u044F"); label_kvalification.setBounds(10, 190, 147, 14); contentPane.add(label_kvalification); textField_phone = new JTextField(); textField_phone.setBounds(167, 134, 186, 20); contentPane.add(textField_phone); textField_phone.setColumns(10); textField_date.setBounds(167, 109, 186, 20); contentPane.add(textField_date); label_id_hidden.setFont(new Font("Tahoma", Font.BOLD, 12)); label_id_hidden.setBounds(143, 11, 122, 14); contentPane.add(label_id_hidden); button_insert.setBounds(83, 230, 160, 23); contentPane.add(button_insert); button_cancel.setBounds(264, 230, 104, 23); contentPane.add(button_cancel); button_update.setBounds(83, 230, 160, 23); contentPane.add(button_update); JButton button_plus_doljnost = new JButton("+"); button_plus_doljnost.addActionListener( new ActionListener() { @SuppressWarnings("deprecation") public void actionPerformed(ActionEvent arg0) { DoljnostDialog d = new DoljnostDialog(); d.setTitle("Добавление должности"); d.show(); } }); button_plus_doljnost.setBounds(359, 159, 41, 23); contentPane.add(button_plus_doljnost); JButton button_plus_kvalification = new JButton("+"); button_plus_kvalification.addActionListener( new ActionListener() { @SuppressWarnings("deprecation") public void actionPerformed(ActionEvent arg0) { KvalificationDialog d = new KvalificationDialog(); d.setTitle("Добавление квалификации"); d.show(); } }); button_plus_kvalification.setBounds(359, 184, 41, 23); contentPane.add(button_plus_kvalification); JLabel label = new JLabel( "\u041F\u043E\u043B\u044F, \u043E\u0442\u043C\u0435\u0447\u0435\u043D\u043D\u044B\u0435 "); label.setBounds(60, 264, 122, 14); contentPane.add(label); JLabel label_3 = new JLabel("*"); label_3.setForeground(Color.RED); label_3.setFont(new Font("Tahoma", Font.BOLD, 11)); label_3.setBounds(186, 264, 12, 14); contentPane.add(label_3); JLabel label_4 = new JLabel( "\u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u044B \u0434\u043B\u044F \u0437\u0430\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u044F!"); label_4.setBounds(197, 264, 203, 14); contentPane.add(label_4); JLabel label_5 = new JLabel("*"); label_5.setForeground(Color.RED); label_5.setFont(new Font("Tahoma", Font.BOLD, 11)); label_5.setBounds(356, 37, 12, 14); contentPane.add(label_5); JLabel label_1 = new JLabel("*"); label_1.setForeground(Color.RED); label_1.setFont(new Font("Tahoma", Font.BOLD, 11)); label_1.setBounds(356, 62, 12, 14); contentPane.add(label_1); comboBox_doljnost.setBounds(167, 159, 186, 20); contentPane.add(comboBox_doljnost); comboBox_kvalification.setBounds(167, 187, 186, 20); contentPane.add(comboBox_kvalification); // Actions for button "Добавить" button_insert.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (!textField_familiya.getText().equals("") && !textField_imya.getText().equals("")) { try { Sotrudnik s = new Sotrudnik(); s.setFamiliya(textField_familiya.getText()); s.setImya(textField_imya.getText()); s.setOtchestvo(textField_otchestvo.getText()); s.setData_priema(Date.valueOf(textField_date.getText())); s.setPhone(textField_phone.getText()); Doljnost d = (Doljnost) comboBox_doljnost.getSelectedItem(); s.setId_doljnosti(d.getId_doljnosti()); Kvalification k = (Kvalification) comboBox_kvalification.getSelectedItem(); s.setId_kvalification(k.getId_kvalification()); DBClass db = new DBClass(); db.sotrudnikUpsert(s, "INSERT"); MyFrame.updateList(); ZakazDialog.updateSotrudnik(); } catch (SQLException e) { e.printStackTrace(); JOptionPane.showMessageDialog(panelException, e.getMessage()); } catch (ClassNotFoundException ee) { ee.printStackTrace(); JOptionPane.showMessageDialog(panelException, ee.getMessage()); } finally { dispose(); } } else JOptionPane.showMessageDialog(null, "Введите обязательные параметры!"); } }); // Actions for button "Отмена" button_cancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { dispose(); } }); // Actions for button "Сохранить изменения" button_update.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (!textField_familiya.getText().equals("") && !textField_imya.getText().equals("") && !textField_date.getText().equals("")) { if (textField_date.getText().length() == 10) { try { Integer.parseInt((textField_date.getText().substring(0, 3))); Integer.parseInt((textField_date.getText().substring(5, 6))); Integer.parseInt((textField_date.getText().substring(8, 9))); Sotrudnik s = new Sotrudnik(); s.setId_sotrudnika(Integer.parseInt(label_id_hidden.getText())); s.setFamiliya(textField_familiya.getText()); s.setImya(textField_imya.getText()); s.setOtchestvo(textField_otchestvo.getText()); s.setPhone(textField_phone.getText()); Doljnost d = (Doljnost) comboBox_doljnost.getSelectedItem(); s.setId_doljnosti(d.getId_doljnosti()); Kvalification k = (Kvalification) comboBox_kvalification.getSelectedItem(); s.setId_kvalification(k.getId_kvalification()); DBClass db = new DBClass(); db.sotrudnikUpsert(s, "UPDATE"); MyFrame.updateList(); dispose(); } catch (NumberFormatException e) { JOptionPane.showMessageDialog(panelException, e.getMessage()); } catch (SQLException e) { // e.printStackTrace(); JOptionPane.showMessageDialog(panelException, e.getMessage()); } catch (ClassNotFoundException ee) { // ee.printStackTrace(); JOptionPane.showMessageDialog(panelException, ee.getMessage()); } } else JOptionPane.showMessageDialog(null, "Введите дату в правильном формате!"); } else JOptionPane.showMessageDialog(null, "Введите обязательные параметры!"); } }); }
/** Initializes the graphical components */ public void init() { username = getParameter("username"); if (username == null) { username = JOptionPane.showInputDialog( this, "Please enter a username", "Login", JOptionPane.QUESTION_MESSAGE); } try { PORT = Integer.valueOf(getParameter("port")).intValue(); } catch (NumberFormatException e) { PORT = 42412; } URL url = getDocumentBase(); site = url.getHost(); locationURL = "http://" + site + ":" + url.getPort() + "/" + url.getPath(); setSize(615, 362); c = getContentPane(); c.setBackground(new Color(224, 224, 224)); if (site == null || locationURL == null) { c.add(new JLabel("ERROR: did not recieve needed data from page")); } myAction = new MyAction(); myKeyListener = new MyKeyListener(); myMouseListener = new MyMouseListener(); myHyperlinkListener = new MyHyperlinkListener(); c.setLayout(null); cboChannels = new JComboBox(); cboChannels.setBounds(5, 5, 150, 24); butChannel = new JButton("Join"); butChannel.setToolTipText("Join channel"); butChannel.addActionListener(myAction); butChannel.setBounds(160, 5, 60, 24); butCreate = new JButton("Create"); butCreate.setToolTipText("Create new channel"); butCreate.addActionListener(myAction); butCreate.setBounds(230, 5, 100, 24); butCreate.setEnabled(false); butInvite = new JButton("Invite"); butInvite.setToolTipText("Invite Friend"); butInvite.addActionListener(myAction); butInvite.setBounds(340, 5, 80, 24); mainChat = new ChatPane(this); textScroller = new JScrollPane( mainChat, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); textScroller.setBounds(5, 34, 500, 270); userList = new JList(); userList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); userList.setCellRenderer(new MyCellRenderer()); userList.setBackground(new Color(249, 249, 250)); JScrollPane userScroller = new JScrollPane(userList); userScroller.setBounds(510, 34, 100, 297); messageText = new JTextField(); messageText.setBounds(5, 309, 500, 22); messageText.setColumns(10); messageText.setBackground(new Color(249, 249, 250)); JMenuItem item; popup = new JPopupMenu("test"); popup.add("whisper").addActionListener(myAction); popup.add("private message").addActionListener(myAction); popup.add("ignore").addActionListener(myAction); popup.add("clear ignore list").addActionListener(myAction); conNo = new ImageIcon(getURL("images/connect_no.gif")); conYes = new ImageIcon(getURL("images/connect_established.gif")); secNo = new ImageIcon(getURL("images/decrypted.gif")); secYes = new ImageIcon(getURL("images/encrypted.gif")); conIcon = new JLabel(conNo); conIcon.setBorder(new EtchedBorder()); secIcon = new JLabel(secNo); secIcon.setBorder(new EtchedBorder()); conIcon.setBounds(563, 334, 22, 22); secIcon.setBounds(588, 334, 22, 22); bottomText = new JLabel( "<html><body><font color=#445577><b>" + "LlamaChat " + VERSION + "</b></font> © " + "<a href=\"" + linkURL + "\">Joseph Monti</a> 2002-2003" + "</body></html>"); bottomText.setBounds(5, 336, 500, 20); c.add(cboChannels); c.add(butChannel); c.add(butCreate); c.add(butInvite); c.add(textScroller); c.add(userScroller); c.add(messageText); c.add(conIcon); c.add(secIcon); c.add(bottomText); userList.addMouseListener(myMouseListener); messageText.addKeyListener(myKeyListener); bottomText.addMouseListener(myMouseListener); users = new ArrayList(); ignores = new ArrayList(5); afks = new ArrayList(5); admins = new ArrayList(5); history = new CommandHistory(10); admin = false; channels = new Hashtable(); privates = new PrivateMsg(this); showUserStatus = false; myColors[0] = new Color(200, 0, 0); myColors[1] = new Color(0, 150, 0); myColors[2] = new Color(0, 0, 200); rect = new Rectangle(0, 0, 1, 1); String opening = "<font color=#333333>" + "==================================<br>" + "Welcome to LlamaChat " + VERSION + "<br>" + "If you need assistance, type \\help<br>" + "Enjoy your stay!<br>" + "Maestria Aplicada en Redes<br>" + "==================================<br></font>"; HTMLDocument doc = (HTMLDocument) mainChat.getDocument(); HTMLEditorKit kit = (HTMLEditorKit) mainChat.getEditorKit(); try { kit.insertHTML(doc, doc.getLength(), opening, 0, 0, HTML.Tag.FONT); } catch (Throwable t) { t.printStackTrace(System.out); } // validate the name if (!username.matches("[\\w_-]+?")) { error( "username contains invalid characters, changing to " + "'invalid' for now. " + "Type \\rename to chose a new name"); username = "******"; } if (username.length() > 10) { username = username.substring(0, 10); error("username too long, changed to " + username); } connect(); }
editprof(String str, String user) { cp = getContentPane(); cp.setLayout(null); user1 = user; try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception e) { } JTextField ft = new JTextField(); name1 = new JLabel("First Name"); try { r = new FileReader(user + "/First name.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } name = new JTextField(); name.setText(ft.getText()); last1 = new JLabel("Enter Last Name"); try { r = new FileReader(user + "/last name.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } last = new JTextField(); last.setText(ft.getText()); pass = new JLabel("Password"); try { r = new FileReader(user + "/password.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } pwd = new JPasswordField(); pwd.setText(ft.getText()); pwd.setEditable(false); email1 = new JLabel("Enter email address"); try { r = new FileReader(user + "/email.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } email = new JTextField(); email.setText(ft.getText()); addimage = new JButton("Add Image"); icon = new JLabel(); date1 = new JLabel("Date Of Birth"); date = new JComboBox(); for (int i = 1; i <= 31; i++) { date.addItem(i); } month = new JComboBox(); month.addItem("Jan"); month.addItem("Feb"); month.addItem("Mar"); month.addItem("Apr"); month.addItem("May"); month.addItem("Jun"); month.addItem("Jul"); month.addItem("Aug"); month.addItem("Sep"); month.addItem("Oct"); month.addItem("Nov"); month.addItem("Dec"); year = new JComboBox(); for (int j = 1900; j <= 2010; j++) { year.addItem(j); } sx = new JLabel("Gender"); gen = new JComboBox(); gen.addItem("Male"); gen.addItem("Female"); con1 = new JLabel("Country Name"); con = new JComboBox(); con.addItem(" Austrelia"); con.addItem(" America"); con.addItem(" Antartica"); con.addItem(" Africa"); con.addItem(" Canda"); con.addItem(" Corea"); con.addItem(" Chaina"); con.addItem(" Denmark"); con.addItem(" England"); con.addItem(" Franc"); con.addItem(" Hangery"); con.addItem(" Holand"); con.addItem(" Itali"); con.addItem(" India"); con.addItem(" Indonesia"); con.addItem(" Jermany"); con.addItem(" Japan"); con.addItem(" Korea"); con.addItem(" Kembridge"); con.addItem(" Merusalem"); con.addItem(" Noth America"); con.addItem(" Norvey"); con.addItem(" West Indies"); con.addItem(" Peru"); con.addItem(" Zimbawe"); about = new JLabel("About me"); try { r = new FileReader(user + "/about.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS; int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS; main = new JTextArea(); main.setText(ft.getText()); JScrollPane jsp = new JScrollPane(main, v, h); allow = new JLabel("Allow To:"); JCheckBox c1 = new JCheckBox(" orkut Friends"); JCheckBox c2 = new JCheckBox("Collage Friends"); JCheckBox c3 = new JCheckBox("Business Partner"); JCheckBox c4 = new JCheckBox("Relatives"); col = new JLabel("Collage Name:"); try { r = new FileReader(user + "/Collage.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } col1 = new JTextField(); col1.setText(ft.getText()); try { r = new FileReader(user + "/UniverSity.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } uni = new JLabel("Univercity"); uni1 = new JTextField(); uni1.setText(ft.getText()); state1 = new JLabel("State Name"); try { r = new FileReader(user + "/state.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } state = new JTextField(); state.setText(ft.getText()); city = new JLabel("City"); try { r = new FileReader(user + "/City.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } city1 = new JTextField(); city1.setText(ft.getText()); try { r = new FileReader(user + "/imagepath.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } ImageIcon io = new ImageIcon(ft.getText()); icon.setIcon(io); next = new JButton("Update"); next.setBackground(Color.white); // adding to container name1.setBounds(10, 10, 130, 25); name.setBounds(150, 10, 130, 25); last1.setBounds(10, 40, 130, 25); last.setBounds(150, 40, 130, 25); email1.setBounds(10, 70, 130, 25); email.setBounds(150, 70, 130, 25); pass.setBounds(290, 70, 130, 25); pwd.setBounds(390, 70, 130, 25); addimage.setBounds(350, 440, 100, 25); icon.setBounds(490, 410, 100, 100); date1.setBounds(10, 100, 130, 25); date.setBounds(120, 100, 40, 25); month.setBounds(180, 100, 130, 25); year.setBounds(320, 100, 130, 25); sx.setBounds(10, 140, 130, 25); gen.setBounds(150, 140, 130, 25); about.setBounds(10, 180, 130, 25); jsp.setBounds(150, 180, 250, 80); allow.setBounds(10, 260, 130, 25); c1.setBounds(150, 260, 130, 25); c2.setBounds(290, 260, 130, 25); c3.setBounds(150, 290, 130, 25); c4.setBounds(290, 290, 130, 25); uni.setBounds(10, 330, 130, 25); uni1.setBounds(150, 330, 130, 25); col.setBounds(10, 360, 130, 25); col1.setBounds(150, 360, 130, 25); con1.setBounds(10, 390, 130, 25); con.setBounds(150, 390, 130, 25); state1.setBounds(10, 430, 130, 25); state.setBounds(150, 430, 130, 25); city.setBounds(10, 460, 130, 25); city1.setBounds(150, 460, 130, 25); next.setBounds(50, 490, 130, 25); cp.add(name); cp.add(name1); cp.add(last); cp.add(last1); cp.add(email); cp.add(email1); cp.add(addimage); cp.add(icon); cp.add(date1); cp.add(date); cp.add(month); cp.add(year); cp.add(about); cp.add(jsp); cp.add(sx); cp.add(gen); cp.add(allow); cp.add(c1); cp.add(c2); cp.add(c3); cp.add(c4); cp.add(next); cp.add(uni); cp.add(uni1); cp.add(col); cp.add(col1); cp.add(con); cp.add(con1); cp.add(state1); cp.add(state); cp.add(city); cp.add(city1); cp.add(next); cp.add(pwd); cp.add(pass); addimage.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { filepath = name.getText(); JFileChooser chooser = new JFileChooser(); while (true) { int val = chooser.showOpenDialog(editprof.this); File f = chooser.getSelectedFile(); String path = f.getPath(); String name = f.getName(); try { if (val == JFileChooser.CANCEL_OPTION || val == -1) { break; } else { image = new ImageIcon(path); icon.setIcon(image); w = new FileWriter(filepath + "/" + "imagePath.txt"); w.write(path + ""); w.close(); break; } } catch (Exception se) { } } } }); date.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { int str = (Integer) e.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "date.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); month.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e1) { String str = (String) e1.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "month.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); con.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e2) { String str = (String) e2.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "contry.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); year.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e2) { int str = (Integer) e2.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "year.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); gen.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e3) { String str = (String) e3.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "gender.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); next.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent se) { try { w = new FileWriter(name.getText() + "/" + "First name.txt"); w.write(name.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "last name.txt"); w.write(last.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "email.txt"); w.write(email.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "Collage.txt"); w.write(col1.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "UniverSity.txt"); w.write(uni1.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "state.txt"); w.write(state.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "City.txt"); w.write(city1.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "about.txt"); w.write(main.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "password.txt"); w.write(pwd.getText()); w.close(); profile e1 = new profile("My Profile", user1); e1.setVisible(true); e1.setLocation(00, 00); e1.setSize(800, 800); setVisible(false); } catch (Exception be) { } } }); }
public Design() throws Exception { super.setBackground(Color.BLACK); this.setTitle(""); con = getContentPane(); con.setLayout(null); dim = tk.getDefaultToolkit().getScreenSize(); this.setTitle("Customer Peer Login"); l1 = new JLabel(new ImageIcon("plain.jpg")); l1.setBounds(0, 0, 400, 400); con.add(l1); l1.setBorder(BorderFactory.createEtchedBorder(5, Color.black, Color.black)); title = new JLabel("CUSTOMER PEER LOGIN "); title.setFont(new Font("Bookman Old Style", Font.ROMAN_BASELINE, 20)); title.setForeground(Color.red); title.setBounds(80, 30, 300, 30); l1.add(title); l4 = new JLabel("CMACHINE NAME"); l4.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l4.setForeground(Color.BLUE); l4.setBounds(70, 100, 160, 20); // l4.setBorder(BorderFactory.createEtchedBorder(5,Color.green,Color.green)); l1.add(l4); jtf2 = new JTextField(); jtf2.setBounds(250, 100, 100, 20); jtf2.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(jtf2); l2 = new JLabel("CUSER LOGIN"); l2.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l2.setForeground(Color.blue); l2.setBounds(70, 150, 120, 20); l1.add(l2); jtf1 = new JTextField(); jtf1.setBounds(250, 150, 100, 20); jtf1.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(jtf1); l3 = new JLabel("CPASSWORD"); l3.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l3.setForeground(Color.blue); l3.setBounds(70, 200, 120, 20); l1.add(l3); jptf1 = new JPasswordField(); jptf1.setBounds(250, 200, 100, 20); jptf1.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(jptf1); JLabel l4 = new JLabel("DAgent"); l4.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l4.setForeground(Color.blue); l4.setBounds(70, 250, 120, 20); l1.add(l4); box = new JComboBox(); box.setBounds(250, 250, 100, 20); box.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(box); b2 = new JButton("Register"); b2.setBounds(50, 300, 100, 20); l1.add(b2); b2.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE)); b3 = new JButton("Login"); b3.setBounds(150, 300, 100, 20); b3.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE)); l1.add(b3); b1 = new JButton("Cancel"); b1.setBounds(250, 300, 100, 20); b1.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE)); l1.add(b1); b1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent we) { dispose(); } }); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); conn = DriverManager.getConnection("jdbc:odbc:agent"); } catch (Exception exp) { } try { Statement satem = conn.createStatement(); ResultSet rsatem = satem.executeQuery("select * from Dagent"); while (rsatem.next()) { String namem = rsatem.getString("uname"); box.addItem(namem); } } catch (Exception expo1) { } b2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent we) { String username = jtf1.getText().trim(); String password = jptf1.getText().trim(); String mechine = jtf2.getText().trim(); String dname = box.getSelectedItem().toString(); int porte = 0; try { Statement sate = conn.createStatement(); ResultSet rsate = sate.executeQuery("select * from Dagent where uname='" + dname + "'"); if (rsate.next()) { servermachine = rsate.getString("umechine"); porte = rsate.getInt("ulistport"); System.out.println(servermachine); } System.out.println(servermachine); } catch (Exception exp) { exp.printStackTrace(); } try { packet p = new packet(); p.setaction("Creg"); p.setCuser(username); p.setCpass(password); p.setCmname(mechine); p.setCDpeer(dname); Socket soc = new Socket(servermachine, porte); ObjectOutputStream out = new ObjectOutputStream(soc.getOutputStream()); out.writeObject(p); ObjectInputStream in = new ObjectInputStream(soc.getInputStream()); packet rpac = (packet) in.readObject(); if (rpac.getaction().equals("ok")) { JOptionPane.showMessageDialog(null, "Sucessfully Registered"); jtf2.setText(""); jtf1.setText(""); jptf1.setText(""); } else { JOptionPane.showMessageDialog(null, "Already Registered"); jtf2.setText(""); jtf1.setText(""); jptf1.setText(""); } } catch (Exception exp) { } } }); b3.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent we) { String username = jtf1.getText().trim(); String password = jptf1.getText().trim(); String mechine = jtf2.getText().trim(); String Dname = box.getSelectedItem().toString(); int porte = 0; try { Statement sate = conn.createStatement(); ResultSet rsate = sate.executeQuery("select * from Dagent where uname='" + Dname + "'"); if (rsate.next()) { servermachine = rsate.getString("umechine"); porte = rsate.getInt("ulistport"); System.out.println(servermachine); } System.out.println(servermachine); } catch (Exception exp) { } try { packet p1 = new packet(); p1.setaction("clogin"); p1.setCuser(username); p1.setCpass(password); p1.setCmname(mechine); p1.setCDpeer(Dname); Socket soc1 = new Socket(servermachine, porte); ObjectOutputStream out1 = new ObjectOutputStream(soc1.getOutputStream()); out1.writeObject(p1); ObjectInputStream in1 = new ObjectInputStream(soc1.getInputStream()); packet rpac1 = (packet) in1.readObject(); if (rpac1.getaction().equals("ok")) { int port1 = 0; try { int portm = rpac1.getCport(); System.out.println("XXXXXXX" + portm); // JOptionPane.showMessageDialog(null,"Sucessfully Started"); new Listen(portm); new process(username, portm); dispose(); } catch (Exception exp) { } } else { JOptionPane.showMessageDialog( null, "Enter valid username and password", "Server reply", 2); jtf1.setText(""); jtf2.setText(""); jptf1.setText(""); } } catch (Exception exp) { } } }); setSize(400, 400); show(); setLocation(150, 100); setResizable(false); }