List of usage examples for java.awt.event KeyEvent consume
public void consume()
From source file:ch.zhaw.iamp.rct.ui.GrammarWindow.java
private void insertTabAsSpace(KeyEvent event, JTextComponent component) { try {/* w w w . ja v a2 s . c o m*/ int caretPostion = component.getCaretPosition() - 1; component.getDocument().remove(caretPostion, 1); component.getDocument().insertString(caretPostion, " ", null); event.consume(); } catch (BadLocationException ex) { System.out.println("Could not insert a tab: " + ex.getMessage()); } }
From source file:net.sf.taverna.t2.workbench.ui.impl.UserRegistrationForm.java
private void initComponents() { JPanel mainPanel = new JPanel(new GridBagLayout()); // Base font for all components on the form Font baseFont = new JLabel("base font").getFont().deriveFont(11f); // Title panel JPanel titlePanel = new JPanel(new FlowLayout(LEFT)); titlePanel.setBackground(WHITE);//from ww w.j av a 2s. c o m // titlePanel.setBorder(new EmptyBorder(10, 10, 10, 10)); JLabel titleLabel = new JLabel(WELCOME); titleLabel.setFont(baseFont.deriveFont(BOLD, 13.5f)); // titleLabel.setBorder(new EmptyBorder(10, 10, 0, 10)); JLabel titleIcon = new JLabel(tavernaCogs32x32Icon); // titleIcon.setBorder(new EmptyBorder(10, 10, 10, 10)); DialogTextArea titleMessage = new DialogTextArea(PLEASE_FILL_IN_THIS_REGISTRATION_FORM); titleMessage.setMargin(new Insets(0, 20, 0, 10)); titleMessage.setFont(baseFont); titleMessage.setEditable(false); titleMessage.setFocusable(false); // titlePanel.setBorder( new EmptyBorder(10, 10, 0, 10)); JPanel messagePanel = new JPanel(new BorderLayout()); messagePanel.add(titleLabel, NORTH); messagePanel.add(titleMessage, CENTER); messagePanel.setBackground(WHITE); titlePanel.add(titleIcon); titlePanel.add(messagePanel); addDivider(titlePanel, BOTTOM, true); GridBagConstraints gbc = new GridBagConstraints(); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 0; gbc.fill = HORIZONTAL; gbc.anchor = WEST; gbc.gridwidth = 2; // gbc.insets = new Insets(5, 10, 0, 0); mainPanel.add(titlePanel, gbc); // Registration messages gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 1; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 2; // gbc.insets = new Insets(5, 0, 0, 10); DialogTextArea registrationMessage1 = new DialogTextArea(WHY_REGISTER); registrationMessage1.setMargin(new Insets(0, 10, 0, 0)); registrationMessage1.setFont(baseFont); registrationMessage1.setEditable(false); registrationMessage1.setFocusable(false); registrationMessage1.setBackground(getBackground()); DialogTextArea registrationMessage2 = new DialogTextArea(WE_DO); registrationMessage2.setMargin(new Insets(0, 10, 0, 10)); registrationMessage2.setFont(baseFont); registrationMessage2.setEditable(false); registrationMessage2.setFocusable(false); registrationMessage2.setBackground(getBackground()); JPanel registrationMessagePanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); registrationMessagePanel.add(registrationMessage1); registrationMessagePanel.add(registrationMessage2); addDivider(registrationMessagePanel, BOTTOM, true); mainPanel.add(registrationMessagePanel, gbc); // Mandatory label // JLabel mandatoryLabel = new JLabel("* Mandatory fields"); // mandatoryLabel.setFont(baseFont); // gbc.weightx = 0.0; // gbc.weighty = 0.0; // gbc.gridx = 0; // gbc.gridy = 3; // gbc.fill = NONE; // gbc.anchor = GridBagConstraints.EAST; // gbc.gridwidth = 2; // gbc.insets = new Insets(0, 10, 0, 20); // mainPanel.add(mandatoryLabel, gbc); // First name JLabel firstNameLabel = new JLabel(FIRST_NAME); firstNameLabel.setFont(baseFont); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 4; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(0, 10, 0, 10); mainPanel.add(firstNameLabel, gbc); firstNameTextField = new JTextField(); firstNameTextField.setFont(baseFont); if (previousRegistrationData != null) firstNameTextField.setText(previousRegistrationData.getFirstName()); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 4; gbc.fill = HORIZONTAL; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(firstNameTextField, gbc); // Last name JLabel lastNameLabel = new JLabel(LAST_NAME); lastNameLabel.setFont(baseFont); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 5; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(0, 10, 0, 10); mainPanel.add(lastNameLabel, gbc); lastNameTextField = new JTextField(); lastNameTextField.setFont(baseFont); if (previousRegistrationData != null) lastNameTextField.setText(previousRegistrationData.getLastName()); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 5; gbc.fill = HORIZONTAL; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(lastNameTextField, gbc); // Email address JLabel emailLabel = new JLabel(EMAIL_ADDRESS); emailLabel.setFont(baseFont); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 6; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(emailLabel, gbc); emailTextField = new JTextField(); emailTextField.setFont(baseFont); if (previousRegistrationData != null) emailTextField.setText(previousRegistrationData.getEmailAddress()); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 6; gbc.fill = HORIZONTAL; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(emailTextField, gbc); // Keep me informed keepMeInformedCheckBox = new JCheckBox(KEEP_ME_INFORMED); keepMeInformedCheckBox.setFont(baseFont); if (previousRegistrationData != null) keepMeInformedCheckBox.setSelected(previousRegistrationData.getKeepMeInformed()); keepMeInformedCheckBox.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == VK_ENTER) { evt.consume(); keepMeInformedCheckBox.setSelected(!keepMeInformedCheckBox.isSelected()); } } }); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 7; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 2; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(keepMeInformedCheckBox, gbc); // Institution name JLabel institutionLabel = new JLabel(INSTITUTION_COMPANY_NAME); institutionLabel.setFont(baseFont); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 8; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(institutionLabel, gbc); institutionOrCompanyTextField = new JTextField(); institutionOrCompanyTextField.setFont(baseFont); if (previousRegistrationData != null) institutionOrCompanyTextField.setText(previousRegistrationData.getInstitutionOrCompanyName()); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 8; gbc.fill = HORIZONTAL; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(institutionOrCompanyTextField, gbc); // Industry type JLabel industryLabel = new JLabel(" Industry type:"); industryLabel.setFont(baseFont); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 9; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(industryLabel, gbc); industryTypeTextField = new JComboBox<>(industryTypes); industryTypeTextField.setFont(baseFont); if (previousRegistrationData != null) industryTypeTextField.setSelectedItem(previousRegistrationData.getIndustry()); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 9; gbc.fill = HORIZONTAL; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(industryTypeTextField, gbc); // Field of investigation JTextArea fieldLabel = new JTextArea(FIELD_OF_INVESTIGATION); fieldLabel.setFont(baseFont); fieldLabel.setEditable(false); fieldLabel.setFocusable(false); fieldLabel.setBackground(getBackground()); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 10; gbc.fill = NONE; gbc.anchor = LINE_START; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(fieldLabel, gbc); fieldTextField = new JTextField(); fieldTextField.setFont(baseFont); if (previousRegistrationData != null) fieldTextField.setText(previousRegistrationData.getField()); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 10; gbc.fill = HORIZONTAL; gbc.anchor = FIRST_LINE_START; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(fieldTextField, gbc); // Purpose of using Taverna JTextArea purposeLabel = new JTextArea(WHY_YOU_INTEND_TO_USE_TAVERNA); purposeLabel.setFont(baseFont); purposeLabel.setEditable(false); purposeLabel.setFocusable(false); purposeLabel.setBackground(getBackground()); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 11; gbc.fill = NONE; gbc.anchor = LINE_START; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(purposeLabel, gbc); purposeTextArea = new JTextArea(4, 30); purposeTextArea.setFont(baseFont); purposeTextArea.setLineWrap(true); purposeTextArea.setAutoscrolls(true); if (previousRegistrationData != null) purposeTextArea.setText(previousRegistrationData.getPurposeOfUsingTaverna()); purposeTextArea.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == VK_TAB) { if (evt.getModifiers() > 0) purposeTextArea.transferFocusBackward(); else purposeTextArea.transferFocus(); evt.consume(); } } }); JScrollPane purposeScrollPane = new JScrollPane(purposeTextArea); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 11; gbc.fill = HORIZONTAL; gbc.anchor = FIRST_LINE_START; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(purposeScrollPane, gbc); // Terms and conditions termsAndConditionsCheckBox = new JCheckBox(I_AGREE_TO_THE_TERMS_AND_CONDITIONS); termsAndConditionsCheckBox.setFont(baseFont); termsAndConditionsCheckBox.setBorder(null); termsAndConditionsCheckBox.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == VK_ENTER) { evt.consume(); termsAndConditionsCheckBox.setSelected(!termsAndConditionsCheckBox.isSelected()); } } }); // gbc.weightx = 0.0; // gbc.weighty = 0.0; // gbc.gridx = 0; // gbc.gridy = 12; // gbc.fill = NONE; // gbc.anchor = WEST; // gbc.gridwidth = 2; // gbc.insets = new Insets(10, 10, 0, 0); // mainPanel.add(termsAndConditionsCheckBox, gbc); // Terms and conditions link JEditorPane termsAndConditionsURL = new JEditorPane(); termsAndConditionsURL.setEditable(false); termsAndConditionsURL.setBackground(getBackground()); termsAndConditionsURL.setFocusable(false); HTMLEditorKit kit = new HTMLEditorKit(); termsAndConditionsURL.setEditorKit(kit); StyleSheet styleSheet = kit.getStyleSheet(); // styleSheet.addRule("body {font-family:"+baseFont.getFamily()+"; font-size:"+baseFont.getSize()+";}"); // // base font looks bigger when rendered as HTML styleSheet.addRule("body {font-family:" + baseFont.getFamily() + "; font-size:9px;}"); Document doc = kit.createDefaultDocument(); termsAndConditionsURL.setDocument(doc); termsAndConditionsURL.setText("<html><body><a href=\"" + TERMS_AND_CONDITIONS_URL + "\">" + TERMS_AND_CONDITIONS_URL + "</a></body></html>"); termsAndConditionsURL.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent he) { if (he.getEventType() == ACTIVATED) followHyperlinkToTandCs(); } }); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 13; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 2; gbc.insets = new Insets(5, 10, 0, 10); JPanel termsAndConditionsPanel = new JPanel(new FlowLayout(LEFT)); termsAndConditionsPanel.add(termsAndConditionsCheckBox); termsAndConditionsPanel.add(termsAndConditionsURL); mainPanel.add(termsAndConditionsPanel, gbc); // Button panel JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); JButton registerButton = new JButton("Register"); registerButton.setFont(baseFont); registerButton.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == VK_ENTER) { evt.consume(); register(); } } }); registerButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { register(); } }); JButton doNotRegisterButton = new JButton("Do not ask me again"); doNotRegisterButton.setFont(baseFont); doNotRegisterButton.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == VK_ENTER) { evt.consume(); doNotRegister(); } } }); doNotRegisterButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doNotRegister(); } }); JButton remindMeLaterButton = new JButton("Remind me later"); // in 2 weeks remindMeLaterButton.setFont(baseFont); remindMeLaterButton.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == VK_ENTER) { evt.consume(); remindMeLater(); } } }); remindMeLaterButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { remindMeLater(); } }); buttonPanel.add(registerButton); buttonPanel.add(remindMeLaterButton); buttonPanel.add(doNotRegisterButton); addDivider(buttonPanel, TOP, true); gbc.gridx = 0; gbc.gridy = 14; gbc.fill = HORIZONTAL; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(5, 10, 0, 10); gbc.gridwidth = 2; mainPanel.add(buttonPanel, gbc); getContentPane().setLayout(new BorderLayout()); getContentPane().add(mainPanel, CENTER); pack(); setResizable(false); // Center the dialog on the screen (we do not have the parent) Dimension dimension = getToolkit().getScreenSize(); Rectangle abounds = getBounds(); setLocation((dimension.width - abounds.width) / 2, (dimension.height - abounds.height) / 2); setSize(getPreferredSize()); }
From source file:org.pmedv.blackboard.board.BoardDesignerPerspective.java
@Override protected void initializeComponents() { setLayout(new BorderLayout()); toolTabPane = new JTabbedPane(JTabbedPane.BOTTOM); horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); ctx = AppContext.getContext();/*from w w w.j a va2 s.co m*/ resources = ctx.getBean(ResourceService.class); advisor = ctx.getBean(ApplicationWindowAdvisor.class); final String position = (String) Preferences.values .get("org.pmedv.blackboard.BoardDesignerPerspective.layerPanelPlacement"); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { viewMap = new ViewMap(); rootWindow = DockingUtil.createRootWindow(viewMap, true); rootWindow.getWindowBar(Direction.DOWN).setEnabled(true); rootWindow.getWindowProperties().setMinimizeEnabled(true); DockingWindowsTheme theme = new SoftBlueIceDockingTheme(); rootWindow.getRootWindowProperties().addSuperObject(theme.getRootWindowProperties()); rootWindow.getWindowProperties().getTabProperties().getHighlightedButtonProperties() .getCloseButtonProperties().setVisible(false); rootWindow.getWindowProperties().getTabProperties().getNormalButtonProperties() .getCloseButtonProperties().setVisible(false); editorArea = new TabWindow(); editorArea.getWindowProperties().getTabProperties().getNormalButtonProperties() .getCloseButtonProperties().setVisible(false); editorArea.getWindowProperties().getTabProperties().getHighlightedButtonProperties() .getCloseButtonProperties().setVisible(false); editorArea.getWindowProperties().getTabProperties().getNormalButtonProperties() .getMinimizeButtonProperties().setVisible(true); editorArea.getWindowProperties().getTabProperties().getHighlightedButtonProperties() .getMinimizeButtonProperties().setVisible(true); DockingWindowAdapter dockingAdapter = new DockingWindowAdapter() { @Override public void windowClosing(DockingWindow window) throws OperationAbortedException { } }; editorArea.addListener(dockingAdapter); setDockingListener(dockingAdapter); rootWindow.setWindow(editorArea); if (position.equalsIgnoreCase("left")) { horizontalSplitPane.setRightComponent(rootWindow); } else { horizontalSplitPane.setLeftComponent(rootWindow); } advisor.setCurrentEditorArea(editorArea); } }); JXTaskPaneContainer taskpanecontainer = new JXTaskPaneContainer(); taskpanecontainer.setBackground(new Color(182, 191, 205)); JXTaskPane shapePane = new JXTaskPane(); shapePane.setTitle(resources.getResourceByKey("BoardDesignerPerspective.shapes.title")); shapePane.add(ctx.getBean(ShapePropertiesPanel.class)); taskpanecontainer.add(shapePane); ctx.getBean(ShapePropertiesPanel.class).getStartLineCombo().setSelectedItem(LineEdgeType.STRAIGHT); ctx.getBean(ShapePropertiesPanel.class).getEndLineCombo().setSelectedItem(LineEdgeType.STRAIGHT); ctx.getBean(ShapePropertiesPanel.class).getThicknessCombo().setSelectedItem(new BasicStroke(2.0f)); JXTaskPane layerPane = new JXTaskPane(); layerPane.setTitle(resources.getResourceByKey("BoardDesignerPerspective.layers")); layerPane.add(ctx.getBean(ShowLayersCommand.class).getLayerPanel()); taskpanecontainer.add(layerPane); JScrollPane scrollPane = new JScrollPane(taskpanecontainer); if (position.equalsIgnoreCase("left")) { horizontalSplitPane.setLeftComponent(toolTabPane); } else { horizontalSplitPane.setRightComponent(toolTabPane); } horizontalSplitPane.setOneTouchExpandable(true); horizontalSplitPane.setDividerSize(10); toolTabPane.addTab(resources.getResourceByKey("tooltab.forms"), resources.getIcon("icon.paint"), scrollPane); final SymbolListPanel symbolListPanel = ctx.getBean(SymbolListPanel.class); toolTabPane.addTab(resources.getResourceByKey("tooltab.symbols"), resources.getIcon("icon.symbols"), symbolListPanel); final ModelListPanel modelListPanel = ctx.getBean(ModelListPanel.class); toolTabPane.addTab(resources.getResourceByKey("tooltab.models"), resources.getIcon("icon.model"), modelListPanel); add(horizontalSplitPane, BorderLayout.CENTER); commandArea = new RSyntaxTextArea(); commandArea.setRows(1); commandArea.setColumns(100); JPanel commandPanel = new JPanel(new BorderLayout()); commandPanel.add(new JLabel("Command :"), BorderLayout.WEST); commandPanel.add(commandArea, BorderLayout.CENTER); commandArea.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2), BorderFactory.createLineBorder(Color.BLACK))); add(commandPanel, BorderLayout.NORTH); setupAutoComplete(); commandArea.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (commandArea.getText().startsWith("add ") && commandArea.getText().length() > 4 && commandArea.hasFocus()) { PartFactory pf = AppContext.getContext().getBean(PartFactory.class); String tokens[] = commandArea.getText().split(" "); StringBuffer partName = new StringBuffer(); for (int i = 1; i < tokens.length; i++) { partName.append(tokens[i] + " "); } String name = partName.toString().trim(); if (pf.getPartnames().contains(name)) { e.consume(); commandArea.setText(""); BoardUtil.addPart(name, EditorUtils.getCurrentActiveEditor()); } } else if (commandArea.getText().equals("new")) { e.consume(); commandArea.setText(""); AppContext.getContext().getBean(CreateBoardCommand.class).execute(null); } else if (commandArea.getText().equals("resistor")) { e.consume(); commandArea.setText(""); AppContext.getContext().getBean(AddResistorCommand.class).execute(null); } else if (commandArea.getText().equals("diode")) { e.consume(); commandArea.setText(""); AppContext.getContext().getBean(AddDiodeCommand.class).execute(null); } else if (commandArea.getText().equals("text")) { e.consume(); commandArea.setText(""); AppContext.getContext().getBean(AddTextCommand.class).execute(null); } else if (commandArea.getText().equals("open")) { e.consume(); commandArea.setText(""); new OpenBoardCommand().execute(null); } else if (commandArea.getText().equals("save")) { e.consume(); commandArea.setText(""); AppContext.getContext().getBean(SaveBoardCommand.class).execute(null); } else if (commandArea.getText().equals("color")) { e.consume(); commandArea.setText(""); AppContext.getContext().getBean(ChooseColorCommand.class).execute(null); } } } }); horizontalSplitPane.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equalsIgnoreCase("dividerLocation")) { configProvider.getConfig().setDividerLocation(horizontalSplitPane.getDividerLocation()); } } }); ctx.getBean(ShapePropertiesPanel.class).getObjectField() .setText(resources.getResourceByKey("ShapePropertiesPanel.items.none")); ctx.getBean(ShapePropertiesPanel.class).getRotationSpinner().setEnabled(false); ctx.getBean(ShapePropertiesPanel.class).getStartAngleSpinner().setEnabled(false); initListeners(); }
From source file:Filter3dTest.java
public void keyTyped(KeyEvent e) { // make sure the key isn't processed for anything else e.consume(); }
From source file:com.jcraft.weirdx.DDXWindowImp.java
public void processKeyEvent(KeyEvent e) { int id = e.getID(); if (id == KeyEvent.KEY_PRESSED) { keyPressed(e);/*from w w w .j a v a 2 s .c o m*/ } else if (id == KeyEvent.KEY_RELEASED) { keyReleased(e); } else if (id == KeyEvent.KEY_TYPED) { keyTyped(e); } e.consume(); // ?? }
From source file:tufts.vue.RichTextBox.java
public void keyReleased(KeyEvent e) { e.consume(); }
From source file:Filter3dTest.java
public void keyPressed(KeyEvent e) { GameAction gameAction = getKeyAction(e); if (gameAction != null) { gameAction.press();//from w w w. j ava 2s .c om } // make sure the key isn't processed for anything else e.consume(); }
From source file:Filter3dTest.java
public void keyReleased(KeyEvent e) { GameAction gameAction = getKeyAction(e); if (gameAction != null) { gameAction.release();//w ww . j a v a 2s . c om } // make sure the key isn't processed for anything else e.consume(); }
From source file:tufts.vue.RichTextBox.java
public void keyPressed(KeyEvent e) { if (DEBUG.KEYS) out(e.toString());/*from w w w . j a v a 2s . co m*/ //System.out.println("TextBox: " + e); //if (VueUtil.isAbortKey(e)) // check for ESCAPE for CTRL-Z or OPTION-Z if on mac if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { e.consume(); // System.out.println(mUnchangedText); //setText(mUnchangedText); revert = true; getParent().remove(this); // will trigger a save (via focusLost) return; // setSize(mUnchangedSize); // todo: won't be good enough if we ever resize the actual node as we type } else if (isFinishEditKeyPress(e)) { keyWasPressed = true; e.consume(); getParent().remove(this); // will trigger a save (via focusLost) VUE.getFormattingPanel().getTextPropsPane().getFontEditorPanel().updateFormatControlsTB(this); } else if (e.getKeyCode() == KeyEvent.VK_U && e.isMetaDown()) { e.consume(); String t = getText(); if (e.isShiftDown()) setText(t.toUpperCase()); // upper whole string else setText(Character.toTitleCase(t.charAt(0)) + t.substring(1)); // upper first char } else keyWasPressed = true; // Dimension d = preAddDimension; // d.height = this.getPreferredSize().height; // setSize(getPreferredSize()); // action keys will be ignored if we consume this here! // (e.g., "enter" does nothing) //e.consume(); }
From source file:net.sf.jabref.gui.autocompleter.AutoCompleteListener.java
/** * Start a new completion attempt (instead of treating a continuation of an existing word or an interrupt of the * current word)//w ww. j a v a 2s . c o m */ private void startCompletion(StringBuffer currentword, KeyEvent e) { JTextComponent comp = (JTextComponent) e.getSource(); List<String> completed = findCompletions(currentword.toString()); String prefix = completer.getPrefix(); String cWord = (prefix != null) && (!prefix.isEmpty()) ? currentword.toString().substring(prefix.length()) : currentword.toString(); LOGGER.debug("StartCompletion currentword: >" + currentword + "'<' prefix: >" + prefix + "'<' cword: >" + cWord + '<'); int no = 0; // We use the first word in the array of completions. if ((completed != null) && (!completed.isEmpty())) { lastShownCompletion = 0; lastCompletions = completed; String sno = completed.get(no); // these two lines obey the user's input //toSetIn = Character.toString(ch); //toSetIn = toSetIn.concat(sno.substring(cWord.length())); // BUT we obey the completion toSetIn = sno.substring(cWord.length() - 1); LOGGER.debug("toSetIn: >" + toSetIn + '<'); StringBuilder alltext = new StringBuilder(comp.getText()); int cp = comp.getCaretPosition(); alltext.insert(cp, toSetIn); comp.setText(alltext.toString()); comp.setCaretPosition(cp); comp.select(cp + 1, (cp + 1 + sno.length()) - cWord.length()); e.consume(); lastCaretPosition = comp.getCaretPosition(); char ch = e.getKeyChar(); LOGGER.debug("Appending >" + ch + '<'); if (cWord.length() <= 1) { lastBeginning = Character.toString(ch); } else { lastBeginning = cWord.substring(0, cWord.length() - 1).concat(Character.toString(ch)); } } }