List of usage examples for java.awt.event InputEvent SHIFT_MASK
int SHIFT_MASK
To view the source code for java.awt.event InputEvent SHIFT_MASK.
Click Source Link
From source file:org.jfree.chart.demo.selection.SelectionDemo6Pie.java
public final JPanel createDemoPanel() { this.dataset = createDataset(); //extend dataset and add selection change listener for the demo DatasetSelectionExtension<PieCursor<String>> datasetExtension = new PieDatasetSelectionExtension<String>( this.dataset); datasetExtension.addChangeListener(this); //standard setup JFreeChart chart = createChart(this.dataset, datasetExtension); ChartPanel panel = new ChartPanel(chart); panel.setMouseWheelEnabled(true);/*from w ww .j a v a 2 s.c om*/ //add a selection handler with shift modifier for clicking RegionSelectionHandler selectionHandler = new FreeRegionSelectionHandler(); AbstractMouseHandler clickHandler = new MouseClickSelectionHandler(InputEvent.SHIFT_MASK); panel.addMouseHandler(selectionHandler); panel.addMouseHandler(clickHandler); panel.removeMouseHandler(panel.getZoomHandler()); // add a selection manager DatasetExtensionManager dExManager = new DatasetExtensionManager(); dExManager.registerDatasetExtension(datasetExtension); panel.setSelectionManager(new EntitySelectionManager(panel, new Dataset[] { dataset }, dExManager)); return panel; }
From source file:com.mirth.connect.client.ui.Mirth.java
/** * Create the alternate key bindings for the menu shortcut key mask. This is called if the menu * shortcut key mask is not the CTRL key (i.e. COMMAND on OSX) *//*from ww w. j a va 2s . co m*/ private static void createAlternateKeyBindings() { int acceleratorKey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); // Add the common KeyBindings for macs KeyBinding[] defaultBindings = { new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_C, acceleratorKey), DefaultEditorKit.copyAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_V, acceleratorKey), DefaultEditorKit.pasteAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_X, acceleratorKey), DefaultEditorKit.cutAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_A, acceleratorKey), DefaultEditorKit.selectAllAction), // deleteNextWordAction and deletePrevWordAction were not available in Java 1.5 new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, acceleratorKey), DefaultEditorKit.deleteNextWordAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, acceleratorKey), DefaultEditorKit.deletePrevWordAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, acceleratorKey), DefaultEditorKit.nextWordAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, acceleratorKey), DefaultEditorKit.nextWordAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, acceleratorKey), DefaultEditorKit.previousWordAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, acceleratorKey), DefaultEditorKit.previousWordAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, acceleratorKey | InputEvent.SHIFT_MASK), DefaultEditorKit.selectionNextWordAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, acceleratorKey | InputEvent.SHIFT_MASK), DefaultEditorKit.selectionNextWordAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, acceleratorKey | InputEvent.SHIFT_MASK), DefaultEditorKit.selectionPreviousWordAction), new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, acceleratorKey | InputEvent.SHIFT_MASK), DefaultEditorKit.selectionPreviousWordAction) }; keyMapBindings(new javax.swing.JTextField(), defaultBindings); keyMapBindings(new javax.swing.JPasswordField(), defaultBindings); keyMapBindings(new javax.swing.JTextPane(), defaultBindings); keyMapBindings(new javax.swing.JTextArea(), defaultBindings); keyMapBindings(new com.mirth.connect.client.ui.components.MirthTextField(), defaultBindings); keyMapBindings(new com.mirth.connect.client.ui.components.MirthPasswordField(), defaultBindings); keyMapBindings(new com.mirth.connect.client.ui.components.MirthTextPane(), defaultBindings); keyMapBindings(new com.mirth.connect.client.ui.components.MirthTextArea(), defaultBindings); }
From source file:graph.eventhandlers.MyEditingGraphMousePlugin.java
/** * If the mouse is pressed in an empty area, create a new vertex there. If * the mouse is pressed on an existing vertex, prepare to create an edge * from that vertex to another//from w w w . j a v a2s .co m */ public void mousePressed(MouseEvent e) { pw = graphInstance.getPathway(); if (checkModifiers(e)) { final VisualizationViewer<BiologicalNodeAbstract, BiologicalEdgeAbstract> vv = (VisualizationViewer<BiologicalNodeAbstract, BiologicalEdgeAbstract>) e .getSource(); // final Point2D p = vv.inverseViewTransform(e.getPoint()); // System.out.println("Points: "+e.getPoint().getX()+", "+e.getPoint().getY()); final Point2D p = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(e.getPoint()); // System.out.println(e.getPoint()+ " "+p); // System.out.println("Points: "+p.getX()+", "+p.getY()); // final Point2D p = e.getPoint(); GraphElementAccessor<BiologicalNodeAbstract, BiologicalEdgeAbstract> pickSupport = vv.getPickSupport(); // System.out.println("Click: "+p); // System.out.println("regul: "+e.getPoint()); Iterator<BiologicalNodeAbstract> it = pw.getGraph().getAllVertices().iterator(); // while(it.hasNext()){ // System.out.println(pw.getGraph().getVertexLocation(it.next())); // } // System.out.println(pw.getGraph().getAllEdges().size()); // System.out.println(pickSupport.g); BiologicalNodeAbstract vertex = null; vertex = (BiologicalNodeAbstract) pickSupport.getVertex(vv.getGraphLayout(), e.getPoint().getX(), e.getPoint().getY()); // System.out.println(vertex); if (vertex != null) { // get ready to make an edge // System.out.println(vertex); startVertex = vertex; super.down = e.getPoint(); transformEdgeShape(down, down); vv.addPostRenderPaintable(edgePaintable); if ((e.getModifiers() & InputEvent.SHIFT_MASK) != 0) { edgeIsDirected = true; transformArrowShape(down, e.getPoint()); vv.addPostRenderPaintable(arrowPaintable); } } else { // make a new vertex Graph<BiologicalNodeAbstract, BiologicalEdgeAbstract> graph = vv.getGraphLayout().getGraph(); // BiologicalNodeAbstract newVertex = new BiologicalNodeAbstract( // "label", "name"); // vertexLocations.put(newVertex, p); Layout<BiologicalNodeAbstract, BiologicalEdgeAbstract> layout = vv.getGraphLayout(); // System.out.println("size V: "+layout.getGraph().getVertices().size()); // System.out.println("size E: "+layout.getGraph().getEdges().size()); // graph.addVertex(newVertex); /* * Object key = (((AggregateLayout) * layout).getDelegate()).getBaseKey(); Object datum = new * Coordinates(vv.inverseTransform( e.getPoint()).getX(), * vv.inverseTransform( e.getPoint()).getY()); * newVertex.setUserDatum(key, datum, new CopyAction.Clone()); */ for (Iterator<BiologicalNodeAbstract> iterator = graph.getVertices().iterator(); iterator .hasNext();) { layout.lock(iterator.next(), true); } if (con.isPetriView()) { // System.out.println("is petri"); PetriNetVertexDialog dialog = new PetriNetVertexDialog(con.getPetriNetEditingMode()); BiologicalNodeAbstract bna = dialog.getAnswer(p); // System.out.println(); if (bna != null) { // BiologicalNodeAbstract ba = new // BiologicalNodeAbstract( // answers[0], "", newVertex); // ba.setBiologicalElement(answers[1]); // ba.setCompartment(answers[2]); // graphInstance.getPathway().addElement(ba); // graph.addVertex(newVertex); // vv.getModel().restart(); //System.out.println("update"); if (pw instanceof BiologicalNodeAbstract) { bna.setParentNode((BiologicalNodeAbstract) pw); } MainWindowSingleton.getInstance().updateElementTree(); MainWindowSingleton.getInstance().updatePathwayTree(); //MainWindowSingelton.getInstance().updateAllGuiElements(); //MainWindowSingelton.getInstance().updateOptionPanel(); // MainWindowSingelton.getInstance() // .updateTheoryProperties(); // Pathway pw = graphInstance.getPathway(); } } else { // System.out.println("not petri"); VertexDialog dialog = new VertexDialog(); String[] answers = dialog.getAnswer(); if (answers != null) { // BiologicalNodeAbstract ba = new // BiologicalNodeAbstract( // answers[0], ""); String name = answers[0]; String label = answers[0]; String element = answers[1]; String compartment = answers[2]; // newVertex.setBiologicalElement(answers[1]); // newVertex.setCompartment(answers[2]); // graphInstance.getPathway().addElement(newVertex); // graph.addVertex(newVertex); BiologicalNodeAbstract newVertex = pw.addVertex(name, label, element, compartment, p); if (pw instanceof BiologicalNodeAbstract) { newVertex.setParentNode((BiologicalNodeAbstract) pw); } //pw.addVertex(newVertex, p); if (graph.getVertices().size() > 1) { // System.exit(0); } // pw.getGraph().setVertexLocation(newVertex, p); // layout.setLocation(newVertex, p); // vv.getModel().restart(); MainWindowSingleton.getInstance().updateElementTree(); // MainWindowSingelton.getInstance() // .updateTheoryProperties(); for (Iterator<BiologicalNodeAbstract> iterator = graph.getVertices().iterator(); iterator .hasNext();) { layout.lock(iterator.next(), false); } } } if (pw instanceof BiologicalNodeAbstract) { } } vv.repaint(); } }
From source file:com.hp.alm.ali.idea.ui.editor.field.HTMLAreaField.java
public static void installNavigationShortCuts(final JTextPane desc) { Keymap keymap = KeymapManager.getInstance().getActiveKeymap(); new AnAction() { public void actionPerformed(AnActionEvent e) { // default action moves to the end of the document - override desc.getActionMap().get(DefaultEditorKit.endLineAction).actionPerformed(null); }/*from w ww . jav a 2 s.c o m*/ }.registerCustomShortcutSet( new CustomShortcutSet(keymap.getShortcuts(IdeActions.ACTION_EDITOR_MOVE_LINE_END)), desc); new AnAction() { public void actionPerformed(AnActionEvent e) { // default action moves to the beginning of the document - override desc.getActionMap().get(DefaultEditorKit.beginLineAction).actionPerformed(null); } }.registerCustomShortcutSet( new CustomShortcutSet(keymap.getShortcuts(IdeActions.ACTION_EDITOR_MOVE_LINE_START)), desc); new AnAction() { public void actionPerformed(AnActionEvent e) { // default action moves to the end of the document - override desc.getActionMap().get(DefaultEditorKit.selectionEndLineAction).actionPerformed(null); } }.registerCustomShortcutSet( new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_END, InputEvent.SHIFT_MASK)), desc); new AnAction() { public void actionPerformed(AnActionEvent e) { // default action moves to the beginning of the document - override desc.getActionMap().get(DefaultEditorKit.selectionBeginLineAction).actionPerformed(null); } }.registerCustomShortcutSet( new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, InputEvent.SHIFT_MASK)), desc); new AnAction() { public void actionPerformed(AnActionEvent e) { // when editing html insert hard break new InsertHardBreakAction().actionPerformed(null); } }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)), desc); }
From source file:com.mirth.connect.client.ui.components.rsta.RSTAPreferences.java
private void setDefaultKeyStrokeMap() { keyStrokeMap = new HashMap<String, KeyStroke>(); boolean isOSX = RTextArea.isOSX(); int defaultModifier = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); int ctrl = InputEvent.CTRL_MASK; int alt = InputEvent.ALT_MASK; int shift = InputEvent.SHIFT_MASK; int defaultShift = defaultModifier | shift; int moveByWordMod = isOSX ? alt : defaultModifier; int moveByWordModShift = moveByWordMod | shift; putKeyStroke(ActionInfo.UNDO, KeyEvent.VK_Z, defaultModifier); if (isOSX) {//w w w. j a v a2 s . c o m putKeyStroke(ActionInfo.REDO, KeyEvent.VK_Z, defaultShift); } else { putKeyStroke(ActionInfo.REDO, KeyEvent.VK_Y, defaultModifier); } putKeyStroke(ActionInfo.CUT, KeyEvent.VK_X, defaultModifier); putKeyStroke(ActionInfo.COPY, KeyEvent.VK_C, defaultModifier); putKeyStroke(ActionInfo.PASTE, KeyEvent.VK_V, defaultModifier); putKeyStroke(ActionInfo.DELETE, KeyEvent.VK_DELETE, 0); putKeyStroke(ActionInfo.DELETE_REST_OF_LINE, KeyEvent.VK_DELETE, defaultModifier); putKeyStroke(ActionInfo.DELETE_LINE, KeyEvent.VK_D, defaultModifier); putKeyStroke(ActionInfo.JOIN_LINE, KeyEvent.VK_J, defaultModifier); putKeyStroke(ActionInfo.SELECT_ALL, KeyEvent.VK_A, defaultModifier); putKeyStroke(ActionInfo.FIND_REPLACE, KeyEvent.VK_F, defaultModifier); putKeyStroke(ActionInfo.FIND_NEXT, KeyEvent.VK_G, defaultModifier); putKeyStroke(ActionInfo.CLEAR_MARKED_OCCURRENCES, KeyEvent.VK_ESCAPE, 0); putKeyStroke(ActionInfo.FOLD_COLLAPSE, KeyEvent.VK_SUBTRACT, defaultModifier); putKeyStroke(ActionInfo.FOLD_EXPAND, KeyEvent.VK_ADD, defaultModifier); putKeyStroke(ActionInfo.FOLD_COLLAPSE_ALL, KeyEvent.VK_DIVIDE, defaultModifier); putKeyStroke(ActionInfo.FOLD_COLLAPSE_ALL_COMMENTS, KeyEvent.VK_DIVIDE, defaultShift); putKeyStroke(ActionInfo.FOLD_EXPAND_ALL, KeyEvent.VK_MULTIPLY, defaultModifier); putKeyStroke(ActionInfo.GO_TO_MATCHING_BRACKET, KeyEvent.VK_OPEN_BRACKET, defaultModifier); putKeyStroke(ActionInfo.TOGGLE_COMMENT, KeyEvent.VK_SLASH, defaultModifier); putKeyStroke(ActionInfo.AUTO_COMPLETE, KeyEvent.VK_SPACE, ctrl); if (isOSX) { putKeyStroke(ActionInfo.DOCUMENT_START, KeyEvent.VK_HOME, 0); putKeyStroke(ActionInfo.DOCUMENT_END, KeyEvent.VK_END, 0); putKeyStroke(ActionInfo.DOCUMENT_SELECT_START, KeyEvent.VK_HOME, shift); putKeyStroke(ActionInfo.DOCUMENT_SELECT_END, KeyEvent.VK_END, shift); putKeyStroke(ActionInfo.LINE_START, KeyEvent.VK_LEFT, defaultModifier); putKeyStroke(ActionInfo.LINE_END, KeyEvent.VK_RIGHT, defaultModifier); putKeyStroke(ActionInfo.LINE_SELECT_START, KeyEvent.VK_LEFT, defaultShift); putKeyStroke(ActionInfo.LINE_SELECT_END, KeyEvent.VK_RIGHT, defaultShift); } else { putKeyStroke(ActionInfo.DOCUMENT_START, KeyEvent.VK_HOME, defaultModifier); putKeyStroke(ActionInfo.DOCUMENT_END, KeyEvent.VK_END, defaultModifier); putKeyStroke(ActionInfo.DOCUMENT_SELECT_START, KeyEvent.VK_HOME, defaultShift); putKeyStroke(ActionInfo.DOCUMENT_SELECT_END, KeyEvent.VK_END, defaultShift); putKeyStroke(ActionInfo.LINE_START, KeyEvent.VK_HOME, 0); putKeyStroke(ActionInfo.LINE_END, KeyEvent.VK_END, 0); putKeyStroke(ActionInfo.LINE_SELECT_START, KeyEvent.VK_HOME, shift); putKeyStroke(ActionInfo.LINE_SELECT_END, KeyEvent.VK_END, shift); } putKeyStroke(ActionInfo.MOVE_LEFT, KeyEvent.VK_LEFT, 0); putKeyStroke(ActionInfo.MOVE_LEFT_SELECT, KeyEvent.VK_LEFT, shift); putKeyStroke(ActionInfo.MOVE_LEFT_WORD, KeyEvent.VK_LEFT, moveByWordMod); putKeyStroke(ActionInfo.MOVE_LEFT_WORD_SELECT, KeyEvent.VK_LEFT, moveByWordModShift); putKeyStroke(ActionInfo.MOVE_RIGHT, KeyEvent.VK_RIGHT, 0); putKeyStroke(ActionInfo.MOVE_RIGHT_SELECT, KeyEvent.VK_RIGHT, shift); putKeyStroke(ActionInfo.MOVE_RIGHT_WORD, KeyEvent.VK_RIGHT, moveByWordMod); putKeyStroke(ActionInfo.MOVE_RIGHT_WORD_SELECT, KeyEvent.VK_RIGHT, moveByWordModShift); putKeyStroke(ActionInfo.MOVE_UP, KeyEvent.VK_UP, 0); putKeyStroke(ActionInfo.MOVE_UP_SELECT, KeyEvent.VK_UP, shift); putKeyStroke(ActionInfo.MOVE_UP_SCROLL, KeyEvent.VK_UP, defaultModifier); putKeyStroke(ActionInfo.MOVE_UP_LINE, KeyEvent.VK_UP, alt); putKeyStroke(ActionInfo.MOVE_DOWN, KeyEvent.VK_DOWN, 0); putKeyStroke(ActionInfo.MOVE_DOWN_SELECT, KeyEvent.VK_DOWN, shift); putKeyStroke(ActionInfo.MOVE_DOWN_SCROLL, KeyEvent.VK_DOWN, defaultModifier); putKeyStroke(ActionInfo.MOVE_DOWN_LINE, KeyEvent.VK_DOWN, alt); putKeyStroke(ActionInfo.PAGE_UP, KeyEvent.VK_PAGE_UP, 0); putKeyStroke(ActionInfo.PAGE_UP_SELECT, KeyEvent.VK_PAGE_UP, shift); putKeyStroke(ActionInfo.PAGE_LEFT_SELECT, KeyEvent.VK_PAGE_UP, defaultShift); putKeyStroke(ActionInfo.PAGE_DOWN, KeyEvent.VK_PAGE_DOWN, 0); putKeyStroke(ActionInfo.PAGE_DOWN_SELECT, KeyEvent.VK_PAGE_DOWN, shift); putKeyStroke(ActionInfo.PAGE_RIGHT_SELECT, KeyEvent.VK_PAGE_DOWN, defaultShift); putKeyStroke(ActionInfo.INSERT_LF_BREAK, KeyEvent.VK_ENTER, 0); putKeyStroke(ActionInfo.INSERT_CR_BREAK, KeyEvent.VK_ENTER, shift); putKeyStroke(ActionInfo.MACRO_BEGIN, KeyEvent.VK_B, defaultShift); putKeyStroke(ActionInfo.MACRO_END, KeyEvent.VK_N, defaultShift); putKeyStroke(ActionInfo.MACRO_PLAYBACK, KeyEvent.VK_M, defaultShift); }
From source file:net.sf.firemox.DeckBuilder.java
/** * Creates new form DeckBuilder/*from w w w. j a v a 2 s .c om*/ */ 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:edu.umn.ecology.populus.plot.BasicPlotCanvas.java
private void jbInit() throws Exception { /*// w w w .j a va2 s. c om if( info != null ) { mainCaption = new HTMLLabel( info.getMainCaption() ); xCaption = new HTMLLabel( info.getXCaptions()[0] ); yCaption = new HTMLLabel( info.getYCaptions()[0] ); yCaption.setDirection( HTMLLabel.DOWN_TO_UP ); } else { mainCaption = new HTMLLabel( "Main Caption" ); xCaption = new HTMLLabel( "X Caption" ); yCaption = new HTMLLabel( "Y Caption" ); } */ //* if (info != null) { mainCaption = new HTMLMultiLabel(info.getMainCaption()); xCaption = new HTMLMultiLabel(info.getXCaptions()); yCaption = new HTMLMultiLabel(info.getYCaptions()); yCaption.setDirection(HTMLLabel.DOWN_TO_UP); } else { mainCaption = new HTMLMultiLabel("Main Caption"); xCaption = new HTMLMultiLabel("X Caption"); yCaption = new HTMLMultiLabel("Y Caption"); yCaption.setDirection(HTMLLabel.DOWN_TO_UP); } setLayout(borderLayout1); if (PopPreferencesStorage.isUseJFreeClass()) { NumberAxis yAxis = new NumberAxis(null); NumberAxis xAxis = new NumberAxis(null); xAxis.setAutoRangeIncludesZero(false); AbstractXYItemRenderer renderer = null; if (info.isBarChart) { renderer = new XYBarRenderer(); } else { renderer = new XYLineAndShapeRenderer(true, false); } XYPlot plot = new XYPlot(null, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart jfchart = new JFreeChart(null, null, plot, false); jfchartpanel = new ChartPanel(jfchart); plot.setBackgroundPaint(ColorScheme.bG); info.styleJFree(jfchart); add(jfchartpanel, MacroLayout.CENTER); } else { chart = new JCChart(JCChart.PLOT); info.styleJC(chart); chart.setBackground(ColorScheme.bG); chart.setAllowUserChanges(true); chart.setTrigger(0, new EventTrigger(InputEvent.SHIFT_MASK, EventTrigger.CUSTOMIZE)); chart.setTrigger(1, new EventTrigger(InputEvent.BUTTON1_MASK, EventTrigger.ZOOM)); chart.setResetKey('r'); chart.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent e) { if ((e.getModifiers() & InputEvent.META_MASK) != 0) { info.setAxis(chart); chart.reset(); } } }); chart.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); chart.setWarningDialog(false); add(chart, MacroLayout.CENTER); } setBGColor(); add(mainCaption, MacroLayout.NORTH); add(xCaption, MacroLayout.SOUTH); add(yCaption, MacroLayout.WEST); }
From source file:ListProperties.java
public void mouseClicked(MouseEvent mouseEvent) { TableColumnModel columnModel = table.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(mouseEvent.getX()); int column = table.convertColumnIndexToModel(viewColumn); if (mouseEvent.getClickCount() == 1 && column != -1) { System.out.println("Sorting ..."); int shiftPressed = (mouseEvent.getModifiers() & InputEvent.SHIFT_MASK); boolean ascending = (shiftPressed == 0); sorter.sortByColumn(column, ascending); }/*from ww w. j a v a 2s .c om*/ }
From source file:net.sf.jabref.gui.AutoCompleteListener.java
@Override public void keyTyped(KeyEvent e) { LOGGER.debug("key typed event caught " + e.getKeyCode()); char ch = e.getKeyChar(); if (ch == '\n') { // this case is handled at keyPressed(e) return;// w w w . j a v a 2 s . c o m } if ((e.getModifiers() | InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK) { // plain key or SHIFT + key is pressed, no handling of CTRL+key, META+key, ... if (Character.isLetter(ch) || Character.isDigit(ch) || (Character.isWhitespace(ch) && completer.isSingleUnitField())) { JTextComponent comp = (JTextComponent) e.getSource(); if (toSetIn == null) { LOGGER.debug("toSetIn is null"); } else { LOGGER.debug("toSetIn: >" + toSetIn + '<'); } // The case-insensitive system is a bit tricky here // If keyword is "TODO" and user types "tO", then this is treated as "continue" as the "O" matches the "O" // If keyword is "TODO" and user types "To", then this is treated as "discont" as the "o" does NOT match the "O". if ((toSetIn != null) && (toSetIn.length() > 1) && (ch == toSetIn.charAt(1))) { // User continues on the word that was suggested. LOGGER.debug("cont"); toSetIn = toSetIn.substring(1); if (!toSetIn.isEmpty()) { int cp = comp.getCaretPosition(); //comp.setCaretPosition(cp+1-toSetIn.); //System.out.println(cp-toSetIn.length()+" - "+cp); comp.select((cp + 1) - toSetIn.length(), cp); lastBeginning = lastBeginning + ch; e.consume(); lastCaretPosition = comp.getCaretPosition(); //System.out.println("Added char: '"+toSetIn+"'"); //System.out.println("LastBeginning: '"+lastBeginning+"'"); lastCompletions = findCompletions(lastBeginning, comp); lastShownCompletion = 0; for (int i = 0; i < lastCompletions.length; i++) { String lastCompletion = lastCompletions[i]; //System.out.println("Completion["+i+"] = "+lastCompletion); if (lastCompletion.endsWith(toSetIn)) { lastShownCompletion = i; break; } } //System.out.println("Index now: "+lastShownCompletion); if (toSetIn.length() < 2) { // User typed the last character of the autocompleted word // We have to replace the automcompletion word by the typed word. // This helps if the user presses "space" after the completion // "space" indicates that the user does NOT want the autocompletion, // but the typed word String text = comp.getText(); comp.setText(text.substring(0, lastCaretPosition - lastBeginning.length()) + lastBeginning + text.substring(lastCaretPosition)); // there is no selected text, therefore we are not updating the selection toSetIn = null; } return; } } if ((toSetIn != null) && ((toSetIn.length() <= 1) || (ch != toSetIn.charAt(1)))) { // User discontinues the word that was suggested. lastBeginning = lastBeginning + ch; LOGGER.debug("discont toSetIn: >" + toSetIn + "'<' lastBeginning: >" + lastBeginning + '<'); String[] completed = findCompletions(lastBeginning, comp); if ((completed != null) && (completed.length > 0)) { lastShownCompletion = 0; lastCompletions = completed; String sno = completed[0]; // toSetIn = string used for autocompletion last time // this string has to be removed // lastCaretPosition is the position of the caret after toSetIn. int lastLen = toSetIn.length() - 1; toSetIn = sno.substring(lastBeginning.length() - 1); String text = comp.getText(); //Util.pr(""+lastLen); //we do not use toSetIn as we want to obey the casing of "sno" comp.setText(text.substring(0, (lastCaretPosition - lastLen - lastBeginning.length()) + 1) + sno + text.substring(lastCaretPosition)); int startSelect = (lastCaretPosition + 1) - lastLen; int endSelect = (lastCaretPosition + toSetIn.length()) - lastLen; comp.select(startSelect, endSelect); lastCaretPosition = comp.getCaretPosition(); e.consume(); return; } else { setUnmodifiedTypedLetters(comp, true, false); e.consume(); toSetIn = null; return; } } LOGGER.debug("case else"); comp.replaceSelection(""); StringBuffer currentword = getCurrentWord(comp); if (currentword == null) { currentword = new StringBuffer(); } // only "real characters" end up here assert (!Character.isISOControl(ch)); currentword.append(ch); startCompletion(currentword, e); return; } else { if (Character.isWhitespace(ch)) { assert (!completer.isSingleUnitField()); LOGGER.debug("whitespace && !singleUnitField"); // start a new search if end-of-field is reached // replace displayed letters with typed letters setUnmodifiedTypedLetters((JTextComponent) e.getSource(), false, true); resetAutoCompletion(); return; } LOGGER.debug("No letter/digit/whitespace or CHAR_UNDEFINED"); // replace displayed letters with typed letters setUnmodifiedTypedLetters((JTextComponent) e.getSource(), false, !Character.isISOControl(ch)); resetAutoCompletion(); return; } } resetAutoCompletion(); }