Показать конкретный компонент экрана при поддержке - PullRequest
0 голосов
/ 26 мая 2018

У меня есть экран со списком компонентов.Когда я прокручиваю экран вниз, с помощью кнопки (например, 20-й компонент) перехожу к следующему экрану и возвращаюсь к предыдущему экрану с обратной клавишей btn, предыдущий экран (со списком компонентов) отображается там с первым компонентом.Как я могу показать экран с 20-м компонентом при поддержке?

Посмотрите видео здесь

Container mainContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS));
mainContainer.setScrollableY(true);
for (Map<String, Object> entrySet : protectedPlantsList) {
    String title = entrySet.get("title").toString();
    String sname = entrySet.get("sname").toString();
    String nname = entrySet.get("nname").toString();

    Label plantSpeciesLabel = new Label(title);
    TextArea family = new TextArea(sname);
    TextArea nepaliName = new TextArea(nname);
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    Button infoIcon1 = new Button("", "TextField");
    infoIcon1.addActionListener(e -> {
        new ThreatCategory(res, threatData1.getName(), infoIcon1.getName(), threatList).show();
    });
    mainContainer.add(BorderLayout.centerEastWest(plantSpeciesLabel, ...., .....));
}

Обновление 1 :

ProtectedPlantAndSpecies class:

Container mainContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS));
mainContainer.setScrollableY(true);
for (Map<String, Object> entrySet : protectedPlantsList) {
    String title = entrySet.get("title").toString();
    String sname = entrySet.get("sname").toString();
    String nname = entrySet.get("nname").toString();

    Label plantSpeciesLabel = new Label(title);
    TextArea family = new TextArea(sname);
    TextArea nepaliName = new TextArea(nname);
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    Button infoIcon1 = new Button("", "TextField");
    infoIcon1.addActionListener(e -> {
        Form myDestinationForm = new ThreatCategory(res, cat, cat_description, threatList);
        myDestinationForm.addShowListener(f -> infoIcon1.requestFocus());
        myDestinationForm.show();
    });
    mainContainer.add(BorderLayout.centerEastWest(plantSpeciesLabel, ...., .....));
}

ThreatCategory class:

- - - - - - - - - - - - - - - - - - - - - - - - - 
- - - - - - - - - - - - - - - - - - - - - - - - - 

Command backCommand = new Command("Back", backFontImage) {
    @Override
    public void actionPerformed(ActionEvent evt) {
        new ProtectedPlantAndSpecies(res, true).show();
    }
};

- - - - - - - - - - - - - - - - - - - - - - - - - 
- - - - - - - - - - - - - - - - - - - - - - - - - 

1 Ответ

0 голосов
/ 27 мая 2018

Сделайте что-то вроде этого:

Form hi = new Form("Last", BoxLayout.y());
Button t = new Button("Next");
hi.add(t);
t.addActionListener(e -> {
    Form f = new Form("Showing Last", BoxLayout.y());
    for(int iter = 0 ; iter < 20 ; iter++) {
        f.add(new Button("Button " + iter));
    }
    Button last = new Button("Last");
    f.add(last);
    f.addShowListener(ee -> last.requestFocus());
    f.show();
});

enter image description here

...