i have swing-ui sub panel contains list of persons (within scroll pane). each person represented jpanel consists of imageicon , 4 jlabels.
the list behaves circular buffer (with additional conditional behavior) , can changed via 2 buttons can 'rotate' list , forth.
e.g. forward: [a][b][c][d] -> [b][c][d][a]
it contains around 15 persons, yet can added , removed within part of ui - calls update on panel well.
my current solution remove elements scroll pane-panel , re-add elements (in new order) after user has clicked on 1 of buttons.
unfortunately takes quite lot of time. imageicons cached - person-jpanels if person in list before, part takes time re-adding of said elements.
so question if done in more efficient way.
my current solution remove elements scroll pane-panel , re-add elements
the container
api has method allows add component @ location in panel. remove panel end , place @ start, basic logic like:
jpanel removed = panel.getcomponent( panel.getcomponentcount() - 1); panel.remove(removed); panel.add(removed, 0); panel.revalidate(); panel.repaint();
Comments
Post a Comment