Skip to content

Instantly share code, notes, and snippets.

@crzye8s
Forked from BobTheBuilderBot/gist:3856934
Created October 10, 2012 22:55
Show Gist options
  • Select an option

  • Save crzye8s/3869058 to your computer and use it in GitHub Desktop.

Select an option

Save crzye8s/3869058 to your computer and use it in GitHub Desktop.
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ImageZoom implements ActionListener {
private JFrame windowFrame;
public static void main(String[] args) {
ImageZoom imageZoomApp = new ImageZoom();
imageZoomApp.createWindow();
imageZoomApp.createElements();
}
public void createWindow() {
windowFrame = new JFrame("Testing");
windowFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
windowFrame.setPreferredSize(new Dimension(640, 480));
windowFrame.setVisible(true);
}
public void createElements() {
JMenu menu, submenu;
JMenuItem menuItem;
JMenuBar menuBar = new JMenuBar();
menu = new JMenu("Test Menu");
menuBar.add(menu);
menuItem = new JMenuItem("A text-only menu item");
menu.add(menuItem);
menuItem.setActionCommand("openImage");
menuItem.addActionListener(this);
windowFrame.add(menu);
windowFrame.pack();
}
@Override
public void actionPerformed(ActionEvent event) {
if(event.getActionCommand() == "openImage") {
openFileDialog();
}
}
public void openFileDialog() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment