List of usage examples for java.awt Container addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
From source file:Main.java
private static void addContainerListeners(Container c, Object... objs) { if (c == null) return;//from ww w . jav a 2s .com addComponentListeners(c, objs); ContainerListener containerListener = search(objs, ContainerListener.class); PropertyChangeListener propertyChangeListener = search(objs, PropertyChangeListener.class); if (containerListener != null) c.addContainerListener(containerListener); if (propertyChangeListener != null) c.addPropertyChangeListener(propertyChangeListener); }
From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow.java
/** * Set up the GUI/*from w w w . j av a 2 s. c o m*/ * * @param void * @return void */ private void initComponents() { frame = new JFrame("geWorkbench - Component Configuration Manager"); topPanel = new JPanel(); displayLabel = new JLabel(); String[] displayChoices = { DISPLAY_FILTER_ALL, DISPLAY_ONLY_LOADED, DISPLAY_ONLY_UNLOADED }; displayComboBox = new JComboBox(displayChoices); showByTypeLabel = new JLabel(); String[] showByTypeChoices = new String[PluginComponent.categoryList.size() + 2]; showByTypeChoices[0] = SHOW_BY_TYPE_ALL; int index = 1; for (String s : PluginComponent.categoryList) { showByTypeChoices[index] = s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase(); index++; } ; showByTypeChoices[index] = SHOW_BY_TYPE_OTHERS; Arrays.sort(showByTypeChoices); showByTypeComboBox = new JComboBox(showByTypeChoices); showByTypeComboBox.setMaximumRowCount(showByTypeChoices.length); keywordSearchLabel = new JLabel("Keyword search:"); keywordSearchField = new JTextField("Enter Text"); splitPane = new JSplitPane(); scrollPaneForTextPane = new JScrollPane(); textPane = new JTextPane(); bottompanel = new JPanel(); CellConstraints cc = new CellConstraints(); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { ccmWindow = null; } }); viewLicenseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { viewLicense_actionPerformed(e); } }); applyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { applyCcmSelections_actionPerformed(e); } }); resetButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { resetCcmSelections_actionPerformed(e); } }); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeCcmSelections_actionPerformed(e); } }); //======== frame ======== { Container frameContentPane = frame.getContentPane(); frameContentPane.setLayout(new BorderLayout()); //======== outerPanel ======== { frameContentPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent e) { if ("border".equals(e.getPropertyName())) throw new RuntimeException(); } }); //======== topPanel ======== { FormLayout topPanelLayout = new FormLayout( " 32dlu, default, 4dlu, default, 32dlu, default, 4dlu, default, 32dlu, default, 4dlu, 64dlu, 32dlu", "center:25dlu"); topPanel.setLayout(topPanelLayout); //---- displayLabel ---- displayLabel.setText("Display:"); topPanel.add(displayLabel, cc.xy(2, 1)); //======== scrollPaneForTopList1 ======== { //---- displayComboBox ---- ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { ItemSelectable is = (ItemSelectable) actionEvent.getSource(); Object[] selections = is.getSelectedObjects(); String selection = (String) selections[0]; ccmTableModel.setLoadedFilterValue(selection); sorter.setRowFilter(combinedFilter); ccmTableModel.fireTableDataChanged(); } }; displayComboBox.addActionListener(actionListener); } topPanel.add(displayComboBox, cc.xy(4, 1)); //---- showByTypeLabel ---- showByTypeLabel.setText("Show by type:"); topPanel.add(showByTypeLabel, cc.xy(6, 1)); //======== scrollPaneForTopList2 ======== { //---- showByTypeComboBox ---- ActionListener actionListener2 = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { ItemSelectable is = (ItemSelectable) actionEvent.getSource(); Object[] selections = is.getSelectedObjects(); String selection = (String) selections[0]; ccmTableModel.setTypeFilterValue(selection); sorter.setRowFilter(combinedFilter); ccmTableModel.fireTableDataChanged(); } }; showByTypeComboBox.addActionListener(actionListener2); } topPanel.add(showByTypeComboBox, cc.xy(8, 1)); //---- topLabel3 ---- topPanel.add(keywordSearchLabel, cc.xy(10, 1)); //======== scrollPaneForTopList3 ======== { // ---- keywordSearchField ---- KeyListener actionListener3 = new KeyListener() { public void keyPressed(KeyEvent e) { } public void keyReleased(KeyEvent e) { String text = keywordSearchField.getText(); ccmTableModel.setKeywordFilterValue(text); sorter.setRowFilter(combinedFilter); ccmTableModel.fireTableDataChanged(); } public void keyTyped(KeyEvent e) { } }; keywordSearchField.setText("Enter Text"); keywordSearchField.addKeyListener(actionListener3); } topPanel.add(keywordSearchField, cc.xy(12, 1)); } // Top Panel frameContentPane.add(topPanel, BorderLayout.NORTH); //======== splitPane ======== { splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); splitPane.setResizeWeight(0.5); //======== scrollPaneForTable ======== { //---- table ---- ccmTableModel = new CCMTableModel(manager); setOriginalChoices(); table = new JTable(ccmTableModel); sorter = new TableRowSorter<CCMTableModel>(ccmTableModel); table.setRowSorter(sorter); table.setDefaultRenderer(Object.class, new CellRenderer()); table.setDefaultRenderer(CCMTableModel.ImageLink.class, new ImageLinkRenderer()); table.setDefaultRenderer(CCMTableModel.HyperLink.class, new HyperLinkRenderer()); table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ListSelectionModel cellSM = table.getSelectionModel(); cellSM.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); cellSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { boolean adjusting = e.getValueIsAdjusting(); if (adjusting) { return; } int selectedRow = table.getSelectedRow(); ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { textPane.setText(" "); } else { String description = (String) ccmTableModel.getValueAt( table.convertRowIndexToModel(selectedRow), CCMTableModel.DESCRIPTION_INDEX); textPane.setText(description); if (textPane.getCaretPosition() > 1) { textPane.setCaretPosition(1); } } } }); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(java.awt.event.MouseEvent event) { launchBrowser(); } }); TableColumn column = table.getColumnModel().getColumn(CCMTableModel.SELECTION_INDEX); column.setMaxWidth(50); column = table.getColumnModel().getColumn(CCMTableModel.VERSION_INDEX); column.setMaxWidth(60); column = table.getColumnModel().getColumn(CCMTableModel.TUTORIAL_URL_INDEX); column.setMaxWidth(70); column = table.getColumnModel().getColumn(CCMTableModel.TOOL_URL_INDEX); column.setMaxWidth(70); scrollPaneForTable = new JScrollPane(table); } splitPane.setTopComponent(scrollPaneForTable); //======== scrollPaneForTextPane ======== { //---- textPane ---- textPane.setEditable(false); scrollPaneForTextPane.setViewportView(textPane); } splitPane.setBottomComponent(scrollPaneForTextPane); } //======== splitPane ========. frameContentPane.add(splitPane, BorderLayout.CENTER); //======== bottompanel ======== { bottompanel.setLayout(new FormLayout("20dlu," + "default, 4dlu, " + // view License "default,200dlu, " + // Apply "default, 4dlu, " + // Reset "default, 4dlu, " + // Cancel "default " // Close , "center:25dlu")); viewLicenseButton.setText("View License"); bottompanel.add(viewLicenseButton, cc.xy(2, 1)); //---- applyButton ---- applyButton.setText("Apply"); bottompanel.add(applyButton, cc.xy(6, 1)); //---- resetButton ---- resetButton.setText("Reset"); bottompanel.add(resetButton, cc.xy(8, 1)); //---- closeButton ---- closeButton.setText("Close"); bottompanel.add(closeButton, cc.xy(10, 1)); } //======== bottompanel ========. frameContentPane.add(bottompanel, BorderLayout.SOUTH); } //======== outerPanel ======== frame.pack(); frame.setLocationRelativeTo(frame.getOwner()); } // ============ frame ============ topPanel.setVisible(true); splitPane.setVisible(true); scrollPaneForTable.setVisible(true); table.setVisible(true); scrollPaneForTextPane.setVisible(true); textPane.setVisible(true); bottompanel.setVisible(true); sorter.setRowFilter(combinedFilter); frame.setVisible(true); splitPane.setDividerLocation(.7d); }
From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow2.java
/** * Set up the GUI//from w w w .j a v a 2 s .c om * * @param void * @return void */ private void initComponents() { frame = new JFrame("geWorkbench - Component Configuration Manager"); topPanel = new JPanel(); displayLabel = new JLabel(); String[] displayChoices = { DISPLAY_FILTER_ALL, DISPLAY_ONLY_LOADED, DISPLAY_ONLY_UNLOADED }; displayComboBox = new JComboBox(displayChoices); showByTypeLabel = new JLabel(); String[] showByTypeChoices = new String[PluginComponent.categoryList.size() + 2]; showByTypeChoices[0] = SHOW_BY_TYPE_ALL; int index = 1; for (String s : PluginComponent.categoryList) { showByTypeChoices[index] = s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase(); index++; } ; showByTypeChoices[index] = SHOW_BY_TYPE_OTHERS; Arrays.sort(showByTypeChoices); showByTypeComboBox = new JComboBox(showByTypeChoices); showByTypeComboBox.setMaximumRowCount(showByTypeChoices.length); keywordSearchLabel = new JLabel("Keyword search:"); keywordSearchField = new JTextField("Enter Text"); splitPane = new JSplitPane(); scrollPaneForTextPane = new JScrollPane(); textPane = new JTextPane(); bottompanel = new JPanel(); CellConstraints cc = new CellConstraints(); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { ccmWindow = null; } }); viewLicenseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { viewLicense_actionPerformed(e); } }); applyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { applyCcmSelections_actionPerformed(e); } }); resetButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { resetCcmSelections_actionPerformed(e); } }); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeCcmSelections_actionPerformed(e); } }); componentUpdateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { componentRemoteUpdate_actionPerformed(e); } }); //======== frame ======== { Container frameContentPane = frame.getContentPane(); frameContentPane.setLayout(new BorderLayout()); //======== outerPanel ======== { frameContentPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent e) { if ("border".equals(e.getPropertyName())) throw new RuntimeException(); } }); //======== topPanel ======== { FormLayout topPanelLayout = new FormLayout( " 32dlu, default, 4dlu, default, 32dlu, default, 4dlu, default, 32dlu, default, 4dlu, 64dlu, 32dlu", "center:25dlu"); topPanel.setLayout(topPanelLayout); //---- displayLabel ---- displayLabel.setText("Display:"); topPanel.add(displayLabel, cc.xy(2, 1)); //======== scrollPaneForTopList1 ======== { //---- displayComboBox ---- ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { ItemSelectable is = (ItemSelectable) actionEvent.getSource(); Object[] selections = is.getSelectedObjects(); String selection = (String) selections[0]; ccmTableModel.setLoadedFilterValue(selection); sorter.setRowFilter(combinedFilter); ccmTableModel.fireTableDataChanged(); } }; displayComboBox.addActionListener(actionListener); } topPanel.add(displayComboBox, cc.xy(4, 1)); //---- showByTypeLabel ---- showByTypeLabel.setText("Show by type:"); topPanel.add(showByTypeLabel, cc.xy(6, 1)); //======== scrollPaneForTopList2 ======== { //---- showByTypeComboBox ---- ActionListener actionListener2 = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { ItemSelectable is = (ItemSelectable) actionEvent.getSource(); Object[] selections = is.getSelectedObjects(); String selection = (String) selections[0]; ccmTableModel.setTypeFilterValue(selection); sorter.setRowFilter(combinedFilter); ccmTableModel.fireTableDataChanged(); } }; showByTypeComboBox.addActionListener(actionListener2); } topPanel.add(showByTypeComboBox, cc.xy(8, 1)); //---- topLabel3 ---- topPanel.add(keywordSearchLabel, cc.xy(10, 1)); //======== scrollPaneForTopList3 ======== { // ---- keywordSearchField ---- KeyListener actionListener3 = new KeyListener() { public void keyPressed(KeyEvent e) { } public void keyReleased(KeyEvent e) { String text = keywordSearchField.getText(); ccmTableModel.setKeywordFilterValue(text); sorter.setRowFilter(combinedFilter); ccmTableModel.fireTableDataChanged(); } public void keyTyped(KeyEvent e) { } }; keywordSearchField.setText("Enter Text"); keywordSearchField.addKeyListener(actionListener3); } topPanel.add(keywordSearchField, cc.xy(12, 1)); } // Top Panel frameContentPane.add(topPanel, BorderLayout.NORTH); //======== splitPane ======== { splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); splitPane.setResizeWeight(0.5); //======== scrollPaneForTable ======== { //---- table ---- ccmTableModel = new CCMTableModel2(manager.componentConfigurationManager); setOriginalChoices(); table = new JTable(ccmTableModel); sorter = new TableRowSorter<CCMTableModel2>(ccmTableModel); table.setRowSorter(sorter); table.setDefaultRenderer(Object.class, new CellRenderer()); table.setDefaultRenderer(CCMTableModel2.ImageLink.class, new ImageLinkRenderer()); table.setDefaultRenderer(CCMTableModel2.HyperLink.class, new HyperLinkRenderer()); table.setDefaultRenderer(CCMTableModel2.DownloadLink.class, new DownloadLinkRenderer()); table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); ListSelectionModel cellSM = table.getSelectionModel(); cellSM.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); cellSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { boolean adjusting = e.getValueIsAdjusting(); if (adjusting) { return; } int[] selectedRow = table.getSelectedRows(); ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { textPane.setText(" "); } else { String description = (String) ccmTableModel.getValueAt( table.convertRowIndexToModel(selectedRow[0]), CCMTableModel2.DESCRIPTION_INDEX); textPane.setText(description); if (textPane.getCaretPosition() > 1) { textPane.setCaretPosition(1); } } if (table.getSelectedRow() >= 0) { int modelColumn = table.convertColumnIndexToModel(table.getSelectedColumn()); if (modelColumn == CCMTableModel2.AVAILABLE_UPDATE_INDEX) installRemoteComponent(); else launchBrowser(); } } }); TableColumn column = table.getColumnModel().getColumn(CCMTableModel2.SELECTION_INDEX); column.setMaxWidth(50); column = table.getColumnModel().getColumn(CCMTableModel2.VERSION_INDEX); column.setMaxWidth(60); column = table.getColumnModel().getColumn(CCMTableModel2.AVAILABLE_UPDATE_INDEX); column.setMaxWidth(60); column = table.getColumnModel().getColumn(CCMTableModel2.TUTORIAL_URL_INDEX_2); column.setMaxWidth(70); column = table.getColumnModel().getColumn(CCMTableModel2.TOOL_URL_INDEX_2); column.setMaxWidth(70); scrollPaneForTable = new JScrollPane(table); } splitPane.setTopComponent(scrollPaneForTable); //======== scrollPaneForTextPane ======== { //---- textPane ---- textPane.setEditable(false); scrollPaneForTextPane.setViewportView(textPane); } splitPane.setBottomComponent(scrollPaneForTextPane); } //======== splitPane ========. frameContentPane.add(splitPane, BorderLayout.CENTER); //======== bottompanel ======== { bottompanel.setLayout(new FormLayout("20dlu," + "default, 4dlu, " + // view License "default,100dlu, " + // Component Update "default, 4dlu, " + // Apply "default, 4dlu, " + // Reset "default, 4dlu, " + // Cancel "default " // Close , "center:25dlu")); viewLicenseButton.setText("View License"); bottompanel.add(viewLicenseButton, cc.xy(2, 1)); //---- componentUpdateButton ---- bottompanel.add(componentUpdateButton, cc.xy(6, 1)); //---- applyButton ---- applyButton.setText("Apply"); bottompanel.add(applyButton, cc.xy(8, 1)); //---- resetButton ---- resetButton.setText("Reset"); bottompanel.add(resetButton, cc.xy(10, 1)); //---- closeButton ---- closeButton.setText("Close"); bottompanel.add(closeButton, cc.xy(12, 1)); } //======== bottompanel ========. frameContentPane.add(bottompanel, BorderLayout.SOUTH); } //======== outerPanel ======== frame.pack(); frame.setLocationRelativeTo(frame.getOwner()); } // ============ frame ============ topPanel.setVisible(true); splitPane.setVisible(true); scrollPaneForTable.setVisible(true); table.setVisible(true); scrollPaneForTextPane.setVisible(true); textPane.setVisible(true); bottompanel.setVisible(true); sorter.setRowFilter(combinedFilter); frame.setVisible(true); splitPane.setDividerLocation(.7d); }