addComponents(textField);
setPreferredSize(new Dimension(200, 100));
}
private JMenuBar menuBar() {
JMenuBar menuBar = new JMenuBar();
JMenu viewMenu = new JMenu("View");
JMenuItem viewMessageMenu = new JMenuItem("Message");
viewMessageMenu.setAccelerator(getKeyStroke(VK_M, CTRL_MASK));
viewMessageMenu.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
showMessageDialog(MyWindow.this, "Hello World", "My Message", INFORMATION_MESSAGE);
}
});
viewMenu.add(viewMessageMenu);
menuBar.add(viewMenu);
return menuBar;
}