You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
945 B
Java
41 lines
945 B
Java
4 years ago
|
package main;
|
||
|
|
||
|
import java.awt.Container;
|
||
|
import java.io.IOException;
|
||
|
import java.io.ObjectInputStream;
|
||
|
|
||
|
import javax.swing.JSlider;
|
||
|
import javax.swing.JTextField;
|
||
|
|
||
|
public class OpenClassIterator {
|
||
|
|
||
|
public OpenClassIterator(Container c, ObjectInputStream in){
|
||
|
|
||
|
if (c.getClass() == new JTextField().getClass()){
|
||
|
try {
|
||
|
((JTextField) c).setText((String) in.readObject());
|
||
|
} catch (IOException e) {
|
||
|
// TODO Auto-generated catch block
|
||
|
e.printStackTrace();
|
||
|
} catch (ClassNotFoundException e) {
|
||
|
// TODO Auto-generated catch block
|
||
|
e.printStackTrace();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
else if (c.getClass() == new JSlider().getClass()){
|
||
|
try {
|
||
|
((JSlider) c).setValue(in.readInt());
|
||
|
} catch (IOException e) {
|
||
|
// TODO Auto-generated catch block
|
||
|
e.printStackTrace();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
for (int i = 0; i < c.getComponentCount(); i++){
|
||
|
OpenClassIterator oCI = new OpenClassIterator((Container) c.getComponent(i),in);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|