Results 1 to 5 of 5
- 04-14-2010, 03:27 PM #1
Member
- Join Date
- Apr 2010
- Posts
- 2
- Rep Power
- 0
Help in incompatible type JTextArea
I have 2 classes in the same package
Class1 Example
Class2 Steganography_ControllerJava Code:package LongRSATest; import java.*; import javax.swing.*; import LongRSA.RSACryptor; import LongRSA.RSACryptString; import Utilities.Panel.LUAboutPanel; import java.io.*; import java.math.BigInteger; import java.security.NoSuchAlgorithmException; import java.util.Vector; /** * * @author Nimisha * */ public class Example extends javax.swing.JFrame { //private RSACryptor cryp; public RSAFrame frame = null; public RSATest parent = null; /** Encryptor / decryptor for String objects */ public RSACryptor cryp = null; public RSACryptString crypter = null; public String input = null; public boolean packFrame = true; public String encrypt = null; public String decrypt = null; public String d,n,e; public JTextArea SHA11; /** Creates new form Example */ public Example() { initComponents(); cryp = new RSACryptor(); jTextField1.setText("256"); jTextField2.setText("256"); d = "cf56895624d88788b57ba37f5fc8b639"; n = "1240a700d6879477b4e38e6fbf096200b"; e = "cb12a3f9d969ea9fe5297633bae03229"; jTextField3.setText(d); jTextField4.setText(n); jTextField5.setText(e); crypter = new RSACryptString(cryp); } String getText() { throw new UnsupportedOperationException("Not yet implemented"); } void setText(String string) { throw new UnsupportedOperationException("Not yet implemented"); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); jTextField2 = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jTextField3 = new javax.swing.JTextField(); jTextField4 = new javax.swing.JTextField(); jTextField5 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jLabel6 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); jButton3 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jLabel7 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); jTextArea2 = new javax.swing.JTextArea(); jButton5 = new javax.swing.JButton(); jLabel8 = new javax.swing.JLabel(); jButton6 = new javax.swing.JButton(); jButton7 = new javax.swing.JButton(); jScrollPane4 = new javax.swing.JScrollPane(); jTextArea4 = new javax.swing.JTextArea(); jLabel9 = new javax.swing.JLabel(); jTextField6 = new javax.swing.JTextField(); jButton8 = new javax.swing.JButton(); jButton9 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Main Frame"); setAlwaysOnTop(true); jLabel1.setText("Key Length (Bit)"); jLabel2.setText("Certainity"); jTextField1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField1ActionPerformed(evt); } }); jLabel3.setText("Public Key"); jLabel4.setText("Private Key"); jLabel5.setText("Base Key"); jButton1.setText("New Keys"); jButton1.setToolTipText("Generate New Keys"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton2.setText("Clear Keys"); jButton2.setToolTipText("Clear all the keys"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jLabel6.setText("Input String"); jTextArea1.setColumns(20); jTextArea1.setRows(5); jScrollPane1.setViewportView(jTextArea1); jButton3.setText("Encrypt"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jButton4.setText("Exit"); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } }); jLabel7.setText("Encrypted String"); jTextArea2.setColumns(20); jTextArea2.setRows(5); jScrollPane2.setViewportView(jTextArea2); jButton5.setText("Decrypt"); jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton5ActionPerformed(evt); } }); jLabel8.setText("Output String"); jButton6.setText("Help"); jButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton6ActionPerformed(evt); } }); jButton7.setText("Clear String"); jButton7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton7ActionPerformed(evt); } }); jTextArea4.setColumns(20); jTextArea4.setRows(5); jScrollPane4.setViewportView(jTextArea4); jLabel9.setText("Hash"); jTextField6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField6ActionPerformed(evt); } }); jButton8.setText("Signature"); jButton8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton8ActionPerformed(evt); } }); jButton9.setText("Generate Hash"); jButton9.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton9ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING)) .addComponent(jLabel7) .addGroup(layout.createSequentialGroup() .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))) .addGroup(layout.createSequentialGroup() .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))) .addGroup(layout.createSequentialGroup() .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(133, 133, 133) .addComponent(jButton2)) .addGroup(layout.createSequentialGroup() .addGap(38, 38, 38) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 74, Short.MAX_VALUE) .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE) .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(353, 353, 353)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jTextField3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE) .addComponent(jTextField5, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jTextField4, javax.swing.GroupLayout.Alignment.LEADING)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jTextField6, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE) .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 294, Short.MAX_VALUE))))) .addContainerGap()) .addGroup(layout.createSequentialGroup() .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE) .addGap(133, 133, 133) .addComponent(jButton7) .addGap(467, 467, 467)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel8) .addGap(375, 375, 375)) .addGroup(layout.createSequentialGroup() .addComponent(jButton9) .addContainerGap(681, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(jButton8) .addGap(144, 144, 144) .addComponent(jButton5) .addContainerGap(492, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(168, 168, 168) .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(498, 498, 498)))) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2) .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(64, 64, 64) .addComponent(jLabel5) .addGap(18, 18, 18)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(10, 10, 10))) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1) .addComponent(jButton2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton3) .addComponent(jButton7)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jButton9))) .addGap(10, 10, 10) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel9) .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton5) .addComponent(jButton8)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(25, 25, 25) .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(35, 35, 35)) .addGroup(layout.createSequentialGroup() .addGap(18, 18, 18) .addComponent(jScrollPane4, 0, 0, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton4) .addComponent(jButton6)) .addGap(41, 41, 41)) ); pack(); }// </editor-fold> private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: System.exit(0); setVisible(false); } private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: JDialog dialog = new JDialog(); LUAboutPanel about = new LUAboutPanel(); about.setApplicationName("LongRSA"); about.setApplicationVersion("2.0.0"); dialog.setContentPane(about); dialog.pack(); dialog.setVisible(true); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: int keyLength = Integer.parseInt(jTextField1.getText()); int keyCertainty = Integer.parseInt(jTextField2.getText()); Vector<BigInteger> keys = cryp.createKey(keyLength, keyCertainty); try { cryp.setKeyN((BigInteger) keys.elementAt(0)); cryp.setKeyE((BigInteger) keys.elementAt(1)); cryp.setKeyD((BigInteger) keys.elementAt(2)); jTextField3.setText(((BigInteger) keys.elementAt(0)).toString(16)); jTextField4.setText(((BigInteger) keys.elementAt(1)).toString(16)); jTextField5.setText(((BigInteger) keys.elementAt(2)).toString(16)); } catch (NumberFormatException e) { jTextField5.setText("Error: " + e.getMessage() + " --> please create again"); jTextField3.setText(""); jTextField4.setText(""); } } private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: setVisible(false); new Steganography_Controller(new Steganography_View("Steganography"),new Steganography()); setVisible(true); } private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: parent.decrypt(); } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: jTextField3.setText(""); jTextField4.setText(""); jTextField5.setText(""); } private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: input = jTextArea1.getText(); encrypt = crypter.Encode(input); jTextArea2.setText(encrypt); } private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: jTextArea1.setText(""); } private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: BufferedReader userInput = new BufferedReader (new InputStreamReader(System.in)); //String rawString=encrypt; String rawString = jTextArea2.getText(); JTextArea SHA11 = new JTextArea(); try { SHA11.toString(); // SHA11=AeSimpleSHA1.SHA1(rawString); jTextField6.setText(AeSimpleSHA1.SHA1(rawString)); // jTextField6.setText(SHA11); // JOptionPane.showMessageDialog(this,SHA11); } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void jTextField6ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Example().setVisible(true); } }); } // Variables declaration - do not modify public static javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JButton jButton5; private javax.swing.JButton jButton6; private javax.swing.JButton jButton7; private javax.swing.JButton jButton8; public static javax.swing.JButton jButton9; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane4; private javax.swing.JTextArea jTextArea1; private javax.swing.JTextArea jTextArea2; private javax.swing.JTextArea jTextArea4; private javax.swing.JTextField jTextField1; private javax.swing.JTextField jTextField2; private javax.swing.JTextField jTextField3; private javax.swing.JTextField jTextField4; private javax.swing.JTextField jTextField5; public javax.swing.JTextField jTextField6; // End of variables declaration }
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
Problem is that I want to use SHA11 variable declared in Example class in Steganography_Controller but it shows an error incompatible typeJava Code:package LongRSATest; /** * * @author Sanjog */ /* *Import List */ import java.io.File; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import javax.imageio.ImageIO; public class Steganography_Controller extends javax.swing.JFrame { //Program Variables private Steganography_View view; private Steganography model; //Panel Displays private JPanel decode_panel; private JPanel encode_panel; //Panel Variables public JTextArea input; private JButton encodeButton,decodeButton; private JLabel image_input; //Menu Variables private JMenuItem encode; private JMenuItem decode; private JMenuItem exit; //action event classes private Encode enc; private Decode dec; private EncodeButton encButton; private DecodeButton decButton; //decode variable private String stat_path = ""; private String stat_name = ""; public Example SHA11; public Example rawString; /* *Constructor to initialize view, model and environment variables *@param aView A GUI class, to be saved as view *@param aModel A model class, to be saved as model */ public Steganography_Controller(Steganography_View aView, Steganography aModel) { //program variables view = aView; model = aModel; //assign View Variables //2 views encode_panel = view.getTextPanel(); decode_panel = view.getImagePanel(); //2 data options input = view.getText(); image_input = view.getImageInput(); //2 buttons encodeButton = view.getEButton(); decodeButton = view.getDButton(); //menu encode = view.getEncode(); decode = view.getDecode(); exit = view.getExit(); //assign action events enc = new Encode(); encode.addActionListener(enc); dec = new Decode(); decode.addActionListener(dec); exit.addActionListener(new Exit()); encButton = new EncodeButton(); encodeButton.addActionListener(encButton); decButton = new DecodeButton(); decodeButton.addActionListener(decButton); //encode view as default encode_view(); } private JTextArea Example(Example SHA11) { throw new UnsupportedOperationException("Not yet implemented"); } /* *Updates the single panel to display the Encode View. */ private void encode_view() { update(); view.setContentPane(encode_panel); view.setVisible(true); } /* *Updates the single panel to display the Decode View. */ private void decode_view() { update(); view.setContentPane(decode_panel); view.setVisible(true); } /* *Encode Class - handles the Encode menu item */ private class Encode implements ActionListener { /* *handles the click event *@param e The ActionEvent Object */ public void actionPerformed(ActionEvent e) { encode_view(); //show the encode view } } /* *Decode Class - handles the Decode menu item */ private class Decode implements ActionListener { /* *handles the click event *@param e The ActionEvent Object */ public void actionPerformed(ActionEvent e) { decode_view(); //show the decode view //start path of displayed File Chooser JFileChooser chooser = new JFileChooser("./"); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); chooser.setFileFilter(new Image_Filter()); int returnVal = chooser.showOpenDialog(view); if (returnVal == JFileChooser.APPROVE_OPTION){ File directory = chooser.getSelectedFile(); try{ String image = directory.getPath(); stat_name = directory.getName(); stat_path = directory.getPath(); stat_path = stat_path.substring(0,stat_path.length()-stat_name.length()-1); stat_name = stat_name.substring(0, stat_name.length()-4); image_input.setIcon(new ImageIcon(ImageIO.read(new File(image)))); } catch(Exception except) { //msg if opening fails JOptionPane.showMessageDialog(view, "The File cannot be opened!","Error!", JOptionPane.INFORMATION_MESSAGE); } } } } /* *Exit Class - handles the Exit menu item */ private class Exit implements ActionListener { /* *handles the click event *@param e The ActionEvent Object */ public void actionPerformed(ActionEvent e) { System.exit(0); //exit the program } } /* *Encode Button Class - handles the Encode Button item */ private class EncodeButton implements ActionListener { /* *handles the click event *@param e The ActionEvent Object */ public void actionPerformed(ActionEvent e) { //start path of displayed File Chooser JFileChooser chooser = new JFileChooser("./"); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); chooser.setFileFilter(new Image_Filter()); int returnVal = chooser.showOpenDialog(view); if (returnVal == JFileChooser.APPROVE_OPTION){ File directory = chooser.getSelectedFile(); try{ String text = input.getText(); String ext = Image_Filter.getExtension(directory); String name = directory.getName(); String path = directory.getPath(); path = path.substring(0,path.length()-name.length()-1); name = name.substring(0, name.length()-4); String stegan = JOptionPane.showInputDialog(view,"Enter output file name:", "File name",JOptionPane.PLAIN_MESSAGE); if(model.encode(path,name,ext,stegan,text)) { JOptionPane.showMessageDialog(view, "The Image was encoded Successfully!", "Success!", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(view, "The Image could not be encoded!", "Error!", JOptionPane.INFORMATION_MESSAGE); } //display the new image decode_view(); image_input.setIcon(new ImageIcon(ImageIO.read(new File(path + "/" + stegan + ".png")))); } catch(Exception except) { //msg if opening fails JOptionPane.showMessageDialog(view, "The File cannot be opened!", "Error!", JOptionPane.INFORMATION_MESSAGE); } } } } /* *Decode Button Class - handles the Decode Button item */ private class DecodeButton implements ActionListener { /* *handles the click event *@param e The ActionEvent Object */ public void actionPerformed(ActionEvent e) { String message = model.decode(stat_path, stat_name); System.out.println(stat_path + ", " + stat_name); if(message != "") { encode_view(); JOptionPane.showMessageDialog(view, "The Image was decoded Successfully!","Success!", JOptionPane.INFORMATION_MESSAGE); input.setText(message); } else { JOptionPane.showMessageDialog(view, "The Image could not be decoded!","Error!", JOptionPane.INFORMATION_MESSAGE); } } } /* *Updates the variables to an initial state */ public void update() { input.setText(""); //clear textarea image_input.setIcon(null); //clear image stat_path = ""; //clear path stat_name = ""; //clear name } /* *Main Method for testing */ public static void main(String args[]) { new Steganography_Controller(new Steganography_View("Steganography"),new Steganography()); } private javax.swing.JTextArea jTextArea1; }Last edited by Eranga; 04-14-2010 at 03:41 PM. Reason: code tags added
- 04-14-2010, 03:42 PM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Please use code tags when you posting again here in the forum. Unformated codes are really hard to read. :)
- 04-14-2010, 03:43 PM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Seems you are using NetBeans for coding. If you cannot solve the problem by looking at the error message look at the suggestion, NetBeans may gives the suggestion for you.
- 04-15-2010, 02:38 AM #4
Member
- Join Date
- Apr 2010
- Posts
- 2
- Rep Power
- 0
thanks for your reponse ,yes i am using netbeans and that error is shown there,
- 04-15-2010, 03:00 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Can you send here on which line you got that error?
Similar Threads
-
JTextArea on PopUp -JTextArea isn't editable
By Richy76 in forum AWT / SwingReplies: 3Last Post: 02-01-2010, 07:51 PM -
Incompatible types
By coltragon in forum New To JavaReplies: 5Last Post: 01-15-2010, 04:47 PM -
using instanceof to get Object type and parent type?
By xcallmejudasx in forum New To JavaReplies: 2Last Post: 11-06-2008, 06:24 PM -
Incompatible magic value 1008821359
By willemjav in forum Java AppletsReplies: 2Last Post: 03-21-2008, 09:41 AM -
'Incompatible operand' fault
By fatnic388 in forum New To JavaReplies: 3Last Post: 12-01-2007, 07:05 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks