Java 类java.awt.event.KeyAdapter 实例源码

项目:Cognizant-Intelligent-Test-Scripter    文件:StyledEditor.java   
public KeyListener updateProviderOnSave() {
    return new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent ke) {
            if (isSave(ke)) {
                onSave();
            }
        }
    };
}
项目:incubator-netbeans    文件:OQLControllerUI.java   
public Presenter(final QueryUI queryUI) {
    super();
    setText(Bundle.OQLControllerUI_ControllerName());
    setToolTipText(Bundle.OQLControllerUI_ControllerDescr());
    setIcon(OQL_ICON);

    addKeyListener(new KeyAdapter() {
        public void keyTyped(final KeyEvent e) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    queryUI.requestFocus();
                    queryUI.addToQuery(e.getKeyChar());
                }
            });
        }
    });
}
项目:pong    文件:DrawingPanel.java   
public DrawingPanel(){
    super();
    setPreferredSize(new Dimension(SCREEN_WIDTH, SCREEN_HEIGHT));
    Random ran = new Random();
    ball = new Ball(300, 350, 10, 3, -5, Color.BLUE);
    paddle = new Paddle((SCREEN_WIDTH/2) - (Paddle.PADDLE_WIDTH/2), SCREEN_HEIGHT - 20, 40);
    Thread t = new Thread(new Repainter());
    t.start();
    setFocusable(true);
    addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            super.keyPressed(e);
            int key = e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_RIGHT ? e.getKeyCode() : 0;
            if(key != 0){
                paddle.move(key);
            }
        }
    });
}
项目:dead-code-detector    文件:ParametersPanel.java   
private void init() {
    initTransferHandler();

    filesTable.addKeyListener(new KeyAdapter() {
        /** {@inheritDoc} */
        @Override
        public void keyPressed(KeyEvent event) {
            final int keyCode = event.getKeyCode();
            onKeyPressed(keyCode);
        }
    });

    setBorder(EMPTY_BORDER);
    setLayout(DcdUiHelper.createBorderLayout());
    setOpaque(false);

    add(getNorthPanel(), BorderLayout.NORTH);

    add(getCenterPanel(), BorderLayout.CENTER);
}
项目:Hotel-Properties-Management-System    文件:HotelPropertiesWindow.java   
private KeyListener listenToKeysListener() {
    final KeyAdapter adapter = new KeyAdapter() {
        @Override
        public void keyTyped(KeyEvent e) {
            String word = nameField.getText();
            if (word.length() < 18) {
                hotelNameTitle.setText(word);
                hotelNameTitle.repaint();
            } else {
                JOptionPane.showMessageDialog(modalFrame, "Hotel name maximum 18 charachter allowed!",
                        JOptionPane.MESSAGE_PROPERTY, JOptionPane.WARNING_MESSAGE);
            }
            super.keyTyped(e);
        }
    };
    return adapter;
}
项目:Hotel-Properties-Management-System    文件:AddUserWindow.java   
private KeyListener validatorListener() {
    final KeyAdapter adapter = new KeyAdapter() {
        @Override
        public void keyTyped(KeyEvent e) {
            final EmailValidator validator = new EmailValidator();
            if(validator.validate(emailField.getText())) {
                markerLbl.setVisible(false);
                infoLabel.setText("");
                isValid = true;
            }
            else {
                markerLbl.setVisible(true);
                infoLabel.setText("Invalid email format!");
            }
        }
    };
    return adapter;
}
项目:JavaGraph    文件:PrologDisplay.java   
/**
 * Constructs and returns the query field.
 * Also initialises {@link #queryEdit}.
 */
