Package org.tools.ui

Examples of org.tools.ui.ButtonBar


                UIFrame frame = new StartScreen();
                frame.switchTo();
            }
        });

        ButtonBar bar = new ButtonBar();
        bar.add(newButton, loadButton, saveButton, exitButton);
        return bar.get();
    }
View Full Code Here


        // TODO load images
        JButton addnationButton = Button.SmallAdd.create();
        JButton removenationButton = Button.SmallDelete.create();
        JButton changenationButton = Button.SmallEdit.create();

        ButtonBar nbar = new ButtonBar();
        nbar.add(addnationButton, removenationButton, changenationButton);

        // list
        nationsList = new JList<>();
        nationsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

        nationsList.addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                boolean adjusting = e.getValueIsAdjusting();
                if (!adjusting) {
                    XList<Nation> model = (XList<Nation>) nationsList.getModel();
                    int row = nationsList.getSelectedIndex();
                    if (row != -1) {
                        Nation nation = model.getElementAt(row);
                        XList<Province> provinces = nation.getProvinces();
                        // TODO tell the province panel all about it
                        provinceList.setModel(provinces);
                    }
                }
            }
        });

        // set button actions
        addnationButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String name = FrameManager.getInstance().showInputDialog("Enter new Nation's name:");
                if (name != null) {
                    // TODO test if already existing
                    XList<Nation> model = (XList<Nation>) nationsList.getModel();
                    Nation nation = new Nation();
                    nation.setProperty(Nation.KEY_NAME, name);
                    model.addElement(nation);
                }
            }
        });
        removenationButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                int row = nationsList.getSelectedIndex();
                if (row != -1) {
                    // TODO are you sure?
                    XList<Nation> model = (XList<Nation>) nationsList.getModel();
                    model.removeElementAt(row);
                }
            }
        });
        changenationButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                int row = nationsList.getSelectedIndex();
                if (row != -1) {
                    // TODO implement
                }
            }
        });

        // scrollpane
        JScrollPane nationScrollPane = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        nationScrollPane.setViewportView(nationsList);

        // layout of nations panel
        panel.setLayout(new MigLayout("wrap 1, fill", "", "[][][grow]"));
        panel.add(nationsInfoLabel);
        panel.add(nbar.get());
        panel.add(nationScrollPane, "height 400!, width 300!");

        return panel;
    }
View Full Code Here

        // TODO load images
        JButton addprovinceButton = Button.SmallAdd.create();
        JButton removeprovinceButton = Button.SmallDelete.create();
        JButton changeprovinceButton = Button.SmallEdit.create();

        ButtonBar pbar = new ButtonBar();
        pbar.add(addprovinceButton, removeprovinceButton, changeprovinceButton);

        // list
        provinceList = new JList<>();
        provinceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        // provinceList.setModel(new XList<>(Province.class));

        // set button actions
        addprovinceButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String name = FrameManager.getInstance().showInputDialog("Enter new Province's name:");
                if (name != null) {
                    // TODO selectedNation could be null, setModel could not have been set, than this will fail
                    XList<Province> model = (XList<Province>) provinceList.getModel();
                    // TODO meaningful id
                    Province province = new Province(1, name);
                    model.addElement(province); // the model is the internal list
                }
            }
        });
        removeprovinceButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                int row = provinceList.getSelectedIndex();
                if (row != -1) {
                    // TODO implement
                }
            }
        });
        changeprovinceButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                int row = provinceList.getSelectedIndex();
                if (row != -1) {
                    // TODO implement
                }
            }
        });

        // ScrollPane
        JScrollPane provinceScrollPane = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        provinceScrollPane.setViewportView(provinceList);

        // layout of province panel
        panel.setLayout(new MigLayout("wrap 1, fill", "", "[][][grow]"));
        panel.add(provinceInfoLabel);
        panel.add(pbar.get());
        panel.add(provinceScrollPane, "height 500!, width 300!");

        return panel;
    }
View Full Code Here

                dialog.setLocation(p);
                dialog.start();
            }
        });

        ButtonBar bar = new ButtonBar();
        bar.add(terrainButton, provinceButton);

        infoPanel = new EditorMapInfoPanel();

        // create main map panel and add
        mainMapPanel = new MainMapPanel(scenario);
        mainMapPanel.addTileListener(new MapTileListener() {
            @Override
            public void focusChanged(MapPosition p) {
                infoPanel.update(p, scenario);
            }

            @Override
            public void tileClicked(MapPosition p) {
                if (selectedTerrain != null) {
                    scenario.setTerrainAt(p, selectedTerrain);
                }
            }
        });
        miniMapPanel.setFocusChangedListener(mainMapPanel);

        // set layout
        panel.setLayout(new MigLayout("wrap 2", "[][grow]", "[][][grow]"));
        panel.add(miniMapPanel, "width 200:300:, hmin 100");
        panel.add(mainMapPanel, "span 1 3, grow");
        panel.add(bar.get());
        panel.add(infoPanel, "grow");

        return panel;
    }
View Full Code Here

                }
            }
        });

        // add buttons to tool bar
        ButtonBar bar = new ButtonBar();
        bar.add(localScenarioButton, connectRemoteServerButton, disconnectRemoteServerButton);
        return bar.get();
    }
View Full Code Here

        // save button
        JButton saveButton = Button.ScenarioSave.create();

        // add buttons to toolbar
        ButtonBar ubar = new ButtonBar();
        ubar.add(saveButton, exitButton);

        // create mini map and add to panel
        miniMapPanel = new MiniMapPanel(scenario);
        miniMapPanel.setFocusChangedListener(mainMapPanel);


        ButtonBar lbar = new ButtonBar();
        for (final GamePanel p : GamePanel.values()) {
            JButton button = p.getButton();
            button.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    // TODO only if not active yet, otherwise just change
                    GameDialogBuilder.build(p);
                }
            });
            lbar.add(button);
        }

        // create info panel
        JPanel infoPanel = new JPanel();
        infoPanel.setBorder(BorderFactory.createLineBorder(Color.black, 1));

        JButton turnButton = new JButton("End Turn");
        turnButton.setFocusable(false);
        turnButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
            }
        });

        // layout
        panel.setLayout(new MigLayout("wrap 1, fill", "", "[][][][][grow][][]"));
        panel.add(infPanel, "growx");
        panel.add(ubar.get());
        panel.add(miniMapPanel, "growx"); // because the extra space goes here
        panel.add(lbar.get());
        panel.add(infoPanel, "grow");
        panel.add(turnButton, "growx, alignx center");
        panel.add(new ClockLabel(), "alignx center");

        return panel;
View Full Code Here

                // MainScreen frame = new MainScreen();
                // frame.switchTo(selectedScenario);
            }
        });

        ButtonBar bar = new ButtonBar();
        bar.add(startButton);

        return bar.get();
    }
View Full Code Here

TOP

Related Classes of org.tools.ui.ButtonBar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.