Olá gente, eu fiz uma janela pequena, e gostaria que quando eu aperta-se F1 nela, ela executase um metodo.
Eu sei fazer isso se a janela tiver um JMenuItem, mas eu gostaria de saber como eu posso criar esse atalho mesmo sem JMenuItem.
Grato.
Olá gente, eu fiz uma janela pequena, e gostaria que quando eu aperta-se F1 nela, ela executase um metodo.
Eu sei fazer isso se a janela tiver um JMenuItem, mas eu gostaria de saber como eu posso criar esse atalho mesmo sem JMenuItem.
Grato.
[code]
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
public class TelaEvento extends JFrame
implements KeyListener {
public TelaEvento() {
addKeyListener(this);
}
public static void main(String[] args) {
TelaEvento te = new TelaEvento();
te.setDefaultCloseOperation(EXIT_ON_CLOSE);
te.setSize(300, 300);
te.setVisible(true);
}
public void F1() {
System.out.println("Eu fui chamado! VIVA!!!!!!!!");
}
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == 112) // F1 == 112
F1();
}
public void keyReleased(KeyEvent e) {
}
public void keyTyped(KeyEvent e) {
}
}[/code]
tá me devendo uma cerveja!
hauhua
Olá amigo
tentei implementar esta rotina e não deu certo, teclo F1 e não faz nada.
Pode me ajudar?
Silvio Guedes
Realmente ela funciona quando você cria uma classe só com o teu exemplo, porem quando tá com mais coisas não funcionar, como se algum código interfire-se nela, tu conhece algo que pode interferir?
Bem Silvio…
O código do tivrfoa ta funcionando. Só que ele tá informando no Console ou Prompt, como queira chamar, e não direto na tela.
Então, vc poderia alterar assim:
//lembrando de importar na seção de Import
import javax.swing.JOptionPane;
//(a mesma coisa que o tivrfoa fez)
//altera esta função.
public void F1() {
JOptionPane.showMessageDialog(null, "Tecla F1 pressionada");
}
Uma outra alteração que eu faria seria sobre o código da função do F1. Como vim do Clipper e depois do Delphi, sabia os códigos das teclas. Qdo me confundia, olhava numa tabela… Só que o Java traz uma facilidade… Assim, vc poderia fazer esta outra troca:
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == e.VK_F1)
F1();
}
Abraços
Tenta implementar essa solução dentro de algum jframe com mais comandos, não funciona…
Se rodar exatamente igual ao exemplo funciona, porem o problema é dentro de uma outra classe com mais comandos, como se algo “buga-se” seu uso.
Olá amigos
bem não está funcionando. Então lá vai o código:
/*
* Copyright (c) 1995 - 2008 Sun Microsystems, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Sun Microsystems nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package assistenciadesktop;
import java.beans.PropertyVetoException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JToolBar;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
/*
* FramePrincipal.java requires:
* MyInternalFrame.java
*/
public class FramePrincipal extends JFrame
implements ActionListener, KeyListener {
JDesktopPane desktop;
// private JDesktopPane pane = new JDesktopPane();
// guarda o frame atualmente selecionado para trabalhar com ele
// nas opcçoes de menu
// private MyIF selectedFrame = null;
JPanel panelStatus;
private JToolBar toolBar;
private AbstractAction actionClientes;
private AbstractAction actionOrdemServico;
private AbstractAction actionMarcas;
//private AbstractAction actionTipoequipamento;
static int getHeight;
public JLabel LabelDataHora;
public JLabel LabelUsuario;
ImageIcon sairButtonIcon = createImageIcon("/assistenciadesktop/resources/exit24.png");
ImageIcon clienteButtonIcon = createImageIcon("/assistenciadesktop/resources/kontact_contacts.png");
ImageIcon ordemservicoButtonIcon = createImageIcon("/assistenciadesktop/resources/systemsettings.png");
ImageIcon sobreButtonIcon = createImageIcon("/assistenciadesktop/resources/stockhelp.png");
static FrameClientes frameClientes;
static FrameMarcas frameMarcas;
static FrameOrdemServico frameOrdemServico;
JMenuBar menuBar = new JMenuBar();
public FramePrincipal() {
super("SAT - Sistema de Assistência Técnica V. 1.0");
javax.swing.UIManager.put("OptionPane.yesButtonText", "Sim");
javax.swing.UIManager.put("OptionPane.noButtonText", "Não");
javax.swing.UIManager.put("OptionPane.okButtonText", "Ok");
javax.swing.UIManager.put("OptionPane.cancelButtonText", "Cancelar");
addKeyListener(this);
//Make the big window be indented 50 pixels from each edge
//of the screen.
int inset = 50;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
getHeight = screenSize.height;
setBounds(inset, inset,
screenSize.width - inset*2,
screenSize.height - inset*2);
//Set up the GUI.
desktop = new JDesktopPane(); //a specialized layered pane
// createFrame(); //create first "window"
// setContentPane(desktop);
setJMenuBar(createMenuBar());
JLabel LabelUsuario = new JLabel();
JLabel LabelDataHora = new JLabel();
// tfIdCliente.setBounds(10,25,30,20);
// tfNomeCliente.setBounds(80,25,400,20);
LabelUsuario.setText("Usuário: Data: ");
LabelUsuario.setBounds(110, 01, 10, 30);
LabelDataHora.setText("Data: ");
LabelDataHora.setBounds(200, 01, 280, 30);
StatusBar statusBar = new StatusBar();
statusBar.add(LabelUsuario);
//statusBar.add(LabelDataHora);
getContentPane().add(statusBar, BorderLayout.SOUTH);
getContentPane().add(desktop);
//Make dragging a little faster but perhaps uglier.
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
this.setVisible(true);
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
}
protected JMenuBar createMenuBar() {
//JMenuBar menuBar = new JMenuBar();
//Set up the lone menu.
// JMenu menu = new JMenu("Cadastro");
// menu.setMnemonic(KeyEvent.VK_C);
// menuBar.add(menu);
JMenu menu = new JMenu("Assistência");
menu.setMnemonic(KeyEvent.VK_A);
menu.setMnemonic('A');
menuBar.add(menu);
//Set up the first menu item.
JMenuItem menuItem = new JMenuItem("Clientes");
menuItem.setMnemonic(KeyEvent.VK_C);
menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_C, ActionEvent.ALT_MASK));
menuItem.setActionCommand("clientes");
menuItem.setIcon(clienteButtonIcon);
menuItem.addActionListener(this);
menu.add(menuItem);
menuItem = new JMenuItem("Ordem Serviço");
menuItem.setMnemonic(KeyEvent.VK_O);
menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_O, ActionEvent.ALT_MASK));
menuItem.setActionCommand("ordemservico");
menuItem.setIcon(ordemservicoButtonIcon);
menuItem.addActionListener(this);
menu.add(menuItem);
menuItem = new JMenuItem("Marcas");
menuItem.setMnemonic(KeyEvent.VK_M);
menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_M, ActionEvent.ALT_MASK));
menuItem.setActionCommand("marcas");
menuItem.setIcon(ordemservicoButtonIcon);
menuItem.addActionListener(this);
menu.add(menuItem);
menu.addSeparator();
//Set up the second menu item.
menuItem = new JMenuItem("Sair");
menuItem.setMnemonic(KeyEvent.VK_F4);
menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_F4, ActionEvent.ALT_MASK));
menuItem.setActionCommand("quit");
menuItem.setIcon(sairButtonIcon);
menuItem.addActionListener(this);
menu.add(menuItem);
toolBar = new JToolBar();
JButton btn1 = toolBar.add(actionClientes);
btn1.setToolTipText("Cadastro de Clientes");
btn1.setActionCommand("clientes");
btn1.setIcon(clienteButtonIcon);
JButton btn2 = toolBar.add(actionOrdemServico);
btn2.setToolTipText("Ordem de Serviço");
btn2.setIcon(ordemservicoButtonIcon);
btn2.setActionCommand("ordemservico");
JButton btn3 = toolBar.add(actionMarcas);
btn3.setToolTipText("Cadastro de Marcas");
btn3.setIcon(ordemservicoButtonIcon);
btn3.setActionCommand("marcas");
getContentPane().add(toolBar, BorderLayout.NORTH);
return menuBar;
}
//React to menu selections.
public void actionPerformed(ActionEvent e) {
if ("clientes".equals(e.getActionCommand())) { //new
try {
//new
createFrameClientes();
} catch (Exception ex) {
Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
}
}
if ("marcas".equals(e.getActionCommand())) { //new
try {
//new
createFrameMarcas();
} catch (Exception ex) {
Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
}
}
if ("ordemservico".equals(e.getActionCommand())) { //new
try {
//new
createFrameOrdemServico();
} catch (Exception ex) {
Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
}
}
if ("quit".equals(e.getActionCommand())) { //new
int i = JOptionPane.showOptionDialog(null,"Tem certeza que deseja sair?", "Sair do Sistema",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE, null,null,JOptionPane.NO_OPTION);
if (i == JOptionPane.YES_OPTION)
quit();
}
}
//Create a new internal frame.
protected void createFrame() throws PropertyVetoException {
MyInternalFrame frame = new MyInternalFrame();
frame.setVisible(true); //necessary as of 1.3
desktop.add(frame);
this.setVisible(true);
desktop.getDesktopManager().maximizeFrame(frame);
try {
frame.setSelected(true);
} catch (java.beans.PropertyVetoException e) {}
}
protected void createFrameClientes() throws PropertyVetoException, Exception {
if (frameClientes == null) {
frameClientes = new FrameClientes();
frameClientes.setVisible(true); //necessary as of 1.3
desktop.add(frameClientes);
frameClientes.pack();
desktop.getDesktopManager().maximizeFrame(frameClientes);
}
else {
frameClientes.setVisible(true);
}
try {
frameClientes.setSelected(true);
} catch (java.beans.PropertyVetoException e) {}
}
protected void createFrameOrdemServico() throws PropertyVetoException, Exception {
if (frameOrdemServico == null) {
frameOrdemServico= new FrameOrdemServico();
frameOrdemServico.setVisible(true); //necessary as of 1.3
desktop.add(frameOrdemServico);
frameOrdemServico.pack();
desktop.getDesktopManager().maximizeFrame(frameOrdemServico);
}
else {
frameOrdemServico.setVisible(true);
}
try {
frameOrdemServico.setSelected(true);
} catch (java.beans.PropertyVetoException e) {}
}
protected void createFrameMarcas() throws PropertyVetoException, Exception {
if (frameMarcas == null) {
frameMarcas = new FrameMarcas();
desktop.add(frameMarcas);
frameMarcas.setVisible(true);
frameMarcas.pack();
desktop.getDesktopManager().maximizeFrame(frameMarcas);
}
else {
frameMarcas.setVisible(true); //necessary as of 1.3
}
try {
frameMarcas.setSelected(true);
} catch (java.beans.PropertyVetoException e) {}
}
//Quit the application.
protected void quit() {
System.exit(0);
}
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI() throws InterruptedException, ClassNotFoundException {
//Make sure we have nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(true);
//Create and set up the window.
FramePrincipal frame = new FramePrincipal();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Display the window.
frame.setVisible(true);
}
public static ImageIcon createImageIcon(String path) {
java.net.URL imgURL = FramePrincipal.class.getResource(path);
if (imgURL != null) {
return new ImageIcon(imgURL);
} else {
System.err.println("Couldn't find file: " + path);
return null;
}
}
public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, InterruptedException {
Splash.criarExibirInterface();
// FAutenticacao fautenticacao = new FAutenticacao();
// fautenticacao.setVisible(true);
createAndShowGUI();
}
public void F1() {
JOptionPane.showMessageDialog(null, "Tecla F1 pressionada");
}
public void keyTyped(KeyEvent arg0) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == e.VK_F1)
F1();
}
public void keyReleased(KeyEvent arg0) {
throw new UnsupportedOperationException("Not supported yet.");
}
// public void keyTyped(KeyEvent arg0) {
// throw new UnsupportedOperationException("Not supported yet.");
// }
//
// public void keyPressed(KeyEvent e){
//
// if(e.getKeyCode() == KeyEvent.VK_F1) // F1 == 112
// try {
// // F1 == 112
// F1();
// } catch (PropertyVetoException ex) {
// Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
// } catch (Exception ex) {
// Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
// }
//
//
//}
//
// public void keyReleased(KeyEvent e) {
// if(e.getKeyCode() == KeyEvent.VK_F1) // F1 == 112
// try {
// // F1 == 112
// F1();
// } catch (PropertyVetoException ex) {
// Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
// } catch (Exception ex) {
// Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
// }
// }
}
Muito Obrigado
Silvio Guedes
Bem,
testei de novo, a aplicação sozinha, como o tivrfoa fez, com e sem as alterações que eu fiz. Funciona!
Agora, reintero o que o treloso diz: se vc testar só a aplicação, isolada, ela vai funcionar…
Agora, se na aplicação que vc está fazendo, junto o código esta dando erro, não está funcionando, é bom fazer um review em todas as classes, testanto uma a uma, para ver onde está o erro…

