当前位置: 首页>>代码示例>>Java>>正文


Java KeyAdapter类代码示例

本文整理汇总了Java中java.awt.event.KeyAdapter的典型用法代码示例。如果您正苦于以下问题:Java KeyAdapter类的具体用法?Java KeyAdapter怎么用?Java KeyAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


KeyAdapter类属于java.awt.event包,在下文中一共展示了KeyAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateProviderOnSave

import java.awt.event.KeyAdapter; //导入依赖的package包/类
public KeyListener updateProviderOnSave() {
    return new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent ke) {
            if (isSave(ke)) {
                onSave();
            }
        }
    };
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:11,代码来源:StyledEditor.java

示例2: Presenter

import java.awt.event.KeyAdapter; //导入依赖的package包/类
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());
                }
            });
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:OQLControllerUI.java

示例3: DrawingPanel

import java.awt.event.KeyAdapter; //导入依赖的package包/类
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);
            }
        }
    });
}
 
开发者ID:vramdhanie,项目名称:pong,代码行数:21,代码来源:DrawingPanel.java

示例4: init

import java.awt.event.KeyAdapter; //导入依赖的package包/类
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);
}
 
开发者ID:evernat,项目名称:dead-code-detector,代码行数:21,代码来源:ParametersPanel.java

示例5: listenToKeysListener

import java.awt.event.KeyAdapter; //导入依赖的package包/类
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;
}
 
开发者ID:Coder-ACJHP,项目名称:Hotel-Properties-Management-System,代码行数:18,代码来源:HotelPropertiesWindow.java

示例6: validatorListener

import java.awt.event.KeyAdapter; //导入依赖的package包/类
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;
}
 
开发者ID:Coder-ACJHP,项目名称:Hotel-Properties-Management-System,代码行数:19,代码来源:AddUserWindow.java

示例7: getQueryField

import java.awt.event.KeyAdapter; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:25,代码来源:PrologDisplay.java

示例8: initListeners

import java.awt.event.KeyAdapter; //导入依赖的package包/类
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();
      }
    }
  });
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:26,代码来源:TextualDocumentView.java

示例9: BusyGlassPane

import java.awt.event.KeyAdapter; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:equella,项目名称:Equella,代码行数:23,代码来源:BusyGlassPane.java

示例10: init

import java.awt.event.KeyAdapter; //导入依赖的package包/类
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);
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:27,代码来源:IconPreviewPanel.java

示例11: GlobalSearchDialog

import java.awt.event.KeyAdapter; //导入依赖的package包/类
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;
}
 
开发者ID:pengwei1024,项目名称:AndroidSourceViewer,代码行数:20,代码来源:GlobalSearchDialog.java

示例12: startRename

import java.awt.event.KeyAdapter; //导入依赖的package包/类
private void startRename() {
	
	// init the text box
	final JTextField text = new JTextField();
	text.setText(m_reference.getNamableName());
	text.setPreferredSize(new Dimension(360, text.getPreferredSize().height));
	text.addKeyListener(new KeyAdapter() {
		@Override
		public void keyPressed(KeyEvent event) {
			switch (event.getKeyCode()) {
				case KeyEvent.VK_ENTER:
					finishRename(text, true);
				break;
				
				case KeyEvent.VK_ESCAPE:
					finishRename(text, false);
				break;
			}
		}
	});
	
	// find the label with the name and replace it with the text box
	JPanel panel = (JPanel)m_infoPanel.getComponent(0);
	panel.remove(panel.getComponentCount() - 1);
	panel.add(text);
	text.grabFocus();
	text.selectAll();
	
	redraw();
}
 
开发者ID:cccssw,项目名称:enigma-vk,代码行数:31,代码来源:Gui.java

示例13: run

import java.awt.event.KeyAdapter; //导入依赖的package包/类
@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);
        }
    }
}
 
开发者ID:tomwhite,项目名称:set-game,代码行数:24,代码来源:PlaySet.java

示例14: DisplayChangeVITest

import java.awt.event.KeyAdapter; //导入依赖的package包/类
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());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:DisplayChangeVITest.java

示例15: createGui

import java.awt.event.KeyAdapter; //导入依赖的package包/类
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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:bug6578666.java


注:本文中的java.awt.event.KeyAdapter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。