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.getSelec tedIndexes ();
for(int i=0;i<indexes.length;i++)
listOutput.select(indexes[ i]);
}
});
listOutput.addItemListener (new ItemListener(){
public void itemStateChanged(ItemEvent e){
int[] indexes=listOutput.getSele ctedIndexe s();
for(int i=0;i<indexes.length;i++)
listInput.select(indexes[i ]);
}
});
btnDel.addActionListener(n ew ActionListener(){
public void actionPerformed(ActionEven t e){
int[] index=listOutput.getSelect edIndexes( );
while(index.length>0){
listInput.remove(index[0]) ;
listOutput.remove(index[0] );
//after removing an item refresh the list
index=listOutput.getSelect edIndexes( );
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?
part of my program....
listInput.addItemListener(
public void itemStateChanged(ItemEvent
int[] indexes=listInput.getSelec
for(int i=0;i<indexes.length;i++)
listOutput.select(indexes[
}
});
listOutput.addItemListener
public void itemStateChanged(ItemEvent
int[] indexes=listOutput.getSele
for(int i=0;i<indexes.length;i++)
listInput.select(indexes[i
}
});
btnDel.addActionListener(n
public void actionPerformed(ActionEven
int[] index=listOutput.getSelect
while(index.length>0){
listInput.remove(index[0])
listOutput.remove(index[0]
//after removing an item refresh the list
index=listOutput.getSelect
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Why can't you upload multiple .class files? Perhaps you can put them all in a single .jar file and upload that?
ASKER
hello!
bcoz it say my filename have "$" so can upload those file with filename have"$"
what is .jar file?
thnx
bcoz it say my filename have "$" so can upload those file with filename have"$"
what is .jar file?
thnx
ASKER
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(t his);
.....
error occur: imcompatible type for method. Explicit cast needed to convert Analogue_3 to java.awt.event.ActionListe ner
i can't use:
if ( e.getSource().getClass().i sInstance( 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
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(t
.....
error occur: imcompatible type for method. Explicit cast needed to convert Analogue_3 to java.awt.event.ActionListe
i can't use:
if ( e.getSource().getClass().i
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{
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.
>> 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].to String());
}
catch (Throwable e) {
System.err.println(e);
}
}
}
Invoke this program with a class name like this:
java DumpMethods java.util.Stack
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].to
}
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!