Link to home
Start Free TrialLog in
Avatar of bhuey_ling
bhuey_ling

asked on

how to split few classes in file to few files

hello!....
part of  my program....

listInput.addItemListener(new ItemListener(){
     public void itemStateChanged(ItemEvent e){
        int[] indexes=listInput.getSelectedIndexes();
        for(int i=0;i<indexes.length;i++)
           listOutput.select(indexes[i]);
        }
      });
      
    listOutput.addItemListener(new ItemListener(){
      public void itemStateChanged(ItemEvent e){
        int[] indexes=listOutput.getSelectedIndexes();
      for(int i=0;i<indexes.length;i++)
           listInput.select(indexes[i]);
      }
    });

    btnDel.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){
       int[] index=listOutput.getSelectedIndexes();
      while(index.length>0){
          listInput.remove(index[0]);
        listOutput.remove(index[0]);
        //after removing an item refresh the list
        index=listOutput.getSelectedIndexes();  
        listLen();
      }
      }
    });

as i compile ,let say my filename KK, it will have few class file name KK$1.calss, KK$2.class and KK$3.class

it make me can't upload my file to internet...

How to split it in order no more $ appear?
ASKER CERTIFIED SOLUTION
Avatar of Jod
Jod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jan Louwerens
Why can't you upload multiple .class files? Perhaps you can put them all in a single .jar file and upload that?
Avatar of bhuey_ling
bhuey_ling

ASKER

hello!

bcoz it say my filename have "$" so can upload those file with filename have"$"

what is .jar file?

thnx
Jod..
hello!

i had been tried but have few problem:
this is part of my program:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class Analogue_3 extends Applet{
......
btnDel.addActionListener(this);
.....
 
error occur: imcompatible type for method. Explicit cast needed to convert Analogue_3 to java.awt.event.ActionListener

i can't use:
if ( e.getSource().getClass().isInstance(listInput.Class) ) {
bcoz error occur that not class method in List
so i change to:

if ( e.getSource()==listInput){...}

it have no compile error but i dun know it can run or not because can't "appletviewer" yet........

thnx
replace
public class Analogue_3 extends Applet{

with
public class Analogue_3 extends Applet implements ItemListener, ActionListener{

Sorry I should have explained in full. When I said

>> You can avoid it by making your main class the listener and doing this...

I meant what hethey_ has said above. So use...

public class Analogue_3 extends Applet implements ItemListener, ActionListener{

Just out of interest, have you tried renaming the files to KK_1.class, upload them all and then renaming them back? Packaging them in a jar file could also help, but you need to ensure that the ja tool actually includes the relevant inner classes - it won't neccesarily find them automatically unless you specifically mention them.
Here is another example from Sun...

import java.lang.reflect.*;

public class DumpMethods {
  public static void main(String args[])
  {
    try {
      Class c = Class.forName(args[0]);
      Method m[] = c.getDeclaredMethods();
      for (int i = 0; i < m.length; i++)
        System.out.println(m[i].toString());            
    }
             
    catch (Throwable e) {
      System.err.println(e);
    }
  }
}


Invoke this program with a class name like this:

java DumpMethods java.util.Stack

Sorry, posted that in the wrong place....doh!