mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
A few more cleanups while I'm at it in GUIRunner
git-svn-id: https://zxing.googlecode.com/svn/trunk@414 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
6c4fe1633f
commit
284c1776d5
|
@ -22,6 +22,7 @@ import com.google.zxing.ReaderException;
|
||||||
import com.google.zxing.Result;
|
import com.google.zxing.Result;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.Icon;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
@ -58,27 +59,22 @@ public final class GUIRunner extends JFrame {
|
||||||
panel.add(textArea);
|
panel.add(textArea);
|
||||||
setTitle("ZXing");
|
setTitle("ZXing");
|
||||||
setSize(400, 400);
|
setSize(400, 400);
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||||
setContentPane(panel);
|
setContentPane(panel);
|
||||||
setLocationRelativeTo(null);
|
setLocationRelativeTo(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws MalformedURLException {
|
||||||
GUIRunner runner = new GUIRunner();
|
GUIRunner runner = new GUIRunner();
|
||||||
runner.setVisible(true);
|
runner.setVisible(true);
|
||||||
runner.chooseImage();
|
runner.chooseImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void chooseImage() {
|
private void chooseImage() throws MalformedURLException {
|
||||||
JFileChooser fileChooser = new JFileChooser();
|
JFileChooser fileChooser = new JFileChooser();
|
||||||
fileChooser.showOpenDialog(GUIRunner.this);
|
fileChooser.showOpenDialog(this);
|
||||||
File file = fileChooser.getSelectedFile();
|
File file = fileChooser.getSelectedFile();
|
||||||
ImageIcon imageIcon;
|
Icon imageIcon = new ImageIcon(file.toURI().toURL());
|
||||||
try {
|
|
||||||
imageIcon = new ImageIcon(file.toURI().toURL());
|
|
||||||
} catch (MalformedURLException mue) {
|
|
||||||
throw new RuntimeException(mue);
|
|
||||||
}
|
|
||||||
setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight() + 100);
|
setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight() + 100);
|
||||||
imageLabel.setIcon(imageIcon);
|
imageLabel.setIcon(imageIcon);
|
||||||
String decodeText = getDecodeText(file);
|
String decodeText = getDecodeText(file);
|
||||||
|
|
Loading…
Reference in a new issue