private JComboBox<String> getQueryField() {
    if (this.queryField == null) {
        this.queryField = new JComboBox<>(PREFS.get("queryHistory", "").split("\\n"));
        this.queryField.setFont(EDIT_FONT);
        this.queryField.setEditable(true);
        this.queryField.setEnabled(true);
        this.queryField.setPrototypeDisplayValue("groove+prolog");
        this.queryEdit = (JTextComponent) this.queryField.getEditor().getEditorComponent();
        this.queryEdit.addKeyListener(new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                    executeQuery();
                    giveFocusToNextResultButton();
                }
            }
        });
    }
    return this.queryField;
}
项目:gate-core    文件:TextualDocumentView.java   
protected void initListeners() {
  // textView.addComponentListener(new ComponentAdapter(){
  // public void componentResized(ComponentEvent e){
  // try{
  // scroller.getViewport().setViewPosition(
  // textView.modelToView(0).getLocation());
  // scroller.paintImmediately(textView.getBounds());
  // }catch(BadLocationException ble){
  // //ignore
  // }
  // }
  // });

  // stop control+H from deleting text and transfers the key to the
  // parent
  textView.addKeyListener(new KeyAdapter() {
    @Override
    public void keyPressed(KeyEvent e) {
      if(e.getKeyCode() == KeyEvent.VK_H && e.isControlDown()) {
        getGUI().dispatchEvent(e);
        e.consume();
      }
    }
  });
}
项目:Equella    文件:BusyGlassPane.java   
/**
 * GlassPane constructor comment.
 * 
 * @param Container a
 */
protected BusyGlassPane(Component activeComponent, boolean stopClosing)
{
    this.stopClosing = stopClosing;

    // add adapters that do nothing for keyboard and mouse actions
    addMouseListener(new MouseAdapter()
    {
        // We don't care about any events
    });

    addKeyListener(new KeyAdapter()
    {
        // We don't care about any events
    });

    setActiveComponent(activeComponent);
}
项目:ramus    文件:IconPreviewPanel.java   
private void init() {
    JScrollPane pane = new JScrollPane();
    list = new JList(dataModel);
    list.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_F5) {
                try {
                    data = null;
                    loadImages();
                } catch (IOException e1) {
                    e1.printStackTrace();
                    JOptionPane.showMessageDialog(null, e1
                            .getLocalizedMessage());
                }
                list.setModel(dataModel);
                list.updateUI();
            }
        }
    });
    list.setCellRenderer(new IconRenderer());
    pane.setViewportView(list);
    for (int i = 0; i < data.size(); i++) {
    }
    this.add(pane, BorderLayout.CENTER);
}
项目:AndroidSourceViewer    文件:GlobalSearchDialog.java   
public GlobalSearchDialog(SearchFinishResult result) {
    setContentPane(contentPane);
    setModal(true);
    setTitle("Android Source Search");
    setSize(800, 500);
    this.setLocationRelativeTo(null);
    listView.setModel(dataSet);
    listView.setFixedCellHeight(25);
    listView.addListSelectionListener(this);
    listView.addMouseListener(new ListDoubleClickEvent<String>(this));
    searchBar.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            startSearch();
        }
    });
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.searchFinishResult = result;
}
项目:set-game    文件:PlaySet.java   
@Override
public void run() {
    if (!streaming) {
        addMouseListener(panel);
    }
    JFrame window = ShowImages.showWindow(panel, PlaySet.class.getSimpleName(),true);
    window.addKeyListener(new KeyAdapter() {
        @Override
        public void keyTyped(KeyEvent e) {
            if (e.getKeyChar() == 'x' && previousSet != null) {
                System.out.println("'Not a Set!'");
                ImageSuppliers.WebcamSaverImageSupplier.save(image);
            }
        }
    });

    if (streaming) {
        while (true) {
            image = imageSupplier.get();
            newImage(image);
        }
    }
}
项目:jdk8u-jdk    文件:DisplayChangeVITest.java   
DisplayChangeVITest() {
    selectDisplayModes();
    addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                synchronized (lock) {
                    done = true;
                }
            }
        }
    });
    sprite = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
    sprite.getRaster().getDataBuffer();
    Graphics g = sprite.getGraphics();
    g.setColor(Color.yellow);
    g.fillRect(0, 0, sprite.getWidth(), sprite.getHeight());
}
项目:openjdk-jdk10    文件:DisplayChangeVITest.java   
DisplayChangeVITest() {
    selectDisplayModes();
    addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                synchronized (lock) {
                    done = true;
                }
            }
        }
    });
    sprite = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
    sprite.getRaster().getDataBuffer();
    Graphics g = sprite.getGraphics();
    g.setColor(Color.yellow);
    g.fillRect(0, 0, sprite.getWidth(), sprite.getHeight());
}
项目:openjdk-jdk10    文件:bug6578666.java   
private static void createGui() {
    final JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    tree = new JTree();
    frame.add(tree);

    tree.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            tree.updateUI();
        }
    });

    frame.setSize(200, 200);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}
