List of usage examples for javax.swing KeyStroke getKeyStroke
public static KeyStroke getKeyStroke(int keyCode, int modifiers)
From source file:net.sourceforge.happybank.main.BankMain.java
private void initComponents() { frame = new javax.swing.JFrame(); menuBar = new javax.swing.JMenuBar(); menuFile = new javax.swing.JMenu(); menuItemExit = new javax.swing.JMenuItem(); menuActions = new javax.swing.JMenu(); menuItemView = new javax.swing.JMenuItem(); separator2 = new javax.swing.JSeparator(); menuHelp = new javax.swing.JMenu(); separator4 = new javax.swing.JSeparator(); menuItemAbout = new javax.swing.JMenuItem(); accountEntries = new javax.swing.JTable(); accountModel = new AccountTableModel(); /*/*w w w . j a v a 2 s .com*/ * File menu */ menuFile.setMnemonic('F'); menuFile.setText("File"); // - Exit option menuItemExit.setMnemonic('X'); menuItemExit.setText("Exit"); menuItemExit.setActionCommand("Exit"); menuItemExit.addActionListener(new ActionHandler()); menuFile.add(menuItemExit); menuBar.add(menuFile); // Actions menu menuActions.setMnemonic('A'); menuActions.setText("Actions"); // - View option menuItemView.setMnemonic('V'); menuItemView .setAccelerator(KeyStroke.getKeyStroke('V', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menuItemView.setText("View"); menuItemView.setActionCommand("View"); menuItemView.addActionListener(new ActionHandler()); menuActions.add(menuItemView); menuActions.add(separator2); // Help menu menuHelp.setMnemonic('H'); menuHelp.setText("Help"); // - About option menuHelp.add(separator4); menuItemAbout.setMnemonic('A'); menuItemAbout.setText("About"); menuItemAbout.setActionCommand("About"); menuItemAbout.addActionListener(new ActionHandler()); menuHelp.add(menuItemAbout); menuBar.add(menuHelp); /* * configure the TabListCellRenderer */ accountEntries.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); accountEntries.setAutoCreateColumnsFromModel(false); accountEntries.setModel(accountModel); accountEntries.getTableHeader().setReorderingAllowed(false); accountEntries.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); accountEntries.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { // capture single click if (evt.getClickCount() == 1 && SwingUtilities.isLeftMouseButton(evt)) { // ignore } // capture double click if (evt.getClickCount() == 2) { // edit the account int row = accountEntries.rowAtPoint(evt.getPoint()); accountEntries.setRowSelectionInterval(row, row); onViewAccount(); } } // mouseClicked }); // MouseAdapter // set the column widths and alignment for (int k = 0; k < AccountTableModel.COLUMNS.length; k++) { TableCellEditor zipper = new DefaultCellEditor(new JTextField()); DefaultTableCellRenderer textRenderer = new DefaultTableCellRenderer(); textRenderer.setHorizontalAlignment(AccountTableModel.COLUMNS[k].cAlignment); TableColumn column = new TableColumn(k, AccountTableModel.COLUMNS[k].cWidth, textRenderer, zipper); accountEntries.addColumn(column); } // set the table header JTableHeader header = accountEntries.getTableHeader(); header.setUpdateTableInRealTime(false); /* * create the selection area */ accountPanel = new JPanel(); accountPanel.setLayout(new BorderLayout()); scrollPane = new JScrollPane(accountEntries); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); scrollPane.setPreferredSize(new java.awt.Dimension(750, 300)); accountPanel.add(scrollPane); frame.getContentPane().add(accountPanel, java.awt.BorderLayout.CENTER); /* * layout the frame */ frame.setJMenuBar(menuBar); frame.setTitle(APP_NAME); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation(screenSize.width / 2 - 300, screenSize.height / 2 - 200); // add a listener for the close event frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { onExit(); } }); loadAccounts(); }
From source file:net.sf.firemox.DeckBuilder.java
/** * Creates new form DeckBuilder/*from w w w .j ava2 s. c o m*/ */ private DeckBuilder() { super("DeckBuilder"); form = this; timerPanel = new TimerGlassPane(); cardLoader = new CardLoader(timerPanel); timer = new Timer(200, cardLoader); setGlassPane(timerPanel); try { setIconImage(Picture.loadImage(IdConst.IMAGES_DIR + "deckbuilder.gif")); } catch (Exception e) { // IGNORING } // Load settings loadSettings(); // Initialize components final JMenuItem newItem = UIHelper.buildMenu("menu_db_new", 'n', this); newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK)); final JMenuItem loadItem = UIHelper.buildMenu("menu_db_load", 'o', this); loadItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK)); final JMenuItem saveAsItem = UIHelper.buildMenu("menu_db_saveas", 'a', this); saveAsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0)); final JMenuItem saveItem = UIHelper.buildMenu("menu_db_save", 's', this); saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK)); final JMenuItem quitItem = UIHelper.buildMenu("menu_db_exit", this); quitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK)); final JMenuItem deckConstraintsItem = UIHelper.buildMenu("menu_db_constraints", 'c', this); deckConstraintsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0)); final JMenuItem aboutItem = UIHelper.buildMenu("menu_help_about", 'a', this); aboutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.SHIFT_MASK)); final JMenuItem convertDCK = UIHelper.buildMenu("menu_convert_DCK_MP", this); final JMenu mainMenu = UIHelper.buildMenu("menu_file"); mainMenu.add(newItem); mainMenu.add(loadItem); mainMenu.add(saveAsItem); mainMenu.add(saveItem); mainMenu.add(new JSeparator()); mainMenu.add(quitItem); super.optionMenu = new JMenu("Options"); final JMenu convertMenu = UIHelper.buildMenu("menu_convert"); convertMenu.add(convertDCK); final JMenuItem helpItem = UIHelper.buildMenu("menu_help_help", 'h', this); helpItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); final JMenu helpMenu = new JMenu("?"); helpMenu.add(helpItem); helpMenu.add(deckConstraintsItem); helpMenu.add(aboutItem); final JMenuBar menuBar = new JMenuBar(); menuBar.add(mainMenu); initAbstractMenu(); menuBar.add(optionMenu); menuBar.add(convertMenu); menuBar.add(helpMenu); setJMenuBar(menuBar); addWindowListener(this); // Build the panel containing amount of available cards final JLabel amountLeft = new JLabel("<html>0/?", SwingConstants.RIGHT); // Build the left list allListModel = new MListModel<MCardCompare>(amountLeft, false); leftList = new ThreadSafeJList(allListModel); leftList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); leftList.setLayoutOrientation(JList.VERTICAL); leftList.getSelectionModel().addListSelectionListener(this); leftList.addMouseListener(this); leftList.setVisibleRowCount(10); // Initialize the text field containing the amount to add addQtyTxt = new JTextField("1"); // Build the "Add" button addButton = new JButton(LanguageManager.getString("db_add")); addButton.setMnemonic('a'); addButton.setEnabled(false); // Build the panel containing : "Add" amount and "Add" button final Box addPanel = Box.createHorizontalBox(); addPanel.add(addButton); addPanel.add(addQtyTxt); addPanel.setMaximumSize(new Dimension(32010, 26)); // Build the panel containing the selected card name cardNameTxt = new JTextField(); new HireListener(cardNameTxt, addButton, this, leftList); final JLabel searchLabel = new JLabel(LanguageManager.getString("db_search") + " : "); searchLabel.setLabelFor(cardNameTxt); // Build the panel containing search label and card name text field final Box searchPanel = Box.createHorizontalBox(); searchPanel.add(searchLabel); searchPanel.add(cardNameTxt); searchPanel.setMaximumSize(new Dimension(32010, 26)); listScrollerLeft = new JScrollPane(leftList); MToolKit.addOverlay(listScrollerLeft); // Build the left panel containing : list, available amount, "Add" panel final JPanel srcPanel = new JPanel(null); srcPanel.add(searchPanel); srcPanel.add(listScrollerLeft); srcPanel.add(amountLeft); srcPanel.add(addPanel); srcPanel.setMinimumSize(new Dimension(220, 200)); srcPanel.setLayout(new BoxLayout(srcPanel, BoxLayout.Y_AXIS)); // Initialize constraints constraintsChecker = new ConstraintsChecker(); constraintsChecker.setBorder(new EtchedBorder()); final JScrollPane constraintsCheckerScroll = new JScrollPane(constraintsChecker); MToolKit.addOverlay(constraintsCheckerScroll); // create a pane with the oracle text for the present card oracleText = new JLabel(); oracleText.setPreferredSize(new Dimension(180, 200)); oracleText.setVerticalAlignment(SwingConstants.TOP); final JScrollPane oracle = new JScrollPane(oracleText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); MToolKit.addOverlay(oracle); // build some Pie Charts and a panel to display it initSets(); datasets = new ChartSets(); final JTabbedPane tabbedPane = new JTabbedPane(); for (ChartFilter filter : ChartFilter.values()) { final Dataset dataSet = filter.createDataSet(this); final JFreeChart chart = new JFreeChart(null, null, filter.createPlot(dataSet, painterMapper.get(filter)), false); datasets.addDataSet(filter, dataSet); ChartPanel pieChartPanel = new ChartPanel(chart, true); tabbedPane.add(pieChartPanel, filter.getTitle()); } // add the Constraints scroll panel and Oracle text Pane to the tabbedPane tabbedPane.add(constraintsCheckerScroll, LanguageManager.getString("db_constraints")); tabbedPane.add(oracle, LanguageManager.getString("db_text")); tabbedPane.setSelectedComponent(oracle); // The toollBar for color filtering toolBar = new JToolBar(); toolBar.setFloatable(false); final JButton clearButton = UIHelper.buildButton("clear"); clearButton.addActionListener(this); toolBar.add(clearButton); final JToggleButton toggleColorlessButton = new JToggleButton( UIHelper.getTbsIcon("mana/colorless/small/" + MdbLoader.unknownSmlMana), true); toggleColorlessButton.setActionCommand("0"); toggleColorlessButton.addActionListener(this); toolBar.add(toggleColorlessButton); for (int index = 1; index < IdCardColors.CARD_COLOR_NAMES.length; index++) { final JToggleButton toggleButton = new JToggleButton( UIHelper.getTbsIcon("mana/colored/small/" + MdbLoader.coloredSmlManas[index]), true); toggleButton.setActionCommand(String.valueOf(index)); toggleButton.addActionListener(this); toolBar.add(toggleButton); } // sorted card type combobox creation final List<String> idCards = new ArrayList<String>(Arrays.asList(CardFactory.exportedIdCardNames)); Collections.sort(idCards); final Object[] cardTypes = ArrayUtils.addAll(new String[] { LanguageManager.getString("db_types.any") }, idCards.toArray()); idCardComboBox = new JComboBox(cardTypes); idCardComboBox.setSelectedIndex(0); idCardComboBox.addActionListener(this); idCardComboBox.setActionCommand("cardTypeFilter"); // sorted card properties combobox creation final List<String> properties = new ArrayList<String>( CardFactory.getPropertiesName(DeckConstraints.getMinProperty(), DeckConstraints.getMaxProperty())); Collections.sort(properties); final Object[] cardProperties = ArrayUtils .addAll(new String[] { LanguageManager.getString("db_properties.any") }, properties.toArray()); propertiesComboBox = new JComboBox(cardProperties); propertiesComboBox.setSelectedIndex(0); propertiesComboBox.addActionListener(this); propertiesComboBox.setActionCommand("propertyFilter"); final JLabel colors = new JLabel(" " + LanguageManager.getString("colors") + " : "); final JLabel types = new JLabel(" " + LanguageManager.getString("types") + " : "); final JLabel property = new JLabel(" " + LanguageManager.getString("properties") + " : "); // filter Panel with colors toolBar and card type combobox final Box filterPanel = Box.createHorizontalBox(); filterPanel.add(colors); filterPanel.add(toolBar); filterPanel.add(types); filterPanel.add(idCardComboBox); filterPanel.add(property); filterPanel.add(propertiesComboBox); getContentPane().add(filterPanel, BorderLayout.NORTH); // Destination section : // Build the panel containing amount of available cards final JLabel rightAmount = new JLabel("0/?", SwingConstants.RIGHT); rightAmount.setMaximumSize(new Dimension(220, 26)); // Build the right list rightListModel = new MCardTableModel(new MListModel<MCardCompare>(rightAmount, true)); rightListModel.addTableModelListener(this); rightList = new JTable(rightListModel); rightList.setShowGrid(false); rightList.setTableHeader(null); rightList.getSelectionModel().addListSelectionListener(this); rightList.getColumnModel().getColumn(0).setMaxWidth(25); rightList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); // Build the panel containing the selected deck deckNameTxt = new JTextField("loading..."); deckNameTxt.setEditable(false); deckNameTxt.setBorder(null); final JLabel deckLabel = new JLabel(LanguageManager.getString("db_deck") + " : "); deckLabel.setLabelFor(deckNameTxt); final Box deckNamePanel = Box.createHorizontalBox(); deckNamePanel.add(deckLabel); deckNamePanel.add(deckNameTxt); deckNamePanel.setMaximumSize(new Dimension(220, 26)); // Initialize the text field containing the amount to remove removeQtyTxt = new JTextField("1"); // Build the "Remove" button removeButton = new JButton(LanguageManager.getString("db_remove")); removeButton.setMnemonic('r'); removeButton.addMouseListener(this); removeButton.setEnabled(false); // Build the panel containing : "Remove" amount and "Remove" button final Box removePanel = Box.createHorizontalBox(); removePanel.add(removeButton); removePanel.add(removeQtyTxt); removePanel.setMaximumSize(new Dimension(220, 26)); // Build the right panel containing : list, available amount, constraints final JScrollPane deskListScroller = new JScrollPane(rightList); MToolKit.addOverlay(deskListScroller); deskListScroller.setBorder(BorderFactory.createLineBorder(Color.GRAY)); deskListScroller.setMinimumSize(new Dimension(220, 200)); deskListScroller.setMaximumSize(new Dimension(220, 32000)); final Box destPanel = Box.createVerticalBox(); destPanel.add(deckNamePanel); destPanel.add(deskListScroller); destPanel.add(rightAmount); destPanel.add(removePanel); destPanel.setMinimumSize(new Dimension(220, 200)); destPanel.setMaximumSize(new Dimension(220, 32000)); // Build the panel containing the name of card in picture cardPictureNameTxt = new JLabel("<html><i>no selected card</i>"); final Box cardPictureNamePanel = Box.createHorizontalBox(); cardPictureNamePanel.add(cardPictureNameTxt); cardPictureNamePanel.setMaximumSize(new Dimension(32010, 26)); // Group the detail panels final JPanel viewCard = new JPanel(null); viewCard.add(cardPictureNamePanel); viewCard.add(CardView.getInstance()); viewCard.add(tabbedPane); viewCard.setLayout(new BoxLayout(viewCard, BoxLayout.Y_AXIS)); final Box mainPanel = Box.createHorizontalBox(); mainPanel.add(destPanel); mainPanel.add(viewCard); // Add the main panel getContentPane().add(srcPanel, BorderLayout.WEST); getContentPane().add(mainPanel, BorderLayout.CENTER); // Size this frame getRootPane().setPreferredSize(new Dimension(WINDOW_WIDTH, WINDOW_HEIGHT)); getRootPane().setMinimumSize(getRootPane().getPreferredSize()); pack(); }
From source file:net.andydvorak.intellij.lessc.ui.configurable.LessProfilesPanel.java
@Nullable protected ArrayList<AnAction> createActions(final boolean fromPopup) { final ArrayList<AnAction> result = new ArrayList<AnAction>(); final String addText = UIBundle.message("action.add.less.profile.text"); final String addDescription = UIBundle.message("action.add.less.profile.description"); final String addPromptTitle = UIBundle.message("action.add.less.profile.prompt.title"); result.add(new AnAction(addText, addDescription, PlatformIcons.ADD_ICON) { {// w w w . j av a 2s .co m registerCustomShortcutSet(CommonShortcuts.INSERT, myTree); } public void actionPerformed(final AnActionEvent event) { final String name = askForProfileName(addPromptTitle, ""); if (name == null) return; final LessProfile lessProfile = new LessProfile(getNextId(), name); addProfileNode(lessProfile); } }); result.add(new MyDeleteAction(forAll(Conditions.alwaysTrue()))); final String copyText = UIBundle.message("action.copy.less.profile.text"); final String copyDescription = UIBundle.message("action.copy.less.profile.description"); final String copyPromptTitle = UIBundle.message("action.copy.less.profile.prompt.title"); result.add(new AnAction(copyText, copyDescription, PlatformIcons.COPY_ICON) { { registerCustomShortcutSet( new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_MASK)), myTree); } public void actionPerformed(final AnActionEvent event) { final String profileName = askForProfileName(copyPromptTitle, ""); if (profileName == null) return; final LessProfile clone = new LessProfile(getNextId(), (LessProfile) getSelectedObject()); clone.setName(profileName); addProfileNode(clone); } public void update(final AnActionEvent event) { super.update(event); event.getPresentation().setEnabled(getSelectedObject() != null); } }); return result; }
From source file:org.angnysa.yaba.swing.BudgetFrame.java
private void buildReconciliationTable() { reconciliationModel = new ReconciliationTableModel(service); reconciliationTable = new JTable(reconciliationModel); reconciliationTable.setRowHeight((int) (reconciliationTable.getRowHeight() * 1.2)); reconciliationTable.setDefaultEditor(LocalDate.class, new CustomCellEditor(new JFormattedTextField(new JodaLocalDateFormat()))); reconciliationTable.setDefaultEditor(Double.class, new CustomCellEditor(new JFormattedTextField(NumberFormat.getNumberInstance()))); reconciliationTable.setDefaultRenderer(LocalDate.class, new FormattedTableCellRenderer(new JodaLocalDateFormat())); reconciliationTable.setDefaultRenderer(Double.class, new FormattedTableCellRenderer(TransactionAmountFormatFactory.getFormat())); reconciliationTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); reconciliationTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete"); //$NON-NLS-1$ reconciliationTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "delete"); //$NON-NLS-1$ reconciliationTable.getActionMap().put("delete", new AbstractAction() { //$NON-NLS-1$ private static final long serialVersionUID = 1L; @Override/*from www . ja va2 s .c o m*/ public void actionPerformed(ActionEvent e) { int row = reconciliationTable.getSelectedRow(); if (row >= 0) { reconciliationModel.deleteRow(row); } } }); transactionTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int row = transactionTable.getSelectedRow(); if (row >= 0) { row = transactionTable.getRowSorter().convertRowIndexToModel(row); TransactionDefinition td = transactionModel.getTransactionForRow(row); if (td != null) { reconciliationModel.setCurrentTransactionId(td.getId()); } else { reconciliationModel.setCurrentTransactionId(-1); } } else { reconciliationModel.setCurrentTransactionId(-1); } } } }); }
From source file:ca.phon.app.session.editor.view.session_information.SessionInfoEditorView.java
private void init() { setLayout(new BorderLayout()); contentPanel = new TierDataLayoutPanel(); dateField = createDateField();/*from ww w.j ava 2 s . co m*/ dateField.getTextField().setColumns(10); dateField.setBackground(Color.white); mediaLocationField = new MediaSelectionField(getEditor().getProject()); mediaLocationField.setEditor(getEditor()); mediaLocationField.getTextField().setColumns(10); mediaLocationField.addPropertyChangeListener(FileSelectionField.FILE_PROP, mediaLocationListener); participantTable = new JXTable(); participantTable.setVisibleRowCount(3); ComponentInputMap participantTableInputMap = new ComponentInputMap(participantTable); ActionMap participantTableActionMap = new ActionMap(); ImageIcon deleteIcon = IconManager.getInstance().getIcon("actions/delete_user", IconSize.SMALL); final PhonUIAction deleteAction = new PhonUIAction(this, "deleteParticipant"); deleteAction.putValue(PhonUIAction.SHORT_DESCRIPTION, "Delete selected participant"); deleteAction.putValue(PhonUIAction.SMALL_ICON, deleteIcon); participantTableActionMap.put("DELETE_PARTICIPANT", deleteAction); participantTableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DELETE_PARTICIPANT"); participantTableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "DELETE_PARTICIPANT"); removeParticipantButton = new JButton(deleteAction); participantTable.setInputMap(WHEN_FOCUSED, participantTableInputMap); participantTable.setActionMap(participantTableActionMap); addParticipantButton = new JButton(new NewParticipantAction(getEditor(), this)); addParticipantButton.setFocusable(false); ImageIcon editIcon = IconManager.getInstance().getIcon("actions/edit_user", IconSize.SMALL); final PhonUIAction editParticipantAct = new PhonUIAction(this, "editParticipant"); editParticipantAct.putValue(PhonUIAction.NAME, "Edit participant..."); editParticipantAct.putValue(PhonUIAction.SHORT_DESCRIPTION, "Edit selected participant..."); editParticipantAct.putValue(PhonUIAction.SMALL_ICON, editIcon); editParticipantButton = new JButton(editParticipantAct); editParticipantButton.setFocusable(false); final CellConstraints cc = new CellConstraints(); FormLayout participantLayout = new FormLayout("fill:pref:grow, pref, pref, pref", "pref, pref, pref:grow"); JPanel participantPanel = new JPanel(participantLayout); participantPanel.setBackground(Color.white); participantPanel.add(new JScrollPane(participantTable), cc.xywh(1, 2, 3, 2)); participantPanel.add(addParticipantButton, cc.xy(2, 1)); participantPanel.add(editParticipantButton, cc.xy(3, 1)); participantPanel.add(removeParticipantButton, cc.xy(4, 2)); participantTable.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent arg0) { if (arg0.getClickCount() == 2 && arg0.getButton() == MouseEvent.BUTTON1) { editParticipantAct.actionPerformed(new ActionEvent(arg0.getSource(), arg0.getID(), "edit")); } } }); languageField = new LanguageField(); languageField.getDocument().addDocumentListener(languageFieldListener); int rowIdx = 0; final JLabel dateLbl = new JLabel("Session Date"); dateLbl.setHorizontalAlignment(SwingConstants.RIGHT); contentPanel.add(dateLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx)); contentPanel.add(dateField, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++)); final JLabel mediaLbl = new JLabel("Media"); mediaLbl.setHorizontalAlignment(SwingConstants.RIGHT); contentPanel.add(mediaLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx)); contentPanel.add(mediaLocationField, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++)); final JLabel partLbl = new JLabel("Participants"); partLbl.setHorizontalAlignment(SwingConstants.RIGHT); contentPanel.add(partLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx)); contentPanel.add(participantPanel, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++)); final JLabel langLbl = new JLabel("Language"); langLbl.setHorizontalAlignment(SwingConstants.RIGHT); contentPanel.add(langLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx)); contentPanel.add(languageField, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++)); add(new JScrollPane(contentPanel), BorderLayout.CENTER); update(); }
From source file:com.AandR.beans.plotting.imagePlotPanel.CanvasPanel.java
private void createPopupMenu() { popupMenu = new JPopupMenu(); popupMenu.add(createPopupMenuItem("Toggle Log Plot", null, KeyStroke.getKeyStroke(KeyEvent.VK_L, 0))); popupMenu.add(createPopupMenuItem("Slice Here", null, KeyStroke.getKeyStroke(KeyEvent.VK_C, 10))); popupMenu.addSeparator();//from ww w .j a v a 2 s. c o m JMenu navigateMenu = new JMenu("Navigate"); navigateMenu.add(createPopupMenuItem("View First Frame", null, KeyStroke.getKeyStroke(KeyEvent.VK_F, 2))); navigateMenu .add(createPopupMenuItem("View Previous Frame", null, KeyStroke.getKeyStroke(KeyEvent.VK_P, 2))); navigateMenu .add(createPopupMenuItem("Choose Frame To View", null, KeyStroke.getKeyStroke(KeyEvent.VK_C, 2))); navigateMenu.add(createPopupMenuItem("View Next Frame", null, KeyStroke.getKeyStroke(KeyEvent.VK_N, 2))); navigateMenu.add(createPopupMenuItem("View Last Frame", null, KeyStroke.getKeyStroke(KeyEvent.VK_L, 2))); popupMenu.add(navigateMenu); popupMenu.addSeparator(); popupMenu.add(createPopupMenuItem("Set Zoom Level", null, KeyStroke.getKeyStroke(KeyEvent.VK_Z, 2))); popupMenu.add(createPopupMenuItem("Set Min/Max", null, KeyStroke.getKeyStroke(KeyEvent.VK_R, 2))); popupMenu.add(createPopupMenuItem("Set Physical Extent", null, KeyStroke.getKeyStroke(KeyEvent.VK_E, 2))); popupMenu.addSeparator(); popupMenu.add(createPopupMenuItem("Recenter on Viewport", null, KeyStroke.getKeyStroke(KeyEvent.VK_C, 0))); popupMenu.addSeparator(); popupMenu.add(createPopupMenuItem("Set Colormap", null, KeyStroke.getKeyStroke(KeyEvent.VK_M, 2))); popupMenu.addSeparator(); JMenu overlayMenu = new JMenu("Overlays"); overlayMenu.add(createPopupMenuItem("Add Text Overlay", null, KeyStroke.getKeyStroke(KeyEvent.VK_T, 2))); overlayMenu.add(createPopupMenuItem("Add Shape Overlay", null, KeyStroke.getKeyStroke(KeyEvent.VK_O, 2))); overlayMenu.add(createPopupMenuItem("Add Annulus Overlay", null, KeyStroke.getKeyStroke(KeyEvent.VK_U, 2))); overlayMenu.add(createPopupMenuItem("Add Arrow Overlay", null, KeyStroke.getKeyStroke(KeyEvent.VK_A, 2))); popupMenu.add(overlayMenu); popupMenu.addSeparator(); JMenu pngMenu = new JMenu("To PNG"); pngMenu.add(createPopupMenuItem("Export Original Image", null, KeyStroke.getKeyStroke(KeyEvent.VK_S, 10))); pngMenu.add(createPopupMenuItem("Export Viewport Image", null, KeyStroke.getKeyStroke(KeyEvent.VK_S, 2))); pngMenu.addSeparator(); pngMenu.add(createPopupMenuItem("Export Viewport Series", null, KeyStroke.getKeyStroke(KeyEvent.VK_S, 8))); JMenu pdfMenu = new JMenu("To PDF"); pdfMenu.add(createPopupMenuItem("Export Original Image", null, KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.SHIFT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK))); pdfMenu.add(createPopupMenuItem("Export Viewport Image", null, KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.ALT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK))); JMenu exportMenu = new JMenu("Export"); exportMenu.add(pngMenu); exportMenu.add(pdfMenu); popupMenu.add(exportMenu); popupMenu.addSeparator(); JMenu losslessMenu = new JMenu("Lossless Modifications"); losslessMenu.add(createPopupMenuItem("Flip Horizontally", null, KeyStroke.getKeyStroke(KeyEvent.VK_H, 10))); losslessMenu.add(createPopupMenuItem("Flip Vertically", null, KeyStroke.getKeyStroke(KeyEvent.VK_V, 10))); losslessMenu.addSeparator(); losslessMenu.add(createPopupMenuItem("Rotate +90", null, KeyStroke.getKeyStroke(KeyEvent.VK_R, 10))); losslessMenu.add(createPopupMenuItem("Rotate -90", null, KeyStroke.getKeyStroke(KeyEvent.VK_L, 10))); popupMenu.add(losslessMenu); }
From source file:com.adobe.aem.demomachine.gui.AemDemo.java
@SuppressWarnings({ "rawtypes", "unchecked" }) private void initialize() { // Initialize properties setDefaultProperties(AemDemoUtils//from w w w.j a v a 2 s . c om .loadProperties(buildFile.getParentFile().getAbsolutePath() + File.separator + "build.properties")); setPersonalProperties(AemDemoUtils.loadProperties(buildFile.getParentFile().getAbsolutePath() + File.separator + "conf" + File.separator + "build-personal.properties")); // Constructing the main frame frameMain = new JFrame(); frameMain.setBounds(100, 100, 700, 530); frameMain.getContentPane().setLayout(null); // Main menu bar for the Frame JMenuBar menuBar = new JMenuBar(); JMenu mnAbout = new JMenu("AEM Demo Machine"); mnAbout.setMnemonic(KeyEvent.VK_A); menuBar.add(mnAbout); JMenuItem mntmUpdates = new JMenuItem("Check for Updates"); mntmUpdates.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmUpdates.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "demo_update"); } }); mnAbout.add(mntmUpdates); JMenuItem mntmDoc = new JMenuItem("Help and Documentation"); mntmDoc.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_H, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmDoc.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties, AemDemoConstants.OPTIONS_DOCUMENTATION)); } }); mnAbout.add(mntmDoc); JMenuItem mntmScripts = new JMenuItem("Demo Scripts (VPN)"); mntmScripts.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties, AemDemoConstants.OPTIONS_SCRIPTS)); } }); mnAbout.add(mntmScripts); JMenuItem mntmDiagnostics = new JMenuItem("Diagnostics"); mntmDiagnostics.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Map<String, String> env = System.getenv(); System.out.println("====== System Environment Variables ======"); for (String envName : env.keySet()) { System.out.format("%s=%s%n", envName, env.get(envName)); } System.out.println("====== JVM Properties ======"); RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean(); List<String> jvmArgs = runtimeMXBean.getInputArguments(); for (String arg : jvmArgs) { System.out.println(arg); } System.out.println("====== Runtime Properties ======"); Properties props = System.getProperties(); props.list(System.out); } }); mnAbout.add(mntmDiagnostics); JMenuItem mntmQuit = new JMenuItem("Quit"); mntmQuit.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_Q, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmQuit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(-1); } }); mnAbout.add(mntmQuit); JMenu mnNew = new JMenu("New"); menuBar.add(mnNew); // New Demo Machine JMenuItem mntmNewDemo = new JMenuItem("Demo Environment"); mntmNewDemo.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmNewDemo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (AemDemo.this.getBuildInProgress()) { JOptionPane.showMessageDialog(null, "A Demo Environment is currently being built. Please wait until it is finished."); } else { final AemDemoNew dialogNew = new AemDemoNew(AemDemo.this); dialogNew.setModal(true); dialogNew.setVisible(true); dialogNew.getDemoBuildName().requestFocus(); ; } } }); mnNew.add(mntmNewDemo); JMenuItem mntmNewOptions = new JMenuItem("Demo Properties"); mntmNewOptions.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_P, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmNewOptions.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final AemDemoOptions dialogOptions = new AemDemoOptions(AemDemo.this); dialogOptions.setModal(true); dialogOptions.setVisible(true); } }); mnNew.add(mntmNewOptions); JMenu mnUpdate = new JMenu("Add-ons"); menuBar.add(mnUpdate); // Sites Add-on JMenu mnSites = new JMenu("Sites"); mnUpdate.add(mnSites); JMenuItem mntmSitesDownloadAddOn = new JMenuItem("Download Demo Add-on"); mntmSitesDownloadAddOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_sites"); } }); mnSites.add(mntmSitesDownloadAddOn); JMenuItem mntmSitesDownloadFP = new JMenuItem("Download Packages (PackageShare)"); mntmSitesDownloadFP.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_sites_packages"); } }); mnSites.add(mntmSitesDownloadFP); // Assets Add-on JMenu mnAssets = new JMenu("Assets"); mnUpdate.add(mnAssets); JMenuItem mntmAssetsDownloadAddOn = new JMenuItem("Download Demo Add-on"); mntmAssetsDownloadAddOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_assets"); } }); mnAssets.add(mntmAssetsDownloadAddOn); JMenuItem mntmAssetsDownloadFP = new JMenuItem("Download Packages (PackageShare)"); mntmAssetsDownloadFP.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_assets_packages"); } }); mnAssets.add(mntmAssetsDownloadFP); // Communities Add-on JMenu mnCommunities = new JMenu("Communities/Livefyre"); mnUpdate.add(mnCommunities); JMenuItem mntmAemCommunitiesFeaturePacks = new JMenuItem("Download Packages (PackageShare)"); mntmAemCommunitiesFeaturePacks.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_communities_packages"); } }); mnCommunities.add(mntmAemCommunitiesFeaturePacks); // Forms Add-on JMenu mnForms = new JMenu("Forms"); mnUpdate.add(mnForms); JMenuItem mntmAemFormsAddon = new JMenuItem("Download Demo Add-on"); mntmAemFormsAddon.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_forms"); } }); mnForms.add(mntmAemFormsAddon); JMenuItem mntmAemFormsFP = new JMenuItem("Download Packages (PackageShare)"); mntmAemFormsFP.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_forms_packages"); } }); mnForms.add(mntmAemFormsFP); // Mobile Add-on JMenu mnApps = new JMenu("Mobile"); mnUpdate.add(mnApps); JMenuItem mntmAemAppsAddon = new JMenuItem("Download Demo Add-on"); mntmAemAppsAddon.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_apps"); } }); mnApps.add(mntmAemAppsAddon); JMenuItem mntmAemApps = new JMenuItem("Download Packages (PackageShare)"); mntmAemApps.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_apps_packages"); } }); mnApps.add(mntmAemApps); // Commerce Add-on JMenu mnCommerce = new JMenu("Commerce"); mnUpdate.add(mnCommerce); JMenu mnCommerceDownload = new JMenu("Download Packages"); mnCommerce.add(mnCommerceDownload); // Commerce EP JMenuItem mnCommerceDownloadEP = new JMenuItem("ElasticPath (PackageShare)"); mnCommerceDownloadEP.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_commerce_ep"); } }); mnCommerceDownload.add(mnCommerceDownloadEP); // Commerce WebSphere JMenuItem mnCommerceDownloadWAS = new JMenuItem("WebSphere (PackageShare)"); mnCommerceDownloadWAS.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_commerce_websphere"); } }); mnCommerceDownload.add(mnCommerceDownloadWAS); // WeRetail Add-on JMenu mnWeRetail = new JMenu("We-Retail"); mnUpdate.add(mnWeRetail); JMenuItem mnWeRetailAddon = new JMenuItem("Download Demo Add-on"); mnWeRetailAddon.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_weretail"); } }); mnWeRetail.add(mnWeRetailAddon); // Download all section mnUpdate.addSeparator(); JMenuItem mntmAemDownloadAll = new JMenuItem("Download All Add-ons"); mntmAemDownloadAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_all"); } }); mnUpdate.add(mntmAemDownloadAll); JMenu mnInfrastructure = new JMenu("Infrastructure"); menuBar.add(mnInfrastructure); JMenu mnMongo = new JMenu("MongoDB"); JMenuItem mntmInfraMongoDB = new JMenuItem("Download"); mntmInfraMongoDB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_mongo"); } }); mnMongo.add(mntmInfraMongoDB); JMenuItem mntmInfraMongoDBInstall = new JMenuItem("Install"); mntmInfraMongoDBInstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "install_mongo"); } }); mnMongo.add(mntmInfraMongoDBInstall); mnMongo.addSeparator(); JMenuItem mntmInfraMongoDBStart = new JMenuItem("Start"); mntmInfraMongoDBStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "mongo_start"); } }); mnMongo.add(mntmInfraMongoDBStart); JMenuItem mntmInfraMongoDBStop = new JMenuItem("Stop"); mntmInfraMongoDBStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "mongo_stop"); } }); mnMongo.add(mntmInfraMongoDBStop); mnInfrastructure.add(mnMongo); // SOLR options JMenu mnSOLR = new JMenu("SOLR"); JMenuItem mntmInfraSOLR = new JMenuItem("Download"); mntmInfraSOLR.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_solr"); } }); mnSOLR.add(mntmInfraSOLR); JMenuItem mntmInfraSOLRInstall = new JMenuItem("Install"); mntmInfraSOLRInstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "install_solr"); } }); mnSOLR.add(mntmInfraSOLRInstall); mnSOLR.addSeparator(); JMenuItem mntmInfraSOLRStart = new JMenuItem("Start"); mntmInfraSOLRStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "solr_start"); } }); mnSOLR.add(mntmInfraSOLRStart); JMenuItem mntmInfraSOLRStop = new JMenuItem("Stop"); mntmInfraSOLRStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "solr_stop"); } }); mnSOLR.add(mntmInfraSOLRStop); mnInfrastructure.add(mnSOLR); // MySQL options JMenu mnMySQL = new JMenu("MySQL"); JMenuItem mntmInfraMysql = new JMenuItem("Download"); mntmInfraMysql.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_mysql"); } }); mnMySQL.add(mntmInfraMysql); JMenuItem mntmInfraMysqlInstall = new JMenuItem("Install"); mntmInfraMysqlInstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "install_mysql"); } }); mnMySQL.add(mntmInfraMysqlInstall); mnMySQL.addSeparator(); JMenuItem mntmInfraMysqlStart = new JMenuItem("Start"); mntmInfraMysqlStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "mysql_start"); } }); mnMySQL.add(mntmInfraMysqlStart); JMenuItem mntmInfraMysqlStop = new JMenuItem("Stop"); mntmInfraMysqlStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "mysql_stop"); } }); mnMySQL.add(mntmInfraMysqlStop); mnInfrastructure.add(mnMySQL); // James options JMenu mnJames = new JMenu("James SMTP/POP"); JMenuItem mntmInfraJames = new JMenuItem("Download"); mntmInfraJames.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_james"); } }); mnJames.add(mntmInfraJames); JMenuItem mntmInfraJamesInstall = new JMenuItem("Install"); mntmInfraJamesInstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "install_james"); } }); mnJames.add(mntmInfraJamesInstall); mnJames.addSeparator(); JMenuItem mntmInfraJamesStart = new JMenuItem("Start"); mntmInfraJamesStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "james_start"); } }); mnJames.add(mntmInfraJamesStart); JMenuItem mntmInfraJamesStop = new JMenuItem("Stop"); mntmInfraJamesStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "james_stop"); } }); mnJames.add(mntmInfraJamesStop); mnInfrastructure.add(mnJames); // FFMPEPG options JMenu mnFFMPEG = new JMenu("FFMPEG"); JMenuItem mntmInfraFFMPEG = new JMenuItem("Download"); mntmInfraFFMPEG.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_ffmpeg"); } }); mnFFMPEG.add(mntmInfraFFMPEG); JMenuItem mntmInfraFFMPEGInstall = new JMenuItem("Install"); mntmInfraFFMPEGInstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "install_ffmpeg"); } }); mnFFMPEG.add(mntmInfraFFMPEGInstall); mnInfrastructure.add(mnFFMPEG); mnInfrastructure.addSeparator(); // InDesignServer options JMenu mnInDesignServer = new JMenu("InDesign Server"); JMenuItem mntmInfraInDesignServerDownload = new JMenuItem("Download"); mntmInfraInDesignServerDownload.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_indesignserver"); } }); mnInDesignServer.add(mntmInfraInDesignServerDownload); mnInDesignServer.addSeparator(); JMenuItem mntmInfraInDesignServerStart = new JMenuItem("Start"); mntmInfraInDesignServerStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "start_indesignserver"); } }); mnInDesignServer.add(mntmInfraInDesignServerStart); JMenuItem mntmInfraInDesignServerStop = new JMenuItem("Stop"); mntmInfraInDesignServerStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "stop_indesignserver"); } }); mnInDesignServer.add(mntmInfraInDesignServerStop); mnInfrastructure.add(mnInDesignServer); mnInfrastructure.addSeparator(); JMenuItem mntmInfraInstall = new JMenuItem("All in One Setup"); mntmInfraInstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "infrastructure"); } }); mnInfrastructure.add(mntmInfraInstall); JMenu mnOther = new JMenu("Other"); menuBar.add(mnOther); JMenu mntmAemDownload = new JMenu("AEM & License files (VPN)"); JMenuItem mntmAemLoad = new JMenuItem("Download Latest AEM Load"); mntmAemLoad.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_L, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmAemLoad.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_load"); } }); mntmAemDownload.add(mntmAemLoad); JMenuItem mntmAemSnapshot = new JMenuItem("Download Latest AEM Snapshot"); mntmAemSnapshot.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_T, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmAemSnapshot.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_snapshot"); } }); mntmAemDownload.add(mntmAemSnapshot); JMenuItem mntmAemDownloadAEM62 = new JMenuItem("Download AEM 6.2"); mntmAemDownloadAEM62.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_aem62"); } }); mntmAemDownload.add(mntmAemDownloadAEM62); JMenuItem mntmAemDownloadAEM61 = new JMenuItem("Download AEM 6.1"); mntmAemDownloadAEM61.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_aem61"); } }); mntmAemDownload.add(mntmAemDownloadAEM61); JMenuItem mntmAemDownloadAEM60 = new JMenuItem("Download AEM 6.0"); mntmAemDownloadAEM60.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_aem60"); } }); mntmAemDownload.add(mntmAemDownloadAEM60); JMenuItem mntmAemDownloadCQ561 = new JMenuItem("Download CQ 5.6.1"); mntmAemDownloadCQ561.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_cq561"); } }); mntmAemDownload.add(mntmAemDownloadCQ561); JMenuItem mntmAemDownloadCQ56 = new JMenuItem("Download CQ 5.6"); mntmAemDownloadCQ56.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_cq56"); } }); mntmAemDownload.add(mntmAemDownloadCQ56); JMenuItem mntmAemDownloadOthers = new JMenuItem("Other Releases & License files"); mntmAemDownloadOthers.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties, AemDemoConstants.OPTIONS_DOWNLOAD)); } }); mntmAemDownload.add(mntmAemDownloadOthers); mnOther.add(mntmAemDownload); JMenuItem mntmAemHotfix = new JMenuItem("Download Latest Hotfixes (PackageShare)"); mntmAemHotfix.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmAemHotfix.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_hotfixes_packages"); } }); mnOther.add(mntmAemHotfix); JMenuItem mntmAemAcs = new JMenuItem("Download Latest ACS Commons and Tools"); mntmAemAcs.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmAemAcs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_acs"); } }); mnOther.add(mntmAemAcs); // Adding the menu bar frameMain.setJMenuBar(menuBar); // Adding other form elements JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(24, 163, 650, 230); frameMain.getContentPane().add(scrollPane); final JTextArea textArea = new JTextArea(""); textArea.setEditable(false); scrollPane.setViewportView(textArea); // List of demo machines available JScrollPane scrollDemoList = new JScrollPane(); scrollDemoList.setBounds(24, 34, 208, 100); frameMain.getContentPane().add(scrollDemoList); listModelDemoMachines = AemDemoUtils.listDemoMachines(buildFile.getParentFile().getAbsolutePath()); listDemoMachines = new JList(listModelDemoMachines); listDemoMachines.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listDemoMachines.setSelectedIndex(AemDemoUtils.getSelectedIndex(listDemoMachines, this.getDefaultProperties(), this.getPersonalProperties(), AemDemoConstants.OPTIONS_BUILD_DEFAULT)); scrollDemoList.setViewportView(listDemoMachines); // Capturing the output stream of ANT commands AemDemoOutputStream out = new AemDemoOutputStream(textArea); System.setOut(new PrintStream(out)); JButton btnStart = new JButton("Start"); btnStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "start"); } }); btnStart.setBounds(250, 29, 117, 29); frameMain.getContentPane().add(btnStart); // Set Start as the default button JRootPane rootPane = SwingUtilities.getRootPane(btnStart); rootPane.setDefaultButton(btnStart); JButton btnInfo = new JButton("Details"); btnInfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "details"); } }); btnInfo.setBounds(250, 59, 117, 29); frameMain.getContentPane().add(btnInfo); // Rebuild action JButton btnRebuild = new JButton("Rebuild"); btnRebuild.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (AemDemo.this.getBuildInProgress()) { JOptionPane.showMessageDialog(null, "A Demo Environment is currently being built. Please wait until it is finished."); } else { final AemDemoRebuild dialogRebuild = new AemDemoRebuild(AemDemo.this); dialogRebuild.setModal(true); dialogRebuild.setVisible(true); dialogRebuild.getDemoBuildName().requestFocus(); ; } } }); btnRebuild.setBounds(250, 89, 117, 29); frameMain.getContentPane().add(btnRebuild); // Stop action JButton btnStop = new JButton("Stop"); btnStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int dialogResult = JOptionPane.showConfirmDialog(null, "Are you sure you really want to stop the running instances?", "Warning", JOptionPane.YES_NO_OPTION); if (dialogResult == JOptionPane.NO_OPTION) { return; } AemDemoUtils.antTarget(AemDemo.this, "stop"); } }); btnStop.setBounds(500, 29, 117, 29); frameMain.getContentPane().add(btnStop); JButton btnExit = new JButton("Exit"); btnExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(-1); } }); btnExit.setBounds(550, 408, 117, 29); frameMain.getContentPane().add(btnExit); JButton btnClear = new JButton("Clear"); btnClear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textArea.setText(""); } }); btnClear.setBounds(40, 408, 117, 29); frameMain.getContentPane().add(btnClear); JButton btnBackup = new JButton("Backup"); btnBackup.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "backup"); } }); btnBackup.setBounds(500, 59, 117, 29); frameMain.getContentPane().add(btnBackup); JButton btnRestore = new JButton("Restore"); btnRestore.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "restore"); } }); btnRestore.setBounds(500, 89, 117, 29); frameMain.getContentPane().add(btnRestore); JButton btnDelete = new JButton("Delete"); btnDelete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int dialogResult = JOptionPane.showConfirmDialog(null, "Are you sure you really want to permanently delete the selected demo configuration?", "Warning", JOptionPane.YES_NO_OPTION); if (dialogResult == JOptionPane.NO_OPTION) { return; } AemDemoUtils.antTarget(AemDemo.this, "uninstall"); } }); btnDelete.setBounds(500, 119, 117, 29); frameMain.getContentPane().add(btnDelete); JLabel lblSelectYourDemo = new JLabel("Select your Demo Environment"); lblSelectYourDemo.setBounds(24, 10, 219, 16); frameMain.getContentPane().add(lblSelectYourDemo); JLabel lblCommandOutput = new JLabel("Command Output"); lblCommandOutput.setBounds(24, 143, 160, 16); frameMain.getContentPane().add(lblCommandOutput); // Initializing and launching the ticker String tickerOn = AemDemoUtils.getPropertyValue(buildFile, "demo.ticker"); if (tickerOn == null || (tickerOn != null && tickerOn.equals("true"))) { AemDemoMarquee mp = new AemDemoMarquee(AemDemoConstants.Credits, 60); mp.setBounds(140, 440, 650, 30); frameMain.getContentPane().add(mp); mp.start(); } // Launching the download tracker task AemDemoDownload aemDownload = new AemDemoDownload(AemDemo.this); ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); executor.scheduleAtFixedRate(aemDownload, 0, 5, TimeUnit.SECONDS); // Loading up the README.md file String line = null; try { FileReader fileReader = new FileReader( buildFile.getParentFile().getAbsolutePath() + File.separator + "README.md"); BufferedReader bufferedReader = new BufferedReader(fileReader); while ((line = bufferedReader.readLine()) != null) { if (line.indexOf("AEM Demo Machine!") > 0) { line = line + " (version: " + aemDemoMachineVersion + ")"; } if (!line.startsWith("Double")) System.out.println(line); } bufferedReader.close(); } catch (Exception ex) { logger.error(ex.getMessage()); } }
From source file:com.github.benchdoos.weblocopener.updater.gui.UpdateDialog.java
private void createGUI() { setContentPane(contentPane);/*from ww w. j a v a2s.c o m*/ getRootPane().setDefaultButton(buttonOK); if (IS_WINDOWS_XP) { //for windows xp&server 2003 setIconImage(Toolkit.getDefaultToolkit() .getImage(UpdateDialog.class.getResource("/images/updaterIcon64_white.png"))); } else { setIconImage(Toolkit.getDefaultToolkit() .getImage(UpdateDialog.class.getResource("/images/updaterIcon64.png"))); } createDefaultActionListeners(); // call onCancel() when cross is clicked setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { onCancel(); } }); // call onCancel() on ESCAPE contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); updateInfoButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onUpdateInfoButton(); } }); updateInfoButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); manualDownloadButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openSetupUrl(); } private void openSetupUrl() { log.debug("Calling to download setup manually"); URL url = null; if (updater != null) { if (updater.getAppVersion() != null) { try { log.debug("Trying to open [" + updater.getAppVersion().getDownloadUrl() + "]"); url = new URL(updater.getAppVersion().getDownloadUrl()); UrlValidator urlValidator = new UrlValidator(); UserUtils.openWebUrl(url); } catch (MalformedURLException e1) { openWebsite(url); } } else UserUtils.openWebUrl(ApplicationConstants.UPDATE_WEB_URL); } else UserUtils.openWebUrl(ApplicationConstants.UPDATE_WEB_URL); } private void openWebsite(URL url) { log.warn("Could not open setup url: [" + url + "]\n" + "Opening " + ApplicationConstants.UPDATE_WEB_URL); UserUtils.openWebUrl(ApplicationConstants.UPDATE_WEB_URL); } }); pack(); setLocation(FrameUtils.getFrameOnCenterLocationPoint(this)); setSize(new Dimension(400, 170)); setResizable(false); }
From source file:net.sf.jabref.gui.FindUnlinkedFilesDialog.java
/** * Close dialog when pressing escape/*ww w. jav a2 s . c o m*/ */ @Override protected JRootPane createRootPane() { ActionListener actionListener = actionEvent -> setVisible(false); JRootPane rPane = new JRootPane(); KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); rPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); return rPane; }
From source file:org.pmedv.core.dialogs.AbstractNiceDialog.java
protected JRootPane createRootPane() { ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { result = OPTION_CANCEL;// w w w. j a v a 2 s . com setVisible(false); } }; JRootPane rootPane = new JRootPane(); KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); return rootPane; }