/** Initializes this panel. */ private void init() { JPanel mainPanel = new TransparentPanel(new BorderLayout()); mainPanel.setBorder( BorderFactory.createTitledBorder( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sipaccregwizz.CREATE_ACCOUNT_TITLE"))); JPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1)); JPanel valuesPanel = new TransparentPanel(new GridLayout(0, 1)); JLabel usernameLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.USERNAME")); JLabel displayNameLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sipaccregwizz.DISPLAY_NAME")); JLabel passLabel = new JLabel(Sip2SipAccRegWizzActivator.getResources().getI18NString("service.gui.PASSWORD")); JLabel retypePasswordLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.RETYPE_PASSWORD")); JLabel emailLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.EMAIL")); labelsPanel.add(displayNameLabel); labelsPanel.add(usernameLabel); labelsPanel.add(passLabel); labelsPanel.add(retypePasswordLabel); labelsPanel.add(emailLabel); valuesPanel.add(displayNameField); valuesPanel.add(usernameField); valuesPanel.add(passField); valuesPanel.add(retypePassField); valuesPanel.add(emailField); JLabel emailDescriptionLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.EMAIL_NOTE"), SwingConstants.CENTER); emailDescriptionLabel.setForeground(Color.GRAY); emailDescriptionLabel.setFont(emailDescriptionLabel.getFont().deriveFont(8)); emailDescriptionLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 8, 10)); initErrorArea(); mainPanel.add(labelsPanel, BorderLayout.WEST); mainPanel.add(valuesPanel, BorderLayout.CENTER); mainPanel.add(emailDescriptionLabel, BorderLayout.SOUTH); this.add(mainPanel, BorderLayout.CENTER); JLabel infoLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.INFO_NOTE"), SwingConstants.RIGHT); infoLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); infoLabel.setForeground(Color.GRAY); infoLabel.setFont(emailDescriptionLabel.getFont().deriveFont(8)); infoLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0)); infoLabel.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { Sip2SipAccRegWizzActivator.getBrowserLauncher().openURL("http://wiki.sip2sip.info"); } }); this.add(infoLabel, BorderLayout.SOUTH); }
/** Constructor (create and layout page) */ public SOAPMonitorPage(String host_name) { host = host_name; // Set up default filter (show all messages) filter = new SOAPMonitorFilter(); // Use borders to help improve appearance etched_border = new EtchedBorder(); // Build top portion of split (list panel) model = new SOAPMonitorTableModel(); table = new JTable(model); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setRowSelectionInterval(0, 0); table.setPreferredScrollableViewportSize(new Dimension(600, 96)); table.getSelectionModel().addListSelectionListener(this); scroll = new JScrollPane(table); remove_button = new JButton("Remove"); remove_button.addActionListener(this); remove_button.setEnabled(false); remove_all_button = new JButton("Remove All"); remove_all_button.addActionListener(this); filter_button = new JButton("Filter ..."); filter_button.addActionListener(this); list_buttons = new JPanel(); list_buttons.setLayout(new FlowLayout()); list_buttons.add(remove_button); list_buttons.add(remove_all_button); list_buttons.add(filter_button); list_panel = new JPanel(); list_panel.setLayout(new BorderLayout()); list_panel.add(scroll, BorderLayout.CENTER); list_panel.add(list_buttons, BorderLayout.SOUTH); list_panel.setBorder(empty_border); // Build bottom portion of split (message details) details_time = new JLabel("Time: ", SwingConstants.RIGHT); details_target = new JLabel("Target Service: ", SwingConstants.RIGHT); details_status = new JLabel("Status: ", SwingConstants.RIGHT); details_time_value = new JLabel(); details_target_value = new JLabel(); details_status_value = new JLabel(); Dimension preferred_size = details_time.getPreferredSize(); preferred_size.width = 1; details_time.setPreferredSize(preferred_size); details_target.setPreferredSize(preferred_size); details_status.setPreferredSize(preferred_size); details_time_value.setPreferredSize(preferred_size); details_target_value.setPreferredSize(preferred_size); details_status_value.setPreferredSize(preferred_size); details_header = new JPanel(); details_header_layout = new GridBagLayout(); details_header.setLayout(details_header_layout); details_header_constraints = new GridBagConstraints(); details_header_constraints.fill = GridBagConstraints.BOTH; details_header_constraints.weightx = 0.5; details_header_layout.setConstraints(details_time, details_header_constraints); details_header.add(details_time); details_header_layout.setConstraints(details_time_value, details_header_constraints); details_header.add(details_time_value); details_header_layout.setConstraints(details_target, details_header_constraints); details_header.add(details_target); details_header_constraints.weightx = 1.0; details_header_layout.setConstraints(details_target_value, details_header_constraints); details_header.add(details_target_value); details_header_constraints.weightx = .5; details_header_layout.setConstraints(details_status, details_header_constraints); details_header.add(details_status); details_header_layout.setConstraints(details_status_value, details_header_constraints); details_header.add(details_status_value); details_header.setBorder(etched_border); request_label = new JLabel("SOAP Request", SwingConstants.CENTER); request_text = new SOAPMonitorTextArea(); request_text.setEditable(false); request_scroll = new JScrollPane(request_text); request_panel = new JPanel(); request_panel.setLayout(new BorderLayout()); request_panel.add(request_label, BorderLayout.NORTH); request_panel.add(request_scroll, BorderLayout.CENTER); response_label = new JLabel("SOAP Response", SwingConstants.CENTER); response_text = new SOAPMonitorTextArea(); response_text.setEditable(false); response_scroll = new JScrollPane(response_text); response_panel = new JPanel(); response_panel.setLayout(new BorderLayout()); response_panel.add(response_label, BorderLayout.NORTH); response_panel.add(response_scroll, BorderLayout.CENTER); details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); details_soap.setTopComponent(request_panel); details_soap.setRightComponent(response_panel); details_soap.setResizeWeight(.5); details_panel = new JPanel(); layout_button = new JButton("Switch Layout"); layout_button.addActionListener(this); reflow_xml = new JCheckBox("Reflow XML text"); reflow_xml.addActionListener(this); details_buttons = new JPanel(); details_buttons.setLayout(new FlowLayout()); details_buttons.add(reflow_xml); details_buttons.add(layout_button); details_panel.setLayout(new BorderLayout()); details_panel.add(details_header, BorderLayout.NORTH); details_panel.add(details_soap, BorderLayout.CENTER); details_panel.add(details_buttons, BorderLayout.SOUTH); details_panel.setBorder(empty_border); // Add the two parts to the age split pane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setTopComponent(list_panel); split.setRightComponent(details_panel); // Build status area start_button = new JButton("Start"); start_button.addActionListener(this); stop_button = new JButton("Stop"); stop_button.addActionListener(this); status_buttons = new JPanel(); status_buttons.setLayout(new FlowLayout()); status_buttons.add(start_button); status_buttons.add(stop_button); status_text = new JLabel(); status_text.setBorder(new BevelBorder(BevelBorder.LOWERED)); status_text_panel = new JPanel(); status_text_panel.setLayout(new BorderLayout()); status_text_panel.add(status_text, BorderLayout.CENTER); status_text_panel.setBorder(empty_border); status_area = new JPanel(); status_area.setLayout(new BorderLayout()); status_area.add(status_buttons, BorderLayout.WEST); status_area.add(status_text_panel, BorderLayout.CENTER); status_area.setBorder(etched_border); // Add the split and status area to page setLayout(new BorderLayout()); add(split, BorderLayout.CENTER); add(status_area, BorderLayout.SOUTH); }
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); }