Question
Please motify the follow Java swing code specifically the JButton zOut = new JButton(Zoom Out); to zoom out of an image import java.awt.EventQueue; import java.awt.Image;
Please motify the follow Java swing code specifically the JButton zOut = new JButton("Zoom Out"); to zoom out of an image
import java.awt.EventQueue; import java.awt.Image;
import javax.swing.JFrame; import java.awt.Color; import javax.swing.JScrollPane; import java.awt.BorderLayout; import java.awt.ScrollPane; import java.awt.TextArea; import javax.swing.JLabel; import javax.imageio.ImageIO; import javax.swing.*; import javax.swing.JTextField; import javax.swing.JButton; import java.awt.event.ActionListener; import java.awt.image.BufferedImage; import java.awt.*; import java.io.File; import java.awt.event.ActionEvent;
public class Viewer {
private JFrame frame;
/** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Viewer window = new Viewer(); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
/** * Create the application. */ public Viewer() { initialize(); }
/** * Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.setBackground(Color.GRAY); frame.setBounds(100, 100, 933, 495); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("File"); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(10, 11, 897, 380); frame.getContentPane().add(scrollPane); JLabel ibpict = new JLabel(""); scrollPane.setViewportView(ibpict); JMenuItem open = new JMenuItem("Open File"); open.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser files = new JFileChooser(); files.setCurrentDirectory(new File(".")); int file = files.showOpenDialog(null); if(file == JFileChooser.APPROVE_OPTION) { String name = files.getSelectedFile().getPath(); ibpict.setIcon(new ImageIcon(name)); } } }); JMenuItem close = new JMenuItem("Close"); close.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); menuBar.add(menu); menu.add(open); menu.add(close); frame.setJMenuBar(menuBar); JButton zIn = new JButton(" Zoom In"); zIn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); zIn.setBounds(267, 402, 89, 23); frame.getContentPane().add(zIn); JButton zOut = new JButton("Zoom Out"); zOut.setBounds(397, 402, 89, 23); frame.getContentPane().add(zOut); } // }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started