List of usage examples for javax.swing AbstractAction AbstractAction
public AbstractAction()
From source file:ch.epfl.lis.gnwgui.NetworkGraph.java
/** * Add a key listener to print the content of the JPanel in which the graph is drawn. * @param jp JPanel that contains the network graph. *///from w w w .j a va 2 s . com @SuppressWarnings("serial") public void addPrintAction(JComponent jp) { KeyStroke k = KeyStroke.getKeyStroke("alt P"); jp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(k, "printscreen"); jp.getActionMap().put("printscreen", new AbstractAction() { public void actionPerformed(ActionEvent arg0) { item_.getNetworkViewer().getControl().printGraph(); } }); }
From source file:edu.ku.brc.specify.toycode.UpdatesApp.java
public JMenuBar createMenus() { JMenuBar menuBar = null;/* w w w.ja v a 2s. c o m*/ /*UIHelper.createMenuItemWithAction(fileMenu, "Open", "O", "", true, new AbstractAction() //$NON-NLS-1$ { public void actionPerformed(ActionEvent e) { doOpen(); } }); JMenuItem saveMenuItem = UIHelper.createMenuItemWithAction(fileMenu, "Save", "S", "", true, new AbstractAction() //$NON-NLS-1$ { public void actionPerformed(ActionEvent e) { doSave(); } }); saveMenuItem.setEnabled(false); */ if (!UIHelper.isMacOS()) { menuBar = new JMenuBar(); JMenu fileMenu = createMenu(menuBar, "File", "F"); fileMenu.addSeparator(); UIHelper.createMenuItemWithAction(fileMenu, "Exit", "x", "", true, new AbstractAction() //$NON-NLS-1$ { public void actionPerformed(ActionEvent e) { shutdown(); } }); } return menuBar; }
From source file:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java
/** * Creates new form TribeTribeAttackFrame *///from w ww . java 2 s. c o m public TribeTribeAttackFrame() { initComponents(); centerPanel = new GenericTestPanel(); jMainPanel.add(centerPanel, BorderLayout.CENTER); centerPanel.setChildComponent(jxAttackPlanerPanel); buildMenu(); capabilityInfoPanel1.addActionListener(this, jSourcesTable); capabilityInfoPanel2.addActionListener(this, jResultsTable); KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false); KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false); KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false); KeyStroke cut = KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK, false); KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false); jSourcesTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Copy", copy, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jVictimTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Copy", copy, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jResultsTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Copy", copy, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jSourcesTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Paste", paste, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jVictimTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Paste", paste, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jSourcesTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Cut", cut, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jVictimTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Cut", cut, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jSourcesTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Delete", delete, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jVictimTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Delete", delete, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jResultsTable.registerKeyboardAction(TribeTribeAttackFrame.this, "Delete", delete, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jResultsTable.registerKeyboardAction(TribeTribeAttackFrame.this, "BBCopy", bbCopy, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); Action noFind = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { //no find } }; jSourcesTable.getActionMap().put("find", noFind); jVictimTable.getActionMap().put("find", noFind); jResultsTable.getActionMap().put("find", noFind); jSourcesTable.getSelectionModel().addListSelectionListener(TribeTribeAttackFrame.this); jVictimTable.getSelectionModel().addListSelectionListener(TribeTribeAttackFrame.this); jResultsTable.getSelectionModel().addListSelectionListener(TribeTribeAttackFrame.this); jideTabbedPane1.setTabShape(JideTabbedPane.SHAPE_OFFICE2003); jideTabbedPane1.setTabColorProvider(JideTabbedPane.ONENOTE_COLOR_PROVIDER); jideTabbedPane1.setBoldActiveTab(true); TagManager.getSingleton().addManagerListener(TribeTribeAttackFrame.this); logPanel = new AlgorithmLogPanel(); mLogFrame = new JFrame("Informationen zur Berechnung"); mLogFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); mLogFrame.setLayout(new BorderLayout()); mLogFrame.add(logPanel); mLogFrame.pack(); mTroopSplitDialog = new TroopSplitDialog(TribeTribeAttackFrame.this, true); mSettingsPanel = new SettingsPanel(this); jSettingsContentPanel.add(mSettingsPanel, BorderLayout.CENTER); jAttackResultDetailsFrame.pack(); jTargetResultDetailsFrame.pack(); dragSource = DragSource.getDefaultDragSource(); dragSource.createDefaultDragGestureRecognizer(TribeTribeAttackFrame.this, DnDConstants.ACTION_COPY_OR_MOVE, TribeTribeAttackFrame.this); new DropTarget(jSourcesTable, TribeTribeAttackFrame.this); new DropTarget(jVictimTable, TribeTribeAttackFrame.this); for (MouseListener l : jAllTargetsComboBox.getMouseListeners()) { jAllTargetsComboBox.removeMouseListener(l); } jAllTargetsComboBox.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { fireAddFilteredTargetVillages(); } }); filterDialog = new TroopFilterDialog(this, true); // <editor-fold defaultstate="collapsed" desc="Add selection listeners"> jVillageGroupList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { fireFilterSourceVillagesByGroupEvent(); } } }); jSourceContinentList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { fireFilterSourceContinentEvent(); } } }); jTargetTribeList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { fireFilterTargetByTribeEvent(); } } }); jTargetContinentList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { fireFilterTargetByContinentEvent(); } } }); jTargetAllyList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { fireFilterTargetByAllyEvent(); } } }); // </editor-fold> // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem "> if (!Constants.DEBUG) { GlobalOptions.getHelpBroker().enableHelp(jSourcePanel, "pages.attack_planer_source", GlobalOptions.getHelpBroker().getHelpSet()); GlobalOptions.getHelpBroker().enableHelp(jTargetPanel, "pages.attack_planer_target", GlobalOptions.getHelpBroker().getHelpSet()); GlobalOptions.getHelpBroker().enableHelp(mSettingsPanel, "pages.attack_planer_settings", GlobalOptions.getHelpBroker().getHelpSet()); GlobalOptions.getHelpBroker().enableHelpKey(jResultFrame.getRootPane(), "pages.attack_planer_results", GlobalOptions.getHelpBroker().getHelpSet()); GlobalOptions.getHelpBroker().enableHelpKey(jTargetResultDetailsFrame.getRootPane(), "pages.attack_planer_results_details_targets", GlobalOptions.getHelpBroker().getHelpSet()); GlobalOptions.getHelpBroker().enableHelpKey(jAttackResultDetailsFrame.getRootPane(), "pages.attack_planer_results_details_sources", GlobalOptions.getHelpBroker().getHelpSet()); GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.attack_planer", GlobalOptions.getHelpBroker().getHelpSet()); } // </editor-fold> }
From source file:com.osparking.attendant.AttListForm.java
private void attachEnterHandler(JComponent compo) { Action handleEnter = new AbstractAction() { public void actionPerformed(ActionEvent e) { searchButtonActionPerformed(null); }//from w ww . j a v a 2s.c o m }; compo.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "handleEnter"); compo.getActionMap().put("handleEnter", handleEnter); }
From source file:org.nuclos.client.genericobject.logbook.LogbookController.java
private static void setupEscapeKey(final MainFrameTab ifrm, LogbookPanel pnlLogbook) { // Escape key is to close the window: final Action actClose = new AbstractAction() { @Override// w ww . ja v a 2 s .com public void actionPerformed(ActionEvent ev) { ifrm.dispose(); } }; final String KEY_CLOSE = "Close"; ifrm.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), KEY_CLOSE); ifrm.getRootPane().getActionMap().put(KEY_CLOSE, actClose); pnlLogbook.getTable().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), KEY_CLOSE); pnlLogbook.getTable().getActionMap().put(KEY_CLOSE, actClose); }
From source file:org.ngrinder.recorder.ui.RecordingControlPanel.java
/** * Create Filter Button Panel.//from ww w .j a v a 2 s . co m * * @return filter button panel */ protected JPanel createFilterButtonPanel() { JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); panel.add(createSimpleTextButton("Unselect All", new AbstractAction() { /** UUID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { for (EndPoint each : connectionFilter.getConnectionEndPoints()) { connectionFilter.setFilter(each, true); } } })); DropDownButton resetDropDownButton = createSimpleDropDownButton("Reset", null); panel.add(resetDropDownButton); JPopupMenu menu = new JPopupMenu(); menu.add(createMenuItem("Clear all recording", new AbstractAction() { /** UUID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { messageBus.getPublisher(Topics.RESET) .propertyChange(new PropertyChangeEvent(RecordingControlPanel.this, "RESET", null, null)); connectionFilter.makeZeroCount(); } })); menu.add(createMenuItem("Clear all filters", new AbstractAction() { /** UUID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { connectionFilter.reset(); } })); menu.add(createMenuItem("Clear connection count", new AbstractAction() { /** UUID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { connectionFilter.makeZeroCount(); } })); menu.add(createMenuItem("Reset browser cache", new AbstractAction() { /** UUID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { BrowserServices browserServices = BrowserServices.getInstance(); for (BrowserType type : BrowserFactoryEx.getSupportedBrowser()) { clearCacheIfSupported(browserServices, type); } } private void clearCacheIfSupported(BrowserServices browserServices, BrowserType type) { if (type.isSupported()) { try { browserServices.getCacheStorage(type).clearCache(); } catch (Exception e) { NoOp.noOp(); } } } })); menu.add(createMenuItem("Reset cookies", new AbstractAction() { /** UUID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { BrowserServices browserServices = BrowserServices.getInstance(); for (BrowserType type : BrowserFactoryEx.getSupportedBrowser()) { clearCookieIfSupported(browserServices, type); } } private void clearCookieIfSupported(BrowserServices browserServices, BrowserType type) { if (type.isSupported()) { try { HttpCookieStorage cookieStorage = browserServices.getCookieStorage(type); List<HttpCookie> cookies = cookieStorage.getCookies(); cookieStorage.deleteCookie(cookies); } catch (Exception e) { NoOp.noOp(); } } } })); resetDropDownButton.setMenu(menu); return panel; }
From source file:net.sf.xmm.moviemanager.gui.DialogIMDbMultiAdd.java
private void setHotkeyModifiers() { try {//from w w w .j a v a 2s .c o m // ALT+P for Play shortcutManager.registerKeyboardShortcut( KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyboardShortcutManager.getToolbarShortcutMask()), "Play file", new AbstractAction() { public void actionPerformed(ActionEvent ae) { playMediaFiles.doClick(); } }, playMediaFiles); } catch (Exception e) { log.warn("Exception:" + e.getMessage(), e); } }
From source file:fll.subjective.SubjectiveFrame.java
/** * Set the tab and return behavior for a table. *//*ww w . ja va 2s . c om*/ private void setupTabReturnBehavior(final JTable table) { final InputMap im = table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); // Have the enter key work the same as the tab key final KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0); final KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); im.put(enter, im.get(tab)); // Override the default tab behavior // Tab to the next editable cell. When no editable cells goto next cell. final Action oldTabAction = table.getActionMap().get(im.get(tab)); final Action tabAction = new AbstractAction() { public void actionPerformed(final ActionEvent e) { if (null != oldTabAction) { oldTabAction.actionPerformed(e); } final JTable table = (JTable) e.getSource(); final int rowCount = table.getRowCount(); final int columnCount = table.getColumnCount(); int row = table.getSelectedRow(); int column = table.getSelectedColumn(); // skip the no show when tabbing while (!table.isCellEditable(row, column) || table.getColumnClass(column) == Boolean.class) { column += 1; if (column == columnCount) { column = 0; row += 1; } if (row == rowCount) { row = 0; } // Back to where we started, get out. if (row == table.getSelectedRow() && column == table.getSelectedColumn()) { break; } } table.changeSelection(row, column, false, false); } }; table.getActionMap().put(im.get(tab), tabAction); }
From source file:ffx.ui.MainMenu.java
private Action addMenuItem(JMenu menu, String icon, String actionCommand, int mnemonic, int accelerator, final ActionListener actionListener) { Action a = new AbstractAction() { @Override// ww w. j a v a2 s.c o m public void actionPerformed(ActionEvent e) { actionListener.actionPerformed(e); } }; configureAction(a, icon, actionCommand, mnemonic, accelerator); JMenuItem menuItem = new JMenuItem(a); menu.add(menuItem); return a; }
From source file:com.vgi.mafscaling.MafCompare.java
/** * Initialize the contents of the frame. *///from w w w . ja v a2 s .c om private void initialize() { try { ImageIcon tableImage = new ImageIcon(getClass().getResource("/table.jpg")); setTitle(Title); setIconImage(tableImage.getImage()); setBounds(100, 100, 621, 372); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setSize(Config.getCompWindowSize()); setLocation(Config.getCompWindowLocation()); setLocationRelativeTo(null); setVisible(false); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { Utils.clearTable(origMafTable); Utils.clearTable(newMafTable); Utils.clearTable(compMafTable); Config.setCompWindowSize(getSize()); Config.setCompWindowLocation(getLocation()); origMafData.clear(); newMafData.clear(); } }); JPanel dataPanel = new JPanel(); GridBagLayout gbl_dataPanel = new GridBagLayout(); gbl_dataPanel.columnWidths = new int[] { 0, 0, 0 }; gbl_dataPanel.rowHeights = new int[] { RowHeight, RowHeight, RowHeight, RowHeight, RowHeight, 0 }; gbl_dataPanel.columnWeights = new double[] { 0.0, 0.0, 0.0 }; gbl_dataPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 }; dataPanel.setLayout(gbl_dataPanel); getContentPane().add(dataPanel); JLabel origLabel = new JLabel(origMaf); GridBagConstraints gbc_origLabel = new GridBagConstraints(); gbc_origLabel.anchor = GridBagConstraints.PAGE_START; gbc_origLabel.insets = new Insets(1, 1, 1, 5); gbc_origLabel.weightx = 0; gbc_origLabel.weighty = 0; gbc_origLabel.gridx = 0; gbc_origLabel.gridy = 0; gbc_origLabel.gridheight = 2; dataPanel.add(origLabel, gbc_origLabel); JLabel newLabel = new JLabel(newMaf); GridBagConstraints gbc_newLabel = new GridBagConstraints(); gbc_newLabel.anchor = GridBagConstraints.PAGE_START; gbc_newLabel.insets = new Insets(1, 1, 1, 5); gbc_newLabel.weightx = 0; gbc_newLabel.weighty = 0; gbc_newLabel.gridx = 0; gbc_newLabel.gridy = 2; gbc_newLabel.gridheight = 2; dataPanel.add(newLabel, gbc_newLabel); JLabel compLabel = new JLabel("Change"); GridBagConstraints gbc_compLabel = new GridBagConstraints(); gbc_compLabel.anchor = GridBagConstraints.PAGE_START; gbc_compLabel.insets = new Insets(1, 1, 1, 5); gbc_compLabel.weightx = 0; gbc_compLabel.weighty = 0; gbc_compLabel.gridx = 0; gbc_compLabel.gridy = 4; dataPanel.add(compLabel, gbc_compLabel); JLabel origVoltLabel = new JLabel("volt"); GridBagConstraints gbc_origVoltLabel = new GridBagConstraints(); gbc_origVoltLabel.anchor = GridBagConstraints.PAGE_START; gbc_origVoltLabel.insets = new Insets(1, 1, 1, 5); gbc_origVoltLabel.weightx = 0; gbc_origVoltLabel.weighty = 0; gbc_origVoltLabel.gridx = 1; gbc_origVoltLabel.gridy = 0; dataPanel.add(origVoltLabel, gbc_origVoltLabel); JLabel origGsLabel = new JLabel(" g/s"); GridBagConstraints gbc_origGsLabel = new GridBagConstraints(); gbc_origGsLabel.anchor = GridBagConstraints.PAGE_START; gbc_origGsLabel.insets = new Insets(1, 1, 1, 5); gbc_origGsLabel.weightx = 0; gbc_origGsLabel.weighty = 0; gbc_origGsLabel.gridx = 1; gbc_origGsLabel.gridy = 1; dataPanel.add(origGsLabel, gbc_origGsLabel); JLabel newVoltLabel = new JLabel("volt"); GridBagConstraints gbc_newVoltLabel = new GridBagConstraints(); gbc_newVoltLabel.anchor = GridBagConstraints.PAGE_START; gbc_newVoltLabel.insets = new Insets(1, 1, 1, 5); gbc_newVoltLabel.weightx = 0; gbc_newVoltLabel.weighty = 0; gbc_newVoltLabel.gridx = 1; gbc_newVoltLabel.gridy = 2; dataPanel.add(newVoltLabel, gbc_newVoltLabel); JLabel newGsLabel = new JLabel(" g/s"); GridBagConstraints gbc_newGsLabel = new GridBagConstraints(); gbc_newGsLabel.anchor = GridBagConstraints.PAGE_START; gbc_newGsLabel.insets = new Insets(1, 1, 1, 5); gbc_newGsLabel.weightx = 0; gbc_newGsLabel.weighty = 0; gbc_newGsLabel.gridx = 1; gbc_newGsLabel.gridy = 3; dataPanel.add(newGsLabel, gbc_newGsLabel); JLabel compPctLabel = new JLabel(" % "); GridBagConstraints gbc_compPctLabel = new GridBagConstraints(); gbc_compPctLabel.anchor = GridBagConstraints.PAGE_START; gbc_compPctLabel.insets = new Insets(1, 1, 1, 5); gbc_compPctLabel.weightx = 0; gbc_compPctLabel.weighty = 0; gbc_compPctLabel.gridx = 1; gbc_compPctLabel.gridy = 4; dataPanel.add(compPctLabel, gbc_compPctLabel); JPanel tablesPanel = new JPanel(); GridBagLayout gbl_tablesPanel = new GridBagLayout(); gbl_tablesPanel.columnWidths = new int[] { 0 }; gbl_tablesPanel.rowHeights = new int[] { 0, 0, 0 }; gbl_tablesPanel.columnWeights = new double[] { 0.0 }; gbl_tablesPanel.rowWeights = new double[] { 0.0, 0.0, 1.0 }; tablesPanel.setLayout(gbl_tablesPanel); JScrollPane mafScrollPane = new JScrollPane(tablesPanel); mafScrollPane.setMinimumSize(new Dimension(1600, 107)); mafScrollPane.getHorizontalScrollBar().setMaximumSize(new Dimension(20, 20)); mafScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); mafScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); GridBagConstraints gbc_mafScrollPane = new GridBagConstraints(); gbc_mafScrollPane.weightx = 1.0; gbc_mafScrollPane.anchor = GridBagConstraints.PAGE_START; gbc_mafScrollPane.fill = GridBagConstraints.HORIZONTAL; gbc_mafScrollPane.gridx = 2; gbc_mafScrollPane.gridy = 0; gbc_mafScrollPane.gridheight = 5; dataPanel.add(mafScrollPane, gbc_mafScrollPane); origMafTable = new JTable(); origMafTable.setColumnSelectionAllowed(true); origMafTable.setCellSelectionEnabled(true); origMafTable.setBorder(new LineBorder(new Color(0, 0, 0))); origMafTable.setRowHeight(RowHeight); origMafTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); origMafTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); origMafTable.setModel(new DefaultTableModel(2, MafTableColumnCount)); origMafTable.setTableHeader(null); Utils.initializeTable(origMafTable, ColumnWidth); GridBagConstraints gbc_origMafTable = new GridBagConstraints(); gbc_origMafTable.anchor = GridBagConstraints.PAGE_START; gbc_origMafTable.insets = new Insets(0, 0, 0, 0); gbc_origMafTable.fill = GridBagConstraints.HORIZONTAL; gbc_origMafTable.weightx = 1.0; gbc_origMafTable.weighty = 0; gbc_origMafTable.gridx = 0; gbc_origMafTable.gridy = 0; tablesPanel.add(origMafTable, gbc_origMafTable); excelAdapter.addTable(origMafTable, false, false, false, false, true, false, true, false, true); newMafTable = new JTable(); newMafTable.setColumnSelectionAllowed(true); newMafTable.setCellSelectionEnabled(true); newMafTable.setBorder(new LineBorder(new Color(0, 0, 0))); newMafTable.setRowHeight(RowHeight); newMafTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); newMafTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); newMafTable.setModel(new DefaultTableModel(2, MafTableColumnCount)); newMafTable.setTableHeader(null); Utils.initializeTable(newMafTable, ColumnWidth); GridBagConstraints gbc_newMafTable = new GridBagConstraints(); gbc_newMafTable.anchor = GridBagConstraints.PAGE_START; gbc_newMafTable.insets = new Insets(0, 0, 0, 0); gbc_newMafTable.fill = GridBagConstraints.HORIZONTAL; gbc_newMafTable.weightx = 1.0; gbc_newMafTable.weighty = 0; gbc_newMafTable.gridx = 0; gbc_newMafTable.gridy = 1; tablesPanel.add(newMafTable, gbc_newMafTable); excelAdapter.addTable(newMafTable, false, false, false, false, false, false, false, false, true); compMafTable = new JTable(); compMafTable.setColumnSelectionAllowed(true); compMafTable.setCellSelectionEnabled(true); compMafTable.setBorder(new LineBorder(new Color(0, 0, 0))); compMafTable.setRowHeight(RowHeight); compMafTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); compMafTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); compMafTable.setModel(new DefaultTableModel(1, MafTableColumnCount)); compMafTable.setTableHeader(null); Utils.initializeTable(compMafTable, ColumnWidth); NumberFormatRenderer numericRenderer = new NumberFormatRenderer(); numericRenderer.setFormatter(new DecimalFormat("0.000")); compMafTable.setDefaultRenderer(Object.class, numericRenderer); GridBagConstraints gbc_compMafTable = new GridBagConstraints(); gbc_compMafTable.anchor = GridBagConstraints.PAGE_START; gbc_compMafTable.insets = new Insets(0, 0, 0, 0); gbc_compMafTable.fill = GridBagConstraints.HORIZONTAL; gbc_compMafTable.weightx = 1.0; gbc_compMafTable.weighty = 0; gbc_compMafTable.gridx = 0; gbc_compMafTable.gridy = 2; tablesPanel.add(compMafTable, gbc_compMafTable); compExcelAdapter.addTable(compMafTable, false, true, false, false, false, true, true, false, true); TableModelListener origTableListener = new TableModelListener() { public void tableChanged(TableModelEvent tme) { if (tme.getType() == TableModelEvent.UPDATE) { int colCount = origMafTable.getColumnCount(); Utils.ensureColumnCount(colCount, newMafTable); Utils.ensureColumnCount(colCount, compMafTable); origMafData.clear(); String origY, origX, newY; for (int i = 0; i < colCount; ++i) { origY = origMafTable.getValueAt(1, i).toString(); if (Pattern.matches(Utils.fpRegex, origY)) { origX = origMafTable.getValueAt(0, i).toString(); if (Pattern.matches(Utils.fpRegex, origX)) origMafData.add(Double.valueOf(origX), Double.valueOf(origY), false); newY = newMafTable.getValueAt(1, i).toString(); if (Pattern.matches(Utils.fpRegex, newY)) compMafTable.setValueAt( ((Double.valueOf(newY) / Double.valueOf(origY)) - 1.0) * 100.0, 0, i); } else break; } origMafData.fireSeriesChanged(); } } }; TableModelListener newTableListener = new TableModelListener() { public void tableChanged(TableModelEvent tme) { if (tme.getType() == TableModelEvent.UPDATE) { int colCount = newMafTable.getColumnCount(); Utils.ensureColumnCount(colCount, origMafTable); Utils.ensureColumnCount(colCount, compMafTable); newMafData.clear(); String newY, newX, origY; for (int i = 0; i < colCount; ++i) { newY = newMafTable.getValueAt(1, i).toString(); if (Pattern.matches(Utils.fpRegex, newY)) { newX = newMafTable.getValueAt(0, i).toString(); if (Pattern.matches(Utils.fpRegex, newX)) newMafData.add(Double.valueOf(newX), Double.valueOf(newY), false); origY = origMafTable.getValueAt(1, i).toString(); if (Pattern.matches(Utils.fpRegex, origY)) compMafTable.setValueAt( ((Double.valueOf(newY) / Double.valueOf(origY)) - 1.0) * 100.0, 0, i); } else break; } newMafData.fireSeriesChanged(); } } }; origMafTable.getModel().addTableModelListener(origTableListener); newMafTable.getModel().addTableModelListener(newTableListener); Action action = new AbstractAction() { private static final long serialVersionUID = 8148393537657380215L; public void actionPerformed(ActionEvent e) { TableCellListener tcl = (TableCellListener) e.getSource(); if (Pattern.matches(Utils.fpRegex, compMafTable.getValueAt(0, tcl.getColumn()).toString())) { if (Pattern.matches(Utils.fpRegex, origMafTable.getValueAt(1, tcl.getColumn()).toString())) { double corr = Double.valueOf(compMafTable.getValueAt(0, tcl.getColumn()).toString()) / 100.0 + 1.0; newMafTable.setValueAt( Double.valueOf(origMafTable.getValueAt(1, tcl.getColumn()).toString()) * corr, 1, tcl.getColumn()); } } else compMafTable.setValueAt(tcl.getOldValue(), 0, tcl.getColumn()); } }; setCompMafCellListener(new TableCellListener(compMafTable, action)); // CHART JFreeChart chart = ChartFactory.createXYLineChart(null, null, null, null, PlotOrientation.VERTICAL, false, true, false); chart.setBorderVisible(true); chartPanel = new ChartPanel(chart, true, true, true, true, true); chartPanel.setAutoscrolls(true); GridBagConstraints gbl_chartPanel = new GridBagConstraints(); gbl_chartPanel.anchor = GridBagConstraints.PAGE_START; gbl_chartPanel.fill = GridBagConstraints.BOTH; gbl_chartPanel.insets = new Insets(1, 1, 1, 1); gbl_chartPanel.weightx = 1.0; gbl_chartPanel.weighty = 1.0; gbl_chartPanel.gridx = 0; gbl_chartPanel.gridy = 5; gbl_chartPanel.gridheight = 1; gbl_chartPanel.gridwidth = 3; dataPanel.add(chartPanel, gbl_chartPanel); XYSplineRenderer lineRenderer = new XYSplineRenderer(3); lineRenderer.setUseFillPaint(true); lineRenderer.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new DecimalFormat("0.00"), new DecimalFormat("0.00"))); Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f); lineRenderer.setSeriesStroke(0, stroke); lineRenderer.setSeriesStroke(1, stroke); lineRenderer.setSeriesPaint(0, new Color(201, 0, 0)); lineRenderer.setSeriesPaint(1, new Color(0, 0, 255)); lineRenderer.setSeriesShape(0, ShapeUtilities.createDiamond((float) 2.5)); lineRenderer.setSeriesShape(1, ShapeUtilities.createDownTriangle((float) 2.5)); lineRenderer.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator() { private static final long serialVersionUID = -4045338273187150888L; public String generateLabel(XYDataset dataset, int series) { XYSeries xys = ((XYSeriesCollection) dataset).getSeries(series); return xys.getDescription(); } }); NumberAxis mafvDomain = new NumberAxis(XAxisName); mafvDomain.setAutoRangeIncludesZero(false); mafvDomain.setAutoRange(true); mafvDomain.setAutoRangeStickyZero(false); NumberAxis mafgsRange = new NumberAxis(YAxisName); mafgsRange.setAutoRangeIncludesZero(false); mafgsRange.setAutoRange(true); mafgsRange.setAutoRangeStickyZero(false); XYSeriesCollection lineDataset = new XYSeriesCollection(); origMafData.setDescription(origMaf); newMafData.setDescription(newMaf); lineDataset.addSeries(origMafData); lineDataset.addSeries(newMafData); XYPlot plot = chart.getXYPlot(); plot.setRangePannable(true); plot.setDomainPannable(true); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.setBackgroundPaint(new Color(224, 224, 224)); plot.setDataset(0, lineDataset); plot.setRenderer(0, lineRenderer); plot.setDomainAxis(0, mafvDomain); plot.setRangeAxis(0, mafgsRange); plot.mapDatasetToDomainAxis(0, 0); plot.mapDatasetToRangeAxis(0, 0); LegendTitle legend = new LegendTitle(plot.getRenderer()); legend.setItemFont(new Font("Arial", 0, 10)); legend.setPosition(RectangleEdge.TOP); chart.addLegend(legend); } catch (Exception e) { logger.error(e); } }