项目:openjdk9    文件:DisplayChangeVITest.java   
DisplayChangeVITest() {
    selectDisplayModes();
    addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                synchronized (lock) {
                    done = true;
                }
            }
        }
    });
    sprite = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
    sprite.getRaster().getDataBuffer();
    Graphics g = sprite.getGraphics();
    g.setColor(Color.yellow);
    g.fillRect(0, 0, sprite.getWidth(), sprite.getHeight());
}
项目:openjdk9    文件:bug6578666.java   
private static void createGui() {
    final JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    tree = new JTree();
    frame.add(tree);

    tree.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            tree.updateUI();
        }
    });

    frame.setSize(200, 200);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}
项目:semtool    文件:RelationshipLoadingPlaySheet.java   
private void init() {
    JLabel lbl = new JLabel( "Relationship name:" );
    relationship.setText( defaultRelationship );

    JPanel pnl = new JPanel( new BorderLayout() );
    pnl.add( lbl, BorderLayout.WEST );
    pnl.add( relationship, BorderLayout.CENTER );

    add( pnl, BorderLayout.NORTH );

    relationship.addKeyListener( new KeyAdapter() {

        @Override
        public void keyReleased( KeyEvent e ) {
            LoadingSheetModel model = getLoadingModel();

            if ( model.isRealTimeChecking() ) {
                model.setRelationshipName( relationship.getText() );
                RelationshipLoadingPlaySheet.this.setErrorLabel();
            }

            lbl.setIcon( model.getModelErrorColumns().contains( -1 )
                    ? DbAction.getIcon( "error" ) : null );
        }
    } );
}
项目:wiimote-paintboard    文件:WiimoteCalibration.java   
public CalibrationFrame() {
            super("Calibration");
//          getRootPane().putClientProperty("Window.alpha", new Float(0.9));
            setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
            setBackground(Color.WHITE);
            ((JPanel)getContentPane()).setOpaque(true);
            setLayout(null);
            setUndecorated(true);
            setAlwaysOnTop(true);
            addKeyListener(new KeyAdapter() {
                @Override
                public void keyPressed(KeyEvent e) {
                    if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                        state = CalibrationState.PENDING;
                        if (screen.getFullScreenWindow() == calibrationFrame)
                            screen.setFullScreenWindow(null);
                        setVisible(false);
                        notifyListener(CalibrationEvent.ABORTED);
                    }
                }
            });
        }
项目:wiimote-paintboard    文件:CameraMonitor.java   
public CameraMonitor(WiimoteDataHandler dh) {
    super(Application.getInstance(WiimoteWhiteboard.class).getMainFrame(), Util.getResourceMap(CameraMonitor.class).getString("monitor.Action.text"));
    getRootPane().putClientProperty("Window.style", "small");
    setLayout(new MigLayout());

    dh.addWiimoteDataListener(this);

    canvas = new JPanel(null, true);
    canvas.setOpaque(true);
    canvas.setBorder(BorderFactory.createLineBorder(SystemColor.inactiveCaptionBorder));
    add(canvas, "w 50sp, h 50sp, grow, push");

    addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                setVisible(false);
            }
        }
    });

    pack();
    setLocationRelativeTo(null);

    new Timer(true).schedule(new UpdateTask(), 0, REPAINT_FREQ);
}
项目:intellij-ce-playground    文件:StructureViewComponent.java   
private void addTreeKeyListener() {
  getTree().addKeyListener(
      new KeyAdapter() {
      @Override
      public void keyPressed(KeyEvent e) {
        if (KeyEvent.VK_ENTER == e.getKeyCode()) {
          DataContext dataContext = DataManager.getInstance().getDataContext(getTree());
          OpenSourceUtil.openSourcesFrom(dataContext, false);
        }
        else if (KeyEvent.VK_ESCAPE == e.getKeyCode()) {
          if (e.isConsumed())
          {
            return;
          }
          PsiCopyPasteManager copyPasteManager = PsiCopyPasteManager.getInstance();
          boolean[] isCopied = new boolean[1];
          if (copyPasteManager.getElements(isCopied) != null && !isCopied[0]) {
            copyPasteManager.clear();
            e.consume();
          }
        }
      }
    });
}
项目:PhET    文件:TestDynamicJFreeChartNodeTree.java   
public TestDynamicJFreeChartNodeTree() {
    getPhetPCanvas().removeScreenChild( getDynamicJFreeChartNode() );
    root = new PhetPPath( new Rectangle( 0, 0, 10, 10 ), Color.blue );

    root.addChild( getDynamicJFreeChartNode() );

    getPhetPCanvas().addScreenChild( root );
    getPhetPCanvas().addKeyListener( new KeyAdapter() {
        public void keyPressed( KeyEvent e ) {
            if ( e.getKeyCode() == KeyEvent.VK_PAGE_UP ) {
                root.scale( 1.1 );
            }
            else if ( e.getKeyCode() == KeyEvent.VK_PAGE_DOWN ) {
                root.scale( 1.0 / 1.1 );
            }
        }
    } );
    constructed = true;

    text = new PText( "Page Up/Down to scale" );
    getPhetPCanvas().addScreenChild( text );
}
项目:PhET    文件:TestBufferedPNode.java   
public TestBufferedPNode() {
        frame = new JFrame();
        frame.setSize( 600, 600 );
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

        phetPCanvas = new PhetPCanvas();
        phetPCanvas.setPanEventHandler( new PPanEventHandler() );
        phetPCanvas.setZoomEventHandler( new PZoomEventHandler() );

        frame.setContentPane( phetPCanvas );
        final ExpensiveNode expensiveNode = new ExpensiveNode();
        final BufferedPNode bufferedPNode = new BufferedPNode( phetPCanvas, expensiveNode );
//        phetPCanvas.addWorldChild( expensiveNode );
        phetPCanvas.addWorldChild( bufferedPNode );

        phetPCanvas.addKeyListener( new KeyAdapter() {
            public void keyPressed( KeyEvent e ) {
                System.out.println( "TestBufferedPNode.keyPressed" );
                phetPCanvas.getCamera().scaleView( 1.1 );
                phetPCanvas.repaint();
            }
        } );
    }
项目:scelight    文件:XTextField.java   
/**
 * Creates a new {@link XTextField}.
 * 
 * @param text initial text of the text field
 * @param columns the number of columns to use to calculate the preferred width; if columns is set to zero, the preferred width will be whatever naturally
 *            results from the component implementation
 * @param clearByEsc tells if text field should be cleared when the ESC key is pressed
 */
