Files
VisualSapfor/src/Common/Visual/ControlForm.java
2024-10-14 15:19:13 +03:00

53 lines
1.7 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package Common.Visual;
import Common.Utils.Utils_;
import javax.swing.*;
import java.awt.*;
//класс, представляющий собой прокручиваемую панель, на которой лежит нечто.
public class ControlForm<C extends Component> {
public C control = null;
public JScrollPane scroll = null;
protected Class<C> control_class;
protected JPanel content; //задник.
public ControlForm(Class<C> class_in) {
control_class = class_in;
setContent(new JPanel(new BorderLayout()));
}
//нужно будет вывестии сделать нормальные формы для деревьев а не ручное создание.
public JPanel getContent() {
return content;
}
public void setContent(JPanel content_in) {
content = content_in;
}
//-
public void Show() {
Clear();
CreateControl();
//------------------------
scroll = new JScrollPane(control);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
}
public void CreateControl() {
try {
control = control_class.newInstance();
} catch (Exception e) {
Utils_.MainLog.PrintException(e);
}
}
public boolean isShown() {
return control != null;
}
public void Clear() {
control = null; //очищено.
}
public void Refresh() {
if (control != null)
refresh();
}
//-
protected void refresh() {
} //перерисовать контрол.
}