Answer the question
In order to leave comments, you need to log in
Am I approaching the problem correctly (Java class organization)?
Hello everyone, tell me if I'm approaching the solution of the problem correctly?
There is a left menu that can be FULLSIZE (text + icons + crap) and MINISIZE (icons)
I do have a main class (container) and nested blocks (inner classes), in one of the inner blocks there is a "Resize" button.
Pseudocode:
//Главный класс, контейнер для вложенных блоков
class LeftMenu {
Logo logo;
Menu menu;
LeftMenu context;
//Конструктор
{
this.context = this;
setWidth(200px)
logo = new Logo(); //Блок логотипа
menu = new Menu(); //Само меню
addComponent(logo,menu)
}
void changeSize(){
logo.changeSize();
menu.changeSize()
}
//Внутренние классы
class Logo implement ResizeInterface{
......
Button btnChangeWidth = new Button();
btnChangeWidth.addOnClickListener(e->context.changeSize())//Метод основного класса
@override
void changeSize(){
setWidth(50px)
}
}
class Menu implement ResizeInterface{
......
@override
void changeSize(){
setWidth(50px)
}
}
}
Answer the question
In order to leave comments, you need to log in
Overall, it looks reasonable.
{
context = this;
setWidth(200px)
logo = new Logo(); //Блок логотипа
menu = new Menu(); //Само меню
addComponent(logo,menu)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question