Abraços
Descobri… o problema é que o keylistener tem que ser setado em todos os componentes do jframe…
consegui criar uma solução:
public TelaEvento() {
addKeyListener(this);
// No construtor adicione...
implementarTeclado();
}
// Implemente esse método
private void implementarTeclado() {
for (int i = 0; i < getContentPane().getComponentCount(); i++) {
getContentPane().getComponent(i).addKeyListener(this);
}
}
Feito isso ele deve funcionar… Silvio e berg, testa ai e me avisa qualquer coisa se funcionar, aqui funfou!
No meu ok.
Parabens
:thumbup:
Olá amigos
infelizmente no meu caso ainda não funcionou.
Obrigado
Silvio Guedes
Ola procure pelas classes KeyStroker, InputMap, ActionMap. Que vai resolver seu problema
Abraços
olá pessoal!
então, todo componente q tira o foco da tela tem q ter o listener tbm.
o do treloso funcionou, pq ele adicionou os componentes direto no JFrame, certo?!
já o silviogs deve estar usando JPanel, portanto cada componente do JPanel deve ter o listener tbm!!
[code]import java.awt.Component;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class TelaEvento3 extends JFrame
implements KeyListener {
JLabel lblName;
JTextField txtName;
JButton btnOK;
JPanel panel;
public TelaEvento3() {
addKeyListener(this);
panel = new JPanel();
lblName = new JLabel("Nome:");
panel.add(lblName);
txtName = new JTextField(20);
panel.add(txtName);
btnOK = new JButton("OK");
panel.add(btnOK);
listenKeyboard(panel.getComponents());
add(panel);
listenKeyboard(getComponents());
}
public static void main(String[] args) {
TelaEvento3 te = new TelaEvento3();
te.setDefaultCloseOperation(EXIT_ON_CLOSE);
te.setSize(300, 300);
te.setVisible(true);
}
public void F1() {
System.out.println("Eu fui chamado! VIVA!!!!!!!!");
JOptionPane.showMessageDialog(null, "Olha o PROMPT!");
}
public void listenKeyboard(Component[] cs) {
for(Component c:cs)
c.addKeyListener(this);
}
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_F1)
F1();
}
public void keyReleased(KeyEvent e) {}
public void keyTyped(KeyEvent e) {}
}[/code]
O método implementarTeclado, pega todos os Components do JFrame e adiciona em todos o listener…
tivrfoa, o teu exemplo é correto, é pq ele só funciona se não tiver mais nenhum componenete, se tiver tem que fazer todos esses componentes tb ter esse listener, pq senão eles tem “listerners” proprios… pelo menos eu acho que é assim
huahuauhAhua
muito obrigado mesmo tivrfoa!
Olá amigos
fiz a implementação dos outros componentes e funcionou:
public FramePrincipal() {
super("SAT - Sistema de Assistência Técnica V. 1.0");
javax.swing.UIManager.put("OptionPane.yesButtonText", "Sim");
javax.swing.UIManager.put("OptionPane.noButtonText", "Não");
javax.swing.UIManager.put("OptionPane.okButtonText", "Ok");
javax.swing.UIManager.put("OptionPane.cancelButtonText", "Cancelar");
//Make the big window be indented 50 pixels from each edge
//of the screen.
int inset = 50;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
getHeight = screenSize.height;
setBounds(inset, inset,
screenSize.width - inset*2,
screenSize.height - inset*2);
//Set up the GUI.
desktop = new JDesktopPane(); //a specialized layered pane
// createFrame(); //create first "window"
// setContentPane(desktop);
setJMenuBar(createMenuBar());
JLabel LabelUsuario = new JLabel();
JLabel LabelDataHora = new JLabel();
// tfIdCliente.setBounds(10,25,30,20);
// tfNomeCliente.setBounds(80,25,400,20);
LabelUsuario.setText("Usuário: Data: ");
LabelUsuario.setBounds(110, 01, 10, 30);
LabelDataHora.setText("Data: ");
LabelDataHora.setBounds(200, 01, 280, 30);
StatusBar statusBar = new StatusBar();
statusBar.add(LabelUsuario);
//statusBar.add(LabelDataHora);
getContentPane().add(statusBar, BorderLayout.SOUTH);
getContentPane().add(desktop);
//Make dragging a little faster but perhaps uglier.
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
this.setVisible(true);
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
listenKeyboard(getComponents()); aqui
}
protected JMenuBar createMenuBar() {
//Set up the lone menu.
// JMenu menu = new JMenu("Cadastro");
// menu.setMnemonic(KeyEvent.VK_C);
// menuBar.add(menu);
JMenu menu = new JMenu("Assistência");
menu.setMnemonic(KeyEvent.VK_A);
menu.setMnemonic('A');
menuBar.add(menu);
//Set up the first menu item.
JMenuItem menuItem = new JMenuItem("Clientes");
menuItem.setMnemonic(KeyEvent.VK_C);
menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_C, ActionEvent.ALT_MASK));
menuItem.setActionCommand("clientes");
menuItem.setIcon(clienteButtonIcon);
menuItem.addActionListener(this);
menu.add(menuItem);
menuItem = new JMenuItem("Ordem Serviço");
menuItem.setMnemonic(KeyEvent.VK_O);
menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_O, ActionEvent.ALT_MASK));
menuItem.setActionCommand("ordemservico");
menuItem.setIcon(ordemservicoButtonIcon);
menuItem.addActionListener(this);
menu.add(menuItem);
menuItem = new JMenuItem("Marcas");
menuItem.setMnemonic(KeyEvent.VK_M);
menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_M, ActionEvent.ALT_MASK));
menuItem.setActionCommand("marcas");
menuItem.setIcon(ordemservicoButtonIcon);
menuItem.addActionListener(this);
menu.add(menuItem);
menu.addSeparator();
//Set up the second menu item.
menuItem = new JMenuItem("Sair");
menuItem.setMnemonic(KeyEvent.VK_F4);
menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_F4, ActionEvent.ALT_MASK));
menuItem.setActionCommand("quit");
menuItem.setIcon(sairButtonIcon);
menuItem.addActionListener(this);
menu.add(menuItem);
// ImageIcon sairButtonIcon = createImageIcon("resources/exit24.png");
// ImageIcon clienteButtonIcon = createImageIcon("resources/kontact_contacts.png");
// ImageIcon ordemservicoButtonIcon = createImageIcon("resources/systemsettings.png");
// ImageIcon sobreButtonIcon = createImageIcon("resources/stockhelp.png");
toolBar = new JToolBar();
JButton btn1 = toolBar.add(actionClientes);
btn1.setToolTipText("Cadastro de Clientes");
btn1.setIcon(clienteButtonIcon);
JButton btn2 = toolBar.add(actionOrdemServico);
btn2.setToolTipText("Ordem de Serviço");
btn2.setIcon(ordemservicoButtonIcon);
JButton btn3 = toolBar.add(actionMarcas);
btn3.setToolTipText("Cadastro de Marcas");
btn3.setIcon(ordemservicoButtonIcon);
getContentPane().add(toolBar, BorderLayout.NORTH);
listenKeyboard(toolBar.getComponents()); aqui
listenKeyboard(menu.getComponents()); aqui
return menuBar;
}
Muito Obrigado
Silvio Guedes
Parabens