Hey guys, need some GUI help again.
Getting error: Encode cannot be resolved to a type on Line no. 25
where am I doing wrong ?
Here is my code:
import java.awt.FlowLayout; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.imageio.ImageIO; import javax.swing.*; import java.io.*; import javax.swing.filechooser.FileFilter; import java.awt.*; public class Hashnain extends JFrame{ JMenuBar menuBar; JMenu menu; JMenuItem menuItem1; JMenuItem menuItem2; JMenuItem menuItem3; JFileChooser c = new JFileChooser(); private JTextArea textArea; private JLabel label; private JButton imo; private JButton enco; private Image imo1; private Encode en4; private String stat_path = ""; private String stat_name = ""; Filt im = new Filt(); Model1 mo = new Model1(); public Hashnain(){ super("The title"); setLayout(new FlowLayout()); //Create the menu bar. menuBar = new JMenuBar(); //Build the first menu. menu = new JMenu("Guide"); menuItem1 = new JMenuItem("Help"); menuItem2 = new JMenuItem("About"); menuItem3 = new JMenuItem("Exit"); imo1=new Image(); en4 = new Encode(); imo = new JButton("Select image file"); enco = new JButton("Encode"); imo.addActionListener(imo1); enco.addActionListener(en4); menu.add(menuItem1); menu.add(menuItem2); menu.add(menuItem3); add(menu); menuBar.add(menu); add(menuBar); add(imo); } private class Image implements ActionListener { /* *handles the click event *@param e The ActionEvent Object */ public void actionPerformed(ActionEvent e) { //show the decode view JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); chooser.setFileFilter(new Filt()); int returnVal = chooser.showOpenDialog(imo); if (returnVal == JFileChooser.APPROVE_OPTION){ File directory = chooser.getSelectedFile(); try{ String image = directory.getPath(); stat_name = directory.getName(); stat_path = directory.getPath(); } catch(Exception except) { //msg if opening fails JOptionPane.showMessageDialog(imo, "The File cannot be opened!", "Error!", JOptionPane.INFORMATION_MESSAGE); } } } private class Encode implements ActionListener{ public void actionPerformed(ActionEvent eq) { JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); chooser.setFileFilter(new Filt()); } } } } Main class: import javax.swing.JFrame; import java.awt.*; public class Fish { public static void main(String[] args){ Hashnain obj= new Hashnain(); obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); obj.setSize(350, 100); obj.setVisible(true); } }