public XTextField( final String text, final int columns, final boolean clearByEsc ) {
    super( text, columns );

    if ( clearByEsc )
        addKeyListener( new KeyAdapter() {
            @Override
            public void keyPressed( final KeyEvent event ) {
                if ( event.getKeyCode() == KeyEvent.VK_ESCAPE ) {
                    if ( !getText().isEmpty() ) {
                        setText( null );
                        // ESC is also used to hide (close) dialogs, so consume event if we did clear search term
                        event.consume();
                    }
                }
            }
        } );
}
项目:intellij-ce-playground    文件:EditSourceOnEnterKeyHandler.java   
public static void install(final JTree tree){
  tree.addKeyListener(
    new KeyAdapter() {
      public void keyPressed(KeyEvent e) {
        if (KeyEvent.VK_ENTER == e.getKeyCode()) {
          DataContext dataContext = DataManager.getInstance().getDataContext(tree);

          Project project = CommonDataKeys.PROJECT.getData(dataContext);
          if (project == null) return;

          OpenSourceUtil.openSourcesFrom(dataContext, false);
        }
      }
    }
  );
}
项目:intellij-ce-playground    文件:ArrayTableCellEditor.java   
public MyTableEditor(Project project,
                     XDebuggerEditorsProvider debuggerEditorsProvider,
                     @Nullable @NonNls String historyId,
                     @Nullable XSourcePosition sourcePosition, @NotNull XExpression text, @NotNull final KeyAdapter actionAdapter) {
  super(project, debuggerEditorsProvider, EvaluationMode.CODE_FRAGMENT, historyId, sourcePosition);
  myExpression = XExpressionImpl.changeMode(text, getMode());
  myEditorTextField = new EditorTextField(createDocument(myExpression), project, debuggerEditorsProvider.getFileType()) {
    @Override
    protected EditorEx createEditor() {
      final EditorEx editor = super.createEditor();
      editor.setVerticalScrollbarVisible(false);
      editor.setOneLineMode(true);
      editor.getContentComponent().addKeyListener(actionAdapter);
      return editor;
    }

    @Override
    protected boolean isOneLineMode() {
      return true;
    }
  };
  myEditorTextField.setFontInheritedFromLAF(false);
}
项目:bisis-v4    文件:SveskePanel.java   
private void createSveskeTable() {    
  TableSorter tsorter = new TableSorter(sveskeTableModel);
  sveskeTable = new JTable(tsorter);    
  TableColumn columnInvBroj = sveskeTable.getColumnModel().getColumn(0);    
  tsorter.setTableHeader(sveskeTable.getTableHeader());  
  sveskeScrollPane = new JScrollPane(sveskeTable);    
  ListSelectionModel lSelModel = sveskeTable.getSelectionModel();
  lSelModel.addListSelectionListener(new ListSelectionListener(){
    public void valueChanged(ListSelectionEvent e) {
      handleListSelectionChanged();       
    }     
  });
  sveskeTable.addKeyListener(new KeyAdapter(){
    public void keyPressed(KeyEvent ke) {
      handleKeys(sveskeTable,ke);      
    }      
  });    
}
项目:geoxygene    文件:EditPostgisConnection.java   
JParamField(ParamType key, ConnectionParam param) {
    super(20);
    this.paramType = key;
    this.param = param;
    switch(paramType) {
        case DBTYPE : setValue(param.getDbtype());break;
        case DATABASE : setValue(param.getDatabase());break;
        case HOST : setValue(param.getHost());break;
        case PORT : setValue(param.getPort());break;
        case SCHEMA : setValue(param.getSchema());break;
        case USER : setValue(param.getUser());break;
        case PASSWD : setValue(param.getPasswd());break;
        default:;
    }

    addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            refresh();
        }
    });
    // setToolTipText(param.description.toString());
}
项目:lookaside_java-1.8.0-openjdk    文件:DisplayChangeVITest.java   
DisplayChangeVITest() {
    selectDisplayModes();
    addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                synchronized (lock) {
                    done = true;
                }
            }
        }
    });
    sprite = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
    sprite.getRaster().getDataBuffer();
    Graphics g = sprite.getGraphics();
    g.setColor(Color.yellow);
    g.fillRect(0, 0, sprite.getWidth(), sprite.getHeight());
}
项目:iSeleda    文件:OutputSettingsPanel.java   
private void addAnimationLengthSelector(LayerUI<JTextField> tfLayerUI, GridBagHelper gbHelper) {
    gbHelper.addLabelWithControl("Number of Seconds:",
            new JLayer<>(nrSecondsTF, tfLayerUI));

    KeyListener keyListener = new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent keyEvent) {
            updateCalculations();
        }
    };
    nrSecondsTF.addKeyListener(keyListener);

    gbHelper.addLabelWithControl("Frames per Second:",
            new JLayer<>(fpsTF, tfLayerUI));
    fpsTF.addKeyListener(keyListener);

    nrFramesLabel = new JLabel();
    updateCalculations();
    gbHelper.addLabelWithControl("Number of Frames:", nrFramesLabel);
}
项目:TypeTalk    文件:ApplicationWindow.java   
private JTextField createSuggestField() {
   JSuggestField typingField = new JSuggestField(this, Suggestions.getInstance().getSuggestions());
   typingField.addKeyListener(new KeyAdapter() {

      @Override
      public void keyReleased(KeyEvent e) {
         if (e.getKeyCode() == KeyEvent.VK_ENTER) {
            if (typingField.isSuggestionAccepted()) {
               typingField.setSuggestionAccepted(false);
            } else {
               speekTypingFieldContent(true);
               typingField.hideSuggest();
            }
         }
      }
   });
   new EditAdapter(typingField);
   return typingField;
}
项目:ca-iris    文件:R_NodeDetectorPanel.java   
/** Create Gui jobs */
private void createJobs() {
    ListSelectionModel s = det_table.getSelectionModel();
    s.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    s.addListSelectionListener(new IListSelectionAdapter() {
        @Override
        public void valueChanged() {
            selectDetector();
        }
    });
    det_txt.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if(e.getKeyCode() == KeyEvent.VK_ENTER)
                create_btn.doClick();
        }
        @Override
        public void keyReleased(KeyEvent ke) {
            det_table.clearSelection();
            lookupDetector();
        }
    });
}
项目:intellij-ce-playground    文件:TemplateLanguagePanel.java   
public TemplateLanguagePanel() {
  super(new BorderLayout());
  add(myMainPanel, BorderLayout.CENTER);
  myTemplatesFolderLabel.setLabelFor(myTemplatesFolder);
  FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  descriptor.withTreeRootVisible(true);
  descriptor.setShowFileSystemRoots(true);
  List<String> templateConfigurations = TemplatesService.getAllTemplateLanguages();
  for (String configuration : templateConfigurations) {
    if (!configuration.equals(TemplatesService.WEB2PY)) {
      myTemplateLanguage.addItem(configuration);
    }
  }
  myTemplatesFolder.setText(DEFAULT_TEMPLATES_FOLDER);
  myTemplatesFolder.addKeyListener(new KeyAdapter() {
    @Override
    public void keyTyped(KeyEvent e) {
      final int dot = myTemplatesFolder.getCaret().getDot();
      final int index = myTemplatesFolder.getText().indexOf(File.separator);
      if (index >= dot) {
        myTemplateFolderModified = true;
      }
    }
  });
}
项目:yii2support    文件:SettingsForm.java   
public SettingsForm(Project project) {
    settings = Yii2SupportSettings.getInstance(project);


    tablePrefixTextbox.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            super.keyReleased(e);
            adjustInputs();
        }
    });
}
项目:incubator-netbeans    文件:ListView.java   
private void setupSearch() {
    // Remove the default key listeners
    KeyListener[] keyListeners = getListeners(KeyListener.class);

    for (int i = 0; i < keyListeners.length; i++) {
        removeKeyListener(keyListeners[i]);
    }

    // Add new key listeners
    addKeyListener(
        new KeyAdapter() {
        @Override
            public void keyPressed(KeyEvent e) {
                int modifiers = e.getModifiers();
                int keyCode = e.getKeyCode();

                if (((modifiers > 0) && (modifiers != KeyEvent.SHIFT_MASK)) || e.isActionKey()) {
                    return;
                }

                char c = e.getKeyChar();

                if (!Character.isISOControl(c) && (keyCode != KeyEvent.VK_SHIFT)) {
                    searchTextField.setText(String.valueOf(c));
                    displaySearchField();
                }
            }
        }
    );

    // Create a the "multi-event" listener for the text field. Instead of
    // adding separate instances of each needed listener, we're using a
    // class which implements them all. This approach is used in order
    // to avoid the creation of 4 instances which takes some time
    SearchFieldListener searchFieldListener = new SearchFieldListener();
    searchTextField.addKeyListener(searchFieldListener);
    searchTextField.addFocusListener(searchFieldListener);
    searchTextField.getDocument().addDocumentListener(searchFieldListener);
}
项目:incubator-netbeans    文件:Preview.java   
private Preview() {
    myPrinter = new Printer();
    myKeyListener = new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            char ch = event.getKeyChar();
            int modifiers = event.getModifiers();

            if (ch == '+' || ch == '=') {
                if (isCtrl(modifiers)) {
                    increaseZoom();
                    updated();
                }
                else {
                    myScale.increaseValue();
                }
            }
            else if (ch == '-' || ch == '_') {
                if (isCtrl(modifiers)) {
                    decreaseZoom();
                    updated();
                }
                else {
                    myScale.decreaseValue();
                }
            }
            else if (ch == '/') {
                myScale.normalValue();
            }
            else if (ch == '*') {
                showCustom(true);
            }
        }
    };
}
项目:incubator-netbeans    文件:FindPanel.java   
/** Creates new form FindPanel. */
public FindPanel() {
    initComponents ();
    initAccessibility ();
    findCombo.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() {
         public void keyTyped(KeyEvent evt) {
            if (evt.getKeyChar() == '\n') {
                findButton.doClick(20);
                evt.consume();
            }
        }
    });
}
项目:rapidminer    文件:AutoCompletionComboBox.java   
public AutoCompletionComboBoxEditor(ComboBoxEditor editor) {
    if ((editor.getEditorComponent() instanceof JTextField)) {
        this.editor = editor;
        editorComponent = (JTextField) editor.getEditorComponent();
        editorComponent.getDocument().addDocumentListener(docListener);
        editorComponent.addKeyListener(new KeyAdapter() {

            @Override
            public void keyPressed(KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                    setSelectedItem(editorComponent.getText());
                    actionPerformed(new ActionEvent(this, 0, "editingStoped"));
                    e.consume();
                } else if (e.getKeyCode() == KeyEvent.VK_TAB) {
                    if (isPopupVisible()) {
                        hidePopup();
                    } else {
                        showPopup();
                    }
                    e.consume();
                } else {
                    super.keyPressed(e);
                }
            }
        });
    } else {
        throw new IllegalArgumentException("Only JTextField allowed as editor component");
    }
}
项目:routerapp    文件:PropertyInteractionDialog.java   
/**
 * 
 */
