Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: how to fix?

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to fix?

                                                                                              import javax.swing.JTextField;
     
     
    public class code {
     
     
    	String new_code1 = "";
    	String new_code2 = "";
    	char[] alphabet;
    	final int NUM_ALPHA;
     
    	public void init(String new_code1, String new_code2)
    	{
    		this.new_code1=new_code1;
    		this.new_code2=new_code2;
    	}
     
    	public code()
    	{
     
     
     
     
    		char a = 122;
    		NUM_ALPHA = 26;
    		alphabet=new char[NUM_ALPHA];
    		for(int i1=0; i1<NUM_ALPHA; i1++)
    		{
    			alphabet[i1]= a--;
    		}	
    	}
     
    	public void code_make(JTextField textField1)
    	{
     
    		String textField11 = textField1.getText();
    		for(int i = 0; i < textField11.length(); i++) 
    		{
    			char ch = textField11.charAt(i);
    			int index = ch - 97;
    			if(index < 0)
    			{
    				new_code1 += ch;
    				}
    				else if (index > 25)
    				{
    					new_code1 += ch;
    				}
    			else
    			{
    				char new_ch = alphabet[index];
    				new_code1 += new_ch;
     
    			}
    		}
     
     
    	}
     
     
    	public void code_make_result_show(JTextField textField3)
    	{
    		textField3.setText(new_code1);
    	}
     
    	public void code_solve(JTextField textField2)
    	{
    		String textField22 = textField2.getText();
    		for(int i = 0; i < textField22.length();i++) 
    		{
    			char ch = textField22.charAt(i);
    			int index = ch - 97;
    			if(index < 0)
    			{
    				new_code2 += ch;
    			}
    			else if (index > 25)
    			{
    				new_code2 += ch;
    			}
    			else
    			{
    				char new_ch = alphabet[index];
    				new_code2 += new_ch;
     
    			}
    		}
    	}
     
    	public void code_solve_result_show(JTextField textField4)
    	{
    		textField4.setText(new_code2);
    	}
    }
     
     
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
     
    public abstract class Main implements ActionListener
    {
    	static code code=new code();
     
    	public static void main(String[] args) 
    	{
    		while(true)
    		{	
    			code.init("","");
    			JFrame  make =new JFrame("암호화");              //ignore "암호화" (it is Korean)
    			JFrame  solve =new JFrame("암호해석");           //ignore "암호해석" (it is Korean)
     
     
    			JButton btn1 = new JButton("make!");
    			JButton btn2 = new JButton("make!");
     
    			JTextField TextField1 = new JTextField();
    			JTextField TextField2 = new JTextField();
    			JTextField TextField3 = new JTextField();
    			JTextField TextField4 = new JTextField();
    			make.setBounds(120, 120, 300, 150);
    			solve.setBounds(420, 120, 300, 150);
    			make.setLayout(new GridLayout(2,3));
    			solve.setLayout(new GridLayout(2,3));
     
    			make.add(new JLabel("sentance:"));  make.add(TextField1); make.add(btn1);
    			make.add(new JLabel("code:"));      make.add(TextField3);
     
    			solve.add(new JLabel("code:"));     solve.add(TextField2); solve.add(btn2);
    			solve.add(new JLabel("sentance:")); solve.add(TextField4);
     
    			btn1.addActionListener(code.code_make(TextField1), code.code_make_result_show(TextField3));
    			btn2.addActionListener(code.code_solve(TextField2), code.code_solve_result_show(TextField4));
     
    			make.setVisible(true);
    			solve.setVisible(true);
     
    		}
    	}
    }
    error in these two(addActionListener) in Main class line 36,37
    "The method addActionListener(ActionListener) in the type AbstractButton is not applicable for the
    arguments (void, void)"
    Last edited by kai1107; April 1st, 2014 at 07:49 AM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: how to fix?

    Can you explain what the problem with the code is?

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: how to fix?

    The method addActionListener(ActionListener) in the type AbstractButton is not applicable for the arguments (void, void)"
    You need to read the API doc for that method and see what arguments it takes and then write the code to use the arguments as described in the doc.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] A little help please~~How should i fix it??
    By Li Yin in forum What's Wrong With My Code?
    Replies: 14
    Last Post: April 6th, 2012, 10:12 AM
  2. Can someone tell me how to fix this please
    By NewAtJava in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 9th, 2011, 10:51 AM
  3. Please help... Can somebody fix this for me?
    By Mini83 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 10th, 2011, 05:09 PM
  4. anyone know how to fix this ?
    By skyzred in forum Collections and Generics
    Replies: 7
    Last Post: June 22nd, 2011, 03:16 AM
  5. Please Help Me Fix
    By keygiwawah in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 25th, 2009, 03:37 AM