Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save crzye8s/3864231 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;
/**
* Owner: Justin
* Date: 10/8/12
* Time: 10:43 PM
*/
public class ImageZoom implements ActionListener {
private JFrame windowFrame;
private JPanel buttonPanel;
private JButton openButton;
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() {
buttonPanel = new JPanel();
buttonPanel.setPreferredSize(new Dimension(640, 100));
openButton = new JButton("Open Image");
openButton.setPreferredSize(new Dimension(120, 25));
openButton.setActionCommand("openImage");
// Todo add action listener to our openButton
buttonPanel.add(openButton);
// Todo add element for controlling zoom
// Todo add new panel for image
windowFrame.add(buttonPanel);
windowFrame.pack();
}
@Override
public void actionPerformed(ActionEvent e) {
// Todo listen for action "openImage" - open file dialog and load image created in createElements method
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment