Я хотел бы знать, как можно скопировать объект в Java. Но я имею в виду копирования без реализации Клонируемого интерфейса, но копировать уже существующий объект со всеми содержит другие объекты, например:Как скопировать нераскрытый объект?
JEditorPane editorOryginal = new JEditorPane();
editorOryginal.addFocusListener(new FocusAdapter() {});
editorOryginal.setText("Hello World!");
// ...... other setter and other listeners etc ..
JEditorPane editorCopy = editorOryginal // now i only copy reference to editorOryginal
//but i would like to get copy of object:
JEditorPane editorCopy = editorOryginal.getCopyInstance();
editorOryginal.destroy(); // in JEditorPane this method not exists but we assume existing this method
editorCopy.something(); // here i have my copy but oryginal has been destroyed
поиск модели/XxxEditorKit – mKorbel
, но мне нужно все не только EditorKit, компоненты, слушатели и т.д .. –
Посмотрите на [Java глубокое клонирование] (http://code.google.com/p/cloning/) – Narmer