Trying get a fileViewer
method that will allow user to choose photo from file and when Button
is used will pull up the dialog box. My close button obviously works as code is simple. With the enlarge picture button I did wonder if I could declare a constant and use it to scale photo by the constant. Wasn't sure if that was even a thing.
Below is my code:
package masdfas.fd;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class BetterWork extends Frame implements ActionListener {
Button browseButton = new Button("Browse");
Button enlargeButton = new Button("Enlarge");
Button closeButton = new Button("Quit");
Label onlyLabel = new Label ("Welcome to my Program");
public static void main(String[] args) {
BetterWork BW = new BetterWork();
BW.setVisible(true);
BW.setSize(600, 500);
}
public BetterWork() {
super ("program");
setLayout(null);
onlyLabel.setBounds(250, 50, 150, 50);
add(onlyLabel);
browseButton.setBounds(30, 50, 50, 50);
add( browseButton);
enlargeButton.setBounds(30, 150, 50, 50);
add(enlargeButton);
closeButton.setBounds(30, 250, 50, 50);
add(closeButton);
browseButton.addActionListener(this);
enlargeButton.addActionListener(this);
closeButton.addActionListener(this);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent AE) {
if (AE.getSource() == browseButton) {
browse();
} else if (AE.getSource() == enlargeButton) {
enlarge();
} else if (AE.getSource() == closeButton) {
close();
}
}
private void close() {
System.exit(0);
}
private void enlarge() {
// TODO Auto-generated method stub
}
private void browse() {
// TODO Auto-generated method stub
}
}