mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
optimize the code
This commit is contained in:
+2
-2
@@ -72,7 +72,7 @@ public class CloudBrowserFrame extends JFrame {
|
||||
@Override
|
||||
public void setVisible(boolean b) {
|
||||
super.setVisible(b);
|
||||
if (b) {
|
||||
if (b && !getSearchHeaderPanel().isInitialized()) {
|
||||
executeBackgroundTask(new ITask<Pair<String[], String[]>>() {
|
||||
|
||||
@Override
|
||||
@@ -88,7 +88,7 @@ public class CloudBrowserFrame extends JFrame {
|
||||
|
||||
@Override
|
||||
public void complete(Pair<String[], String[]> result) {
|
||||
getSearchHeaderPanel().updateLists(result.getFirst(), result.getSecond());
|
||||
getSearchHeaderPanel().initializeLists(result.getFirst(), result.getSecond());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+8
-5
@@ -23,6 +23,8 @@ public class SearchHeaderPanel extends JPanel {
|
||||
private JComboBox sortBox;
|
||||
private JButton goButton;
|
||||
|
||||
private boolean initialized = false;
|
||||
|
||||
public SearchHeaderPanel() {
|
||||
setLayout(new GridBagLayout());
|
||||
|
||||
@@ -65,13 +67,14 @@ public class SearchHeaderPanel extends JPanel {
|
||||
getSearchField().requestFocusInWindow();
|
||||
}
|
||||
|
||||
public void updateLists(String[] categories, String[] sortings) {
|
||||
Object selectedCategory = getCategoryBox().getSelectedItem();
|
||||
Object selectedSorting = getSortBox().getSelectedItem();
|
||||
public void initializeLists(String[] categories, String[] sortings) {
|
||||
getCategoryBox().setModel(new DefaultComboBoxModel(categories));
|
||||
getSortBox().setModel(new DefaultComboBoxModel(sortings));
|
||||
getCategoryBox().setSelectedItem(selectedCategory);
|
||||
getSortBox().setSelectedItem(selectedSorting);
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
return initialized;
|
||||
}
|
||||
|
||||
private JTextField getSearchField() {
|
||||
|
||||
Reference in New Issue
Block a user