private void buildFields() {
    Vector properties = component.getProperties().getAllProperties();
    GridLayout layout = new GridLayout(properties.size(),2,10,10);
    int cells = 0;

    Iterator i = properties.iterator();
    JPanel fieldsPane = new JPanel(layout);
    fieldsPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));

    while (i.hasNext()) {
        try {
            InteractiveProperty property = (InteractiveProperty) i.next();

            final JTextField field = new JTextField(property.toString());
            field.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent e) {
                    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                        applyChanges();
                    }
                    else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                        cancelChanges();
                    }
                }
            });
            field.addFocusListener(new FocusAdapter() {

                public void focusGained(FocusEvent evt) {
                    String text = field.getText();
                    field.setSelectionStart(0);
                    field.setSelectionEnd(text.length());
                }
            });
            field.setMaximumSize(new Dimension(150,30));
            fields.put(property,field);

            fieldsPane.add(new JLabel(property.getName()));
            fieldsPane.add(field);

            cells++;
        } catch (ClassCastException exc) {
            /* 
             * caught to be ignored, so that non-interactive properties
             * won't be shown in the GUI
             */
        }
    }
    this.setSize(200,cells * CELL_HEIGHT);
    getContentPane().add(fieldsPane,BorderLayout.CENTER);
}
项目:ObsidianSuite    文件:TimelinePartPanel.java   
private void setupFilter() {
    JTextField textField = ((JSpinner.DefaultEditor)getEditor()).getTextField();
    textField.addKeyListener(new KeyAdapter() {
        public void keyTyped(KeyEvent e) {
            char c = e.getKeyChar();
            if ( ((c < '0') || (c > '9')) && (c != KeyEvent.VK_BACK_SPACE) && (c != KeyEvent.VK_MINUS)  && (c != KeyEvent.VK_PERIOD))
                e.consume();
        }
    });
}