/** Listener to handle button actions */ public void actionPerformed(ActionEvent e) { // Check if the user pressed the remove button if (e.getSource() == remove_button) { int row = table.getSelectedRow(); model.removeRow(row); table.clearSelection(); table.repaint(); valueChanged(null); } // Check if the user pressed the remove all button if (e.getSource() == remove_all_button) { model.clearAll(); table.setRowSelectionInterval(0, 0); table.repaint(); valueChanged(null); } // Check if the user pressed the filter button if (e.getSource() == filter_button) { filter.showDialog(); if (filter.okPressed()) { // Update the display with new filter model.setFilter(filter); table.repaint(); } } // Check if the user pressed the start button if (e.getSource() == start_button) { start(); } // Check if the user pressed the stop button if (e.getSource() == stop_button) { stop(); } // Check if the user wants to switch layout if (e.getSource() == layout_button) { details_panel.remove(details_soap); details_soap.removeAll(); if (details_soap.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) { details_soap = new JSplitPane(JSplitPane.VERTICAL_SPLIT); } else { details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); } details_soap.setTopComponent(request_panel); details_soap.setRightComponent(response_panel); details_soap.setResizeWeight(.5); details_panel.add(details_soap, BorderLayout.CENTER); details_panel.validate(); details_panel.repaint(); } // Check if the user is changing the reflow option if (e.getSource() == reflow_xml) { request_text.setReflowXML(reflow_xml.isSelected()); response_text.setReflowXML(reflow_xml.isSelected()); } }
private void jbInit() throws Exception { //////////////////////////////////////////////////////// // Init LAF //////////////////////////////////////////////////////// ButtonGroup grpLAF = new ButtonGroup(); ActionListener lsnLAF = new ActionListener() { public void actionPerformed(ActionEvent evt) { int iIndex = mvtLAFItem.indexOf(evt.getSource()); if (iIndex >= 0) changeLAF(iIndex); } }; //////////////////////////////////////////////////////// UIManager.LookAndFeelInfo laf = new UIManager.LookAndFeelInfo( "Kunststoff", "com.incors.plaf.kunststoff.KunststoffLookAndFeel"); marrLaf = UIManager.getInstalledLookAndFeels(); int iIndex = 0; while (iIndex < marrLaf.length && !marrLaf[iIndex].getName().equals(laf.getName())) iIndex++; if (iIndex >= marrLaf.length) { UIManager.installLookAndFeel(laf); marrLaf = UIManager.getInstalledLookAndFeels(); } for (iIndex = 0; iIndex < marrLaf.length; iIndex++) { JMenuItem mnu = new JRadioButtonMenuItem(marrLaf[iIndex].getName()); mnu.addActionListener(lsnLAF); mvtLAFItem.addElement(mnu); mnuUI.add(mnu); grpLAF.add(mnu); } mnuUI.addSeparator(); //////////////////////////////////////////////////////// // Init language //////////////////////////////////////////////////////// ButtonGroup grpLanguage = new ButtonGroup(); ActionListener lsnLanguage = new ActionListener() { public void actionPerformed(ActionEvent e) { int iIndex = mvtLanguageItem.indexOf(e.getSource()); if (iIndex >= 0) changeDictionary((String) mvtLanguage.elementAt(iIndex)); } }; //////////////////////////////////////////////////////// String[] str = MonitorDictionary.getSupportedLanguage(); for (iIndex = 0; iIndex < str.length; iIndex++) { JMenuItem mnu = new JRadioButtonMenuItem(MonitorDictionary.getDictionary(str[iIndex]).getLanguage()); mnu.addActionListener(lsnLanguage); mvtLanguage.addElement(str[iIndex]); mvtLanguageItem.addElement(mnu); mnuUI.add(mnu); grpLanguage.add(mnu); } //////////////////////////////////////////////////////// // Add to main menu //////////////////////////////////////////////////////// mnuMain.removeAll(); mnuMain.add(mnuSystem); mnuSystem.add(mnuSystem_Login); mnuSystem.add(mnuSystem_ChangePassword); mnuSystem.addSeparator(); mnuSystem.add(mnuSystem_StopServer); mnuSystem.add(mnuSystem_EnableThreads); mnuMain.add(mnuUI); mnuMain.add(mnuHelp); mnuHelp.add(mnuHelp_About); //////////////////////////////////////////////////////// mnuMain.add(chkVietnamese); mnuMain.add(lblStatus); //////////////////////////////////////////////////////// pnlThread.setTabPlacement(JTabbedPane.LEFT); pnlThread.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); //////////////////////////////////////////////////////// tblUser.addColumn("", 1, false); tblUser.addColumn("", 2, false, Global.FORMAT_DATE_TIME); tblUser.addColumn("", 3, false); //////////////////////////////////////////////////////// JPanel pnlMessage = new JPanel(); pnlMessage.setLayout(new GridBagLayout()); pnlMessage.add( new JScrollPane(txtBoard), new GridBagConstraints( 0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); pnlMessage.add( txtMessage, new GridBagConstraints( 0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); pnlMessage.add( btnSend, new GridBagConstraints( 1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0)); txtBoard.setEditable(false); txtBoard.setAutoscrolls(true); txtBoard.setContentType("text/html"); clearAll(txtBoard); //////////////////////////////////////////////////////// JPanel pnlUserButton = new JPanel(new GridLayout(1, 2, 4, 4)); pnlUserButton.add(btnKick); pnlUserButton.add(btnRefresh); //////////////////////////////////////////////////////// JPanel pnlManager = new JPanel(new GridBagLayout()); pnlManager.add( new JScrollPane(tblUser), new GridBagConstraints( 0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); pnlManager.add( pnlUserButton, new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 2, 4, 2), 0, 0)); //////////////////////////////////////////////////////// pnlUser.setDividerLocation(320); pnlUser.setLeftComponent(pnlManager); pnlUser.setRightComponent(pnlMessage); pnlUser.setOneTouchExpandable(true); //////////////////////////////////////////////////////// setOrientation(JSplitPane.VERTICAL_SPLIT); setOneTouchExpandable(true); pnlThread.setVisible(false); pnlUser.setVisible(false); setTopComponent(pnlThread); setBottomComponent(pnlUser); //////////////////////////////////////////////////////// pmn.add(mnuSelectAll); pmn.addSeparator(); pmn.add(mnuClearSelected); pmn.add(mnuClearAll); //////////////////////////////////////////////////////// setBorder(BorderFactory.createEmptyBorder()); pnlUser.setBorder(BorderFactory.createEmptyBorder()); pnlManager.setBorder( BorderFactory.createBevelBorder( javax.swing.border.BevelBorder.RAISED, Color.white, UIManager.getColor("Panel.background"), UIManager.getColor("Panel.background"), UIManager.getColor("Panel.background"))); pnlMessage.setBorder( BorderFactory.createBevelBorder( javax.swing.border.BevelBorder.RAISED, Color.white, UIManager.getColor("Panel.background"), UIManager.getColor("Panel.background"), UIManager.getColor("Panel.background"))); //////////////////////////////////////////////////////// Skin.applySkin(mnuMain); Skin.applySkin(tblUser); Skin.applySkin(pmn); Skin.applySkin(this); //////////////////////////////////////////////////////// // Default setting //////////////////////////////////////////////////////// Hashtable prt = null; try { prt = Global.loadHashtable(Global.FILE_CONFIG); } catch (Exception e) { prt = new Hashtable(); } changeLAF(Integer.parseInt(StringUtil.nvl(prt.get("LAF"), "0"))); changeDictionary(StringUtil.nvl(prt.get("Language"), "VN")); Skin.LANGUAGE_CHANGE_LISTENER = this; MonitorProcessor.setRootObject(this); updateKeyboardUI(); //////////////////////////////////////////////////////// // Event handler //////////////////////////////////////////////////////// tblUser.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) btnKick.doClick(); } }); //////////////////////////////////////////////////////// btnRefresh.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent evt) { try { DDTP request = new DDTP(); request.setRequestID(String.valueOf(System.currentTimeMillis())); DDTP response = channel.sendRequest("ThreadProcessor", "queryUserList", request); if (response != null) { tblUser.setData((Vector) response.getReturn()); if (mstrChannel != null) removeUser(mstrChannel); } } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } } }); //////////////////////////////////////////////////////// btnKick.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent evt) { int iSelected = tblUser.getSelectedRow(); if (iSelected < 0) return; int iResult = MessageBox.showConfirmDialog( pnlThread, mdic.getString("ConfirmKick"), Global.APP_NAME, MessageBox.YES_NO_OPTION); if (iResult == MessageBox.NO_OPTION) return; try { String strChannel = (String) tblUser.getRow(iSelected).elementAt(0); DDTP request = new DDTP(); request.setRequestID(String.valueOf(System.currentTimeMillis())); request.setString("strChannel", strChannel); DDTP response = channel.sendRequest("ThreadProcessor", "kickUser", request); } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } } }); //////////////////////////////////////////////////////// txtMessage.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent evt) { btnSend.doClick(); } }); //////////////////////////////////////////////////////// btnSend.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent evt) { if (txtMessage.getText().length() == 0) return; try { DDTP request = new DDTP(); request.setString("strMessage", txtMessage.getText()); channel.sendRequest("ThreadProcessor", "sendMessage", request); txtMessage.setText(""); } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } } }); //////////////////////////////////////////////////////// mnuClearAll.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { clearAll(txtBoard); } }); //////////////////////////////////////////////////////// mnuClearSelected.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { txtBoard.setEditable(true); txtBoard.replaceSelection(""); txtBoard.setEditable(false); } }); //////////////////////////////////////////////////////// mnuSelectAll.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { txtBoard.requestFocus(); txtBoard.selectAll(); } }); //////////////////////////////////////////////////////// txtBoard.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getButton() == e.BUTTON3) pmn.show(txtBoard, e.getX(), e.getY()); } }); //////////////////////////////////////////////////////// mnuSystem_Login.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { login(); } }); //////////////////////////////////////////////////////// mnuSystem_ChangePassword.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { changePassword(); } }); //////////////////////////////////////////////////////// mnuSystem_StopServer.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { stopServer(); } }); //////////////////////////////////////////////////////// mnuSystem_EnableThreads.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { manageThreads(); } }); //////////////////////////////////////////////////////// mnuHelp_About.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { WindowManager.centeredWindow(new DialogAbout(PanelThreadManager.this)); } }); //////////////////////////////////////////////////////// chkVietnamese.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { switchKeyboard(); } }); }
/** 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 LabFrame() throws HeadlessException { super(title); JPanel pnl, pnl1; data = new LabData(); alRootEntities.addAll(data.findRootEntities()); JMenuBar mb = new JMenuBar(); for (MenuElement e : menus) { mb.add(e.getItem()); } setJMenuBar(mb); splMain = new JSplitPane(); getContentPane().add(splMain); desktop = new JDesktopPane(); desktop.setPreferredSize(new Dimension(400, 200)); splMain.setRightComponent(desktop); lmEntities = new EntityListModel(); lstEntities = new JList(lmEntities); lstEntities.getSelectionModel().addListSelectionListener(lmEntities); lstEntities.addMouseListener(dblClickListener); JScrollPane scpList = new JScrollPane(lstEntities); pnl = new JPanel(new BorderLayout(4, 4)); pnl.add(scpList, BorderLayout.CENTER); pnl1 = new JPanel(null); pnl1.setLayout(new BoxLayout(pnl1, BoxLayout.X_AXIS)); pnl1.add(Box.createHorizontalGlue()); pnl1.add(new JButton(actNewEntity)); pnl1.add(Box.createHorizontalGlue()); pnl1.add(new JButton(actDelEntity)); pnl1.add(Box.createHorizontalGlue()); pnl.add(pnl1, BorderLayout.SOUTH); splMain.setLeftComponent(pnl); il = new InternalFrameAdapter() { @Override public void internalFrameClosed(InternalFrameEvent e) { Object sel = ((EntityFrame) e.getInternalFrame()).content; mapEntityFrames.remove(sel); } @Override public void internalFrameActivated(InternalFrameEvent e) { setTitle(title + " - " + e.getInternalFrame().getTitle()); Object sel = ((EntityFrame) e.getInternalFrame()).content; lstEntities.setSelectedValue(sel, true); } }; pack(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); updateState(); }