Package megamek.client.ui.AWT.widget

Examples of megamek.client.ui.AWT.widget.ImageButton


        choTeam = new Choice();
        setupTeams();
        choTeam.addItemListener(this);

        butCamo = new ImageButton();
        butCamo.setLabel(Messages.getString("ChatLounge.noCamo")); //$NON-NLS-1$
        butCamo.setPreferredSize(84, 72);
        butCamo.setActionCommand("camo"); //$NON-NLS-1$
        butCamo.addActionListener(this);
        camoDialog.addItemListener(new CamoChoiceListener(camoDialog, butCamo,
View Full Code Here


        panel.add(new AdvancedLabel(Messages
                .getString("CamoChoiceDialog.keep_old_camo")), layout); //$NON-NLS-1$
        layout.gridy++;

        // Create the "keep old camo" button.
        keep = new ImageButton();
        keep.setLabel(Messages.getString("CamoChoiceDialog.no_camo")); //$NON-NLS-1$
        keep.setPreferredSize(84, 72);
        keep.addActionListener(new ActionListener() {
            // Pressing this button closes without saving.
            public void actionPerformed(ActionEvent event) {
                close();
            }
        });
        keep.addKeyListener(new KeyAdapter() {
            public void keyPressed(KeyEvent event) {
                // Pressing enter on this button closes without saving.
                if (KeyEvent.VK_ENTER == event.getKeyCode()) {
                    close();
                }
            }
        });
        panel.add(keep, layout);
        layout.gridy++;

        // Add a label for the "select new camo" button.
        panel.add(new AdvancedLabel(Messages
                .getString("CamoChoiceDialog.select_new_camo")), layout); //$NON-NLS-1$
        layout.gridy++;

        // Create the "select new camo" button.
        select = new ImageButton();
        select.setLabel(Messages.getString("CamoChoiceDialog.no_camo")); //$NON-NLS-1$
        select.setPreferredSize(84, 72);
        select.addActionListener(this);
        panel.add(select, layout);
View Full Code Here

                    .getString("MegaMek.ScenarioDialog.otherh")); //$NON-NLS-1$
            m_typeChoices[x].add(Messages
                    .getString("MegaMek.ScenarioDialog.bot")); //$NON-NLS-1$
            final Color defaultBackground = m_typeChoices[x].getBackground();

            m_camoButtons[x] = new ImageButton();
            final ImageButton curButton = m_camoButtons[x];
            curButton.setLabel(Messages.getString("MegaMek.NoCamoBtn")); //$NON-NLS-1$
            curButton.setPreferredSize(84, 72);
            curButton.setBackground(PlayerColors.getColor(x));
            curButton.setActionCommand("camo"); //$NON-NLS-1$

            // When a camo button is pressed, remove any previous
            // listener from the dialog, update the dialog for the
            // button's player, and add a new listener.
            curButton.addActionListener(new ActionListener() {
                private final CamoChoiceDialog dialog = camoDialog;
                private final ImageButton button = curButton;
                private final Color background = defaultBackground;
                private final Player player = curPlayer;
View Full Code Here

                System.exit(0);
            }
        });

        // Display an image button to show the camo selection dialog.
        camo = new ImageButton();
        camo.setLabel("Choose...");
        camo.setPreferredSize(84, 72);
        camo.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                dialog.setVisible(true);
            }
        });
        camo.addKeyListener(new KeyAdapter() {
            public void keyPressed(KeyEvent event) {
                if (KeyEvent.VK_ENTER == event.getKeyCode()) {
                    dialog.setVisible(true);
                }
            }
        });
        frame.add(camo);

        // Construct a dialog.
        dialog = new Dialog(frame, "Choose a pattern", true);
        dialog.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                dialog.setVisible(false);
            }
        });

        // Create a main panel for the dialog.
        Panel main = new Panel();
        main.setLayout(new BorderLayout());
        dialog.add(main);

        // Create a list as the center of the dialog.
        list = new List(5);
        list.add("data/images/camo/Wood1.jpg");
        list.add("data/images/camo/Wood2.jpg");
        list.add("data/images/camo/Urban.jpg");
        list.add("data/images/camo/Winter.jpg");
        list.select(0);
        list.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent event) {
                imgButton.setImage(Toolkit.getDefaultToolkit()
                        .getImage(
                                (String) event.getItemSelectable()
                                        .getSelectedObjects()[0]));
            }
        });
        list.addKeyListener(new KeyAdapter() {
            public void keyPressed(KeyEvent event) {
                if (KeyEvent.VK_ENTER == event.getKeyCode()
                        || KeyEvent.VK_SPACE == event.getKeyCode()) {
                    Dimension size = imgButton.getPreferredSize();
                    camo.setBackground(imgButton.getBackground());
                    camo.setLabel(imgButton.getLabel());
                    camo.setImage(imgButton.getImage().getScaledInstance(
                            size.width, size.height, Image.SCALE_FAST));
                    dialog.setVisible(false);
                }
            }
        });
        main.add(list, BorderLayout.CENTER);

        // Create a panel for the buttons.
        Panel panel = new Panel();
        panel.setLayout(new GridLayout(0, 1));
        dialog.add(panel, BorderLayout.EAST);

        // Create a "camo" button on the panel.
        imgButton = new ImageButton();
        imgButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                Dimension size = imgButton.getPreferredSize();
                camo.setBackground(imgButton.getBackground());
                camo.setLabel(imgButton.getLabel());
View Full Code Here

        dialog = new CamoChoiceDialog(this);
        dialog.addItemListener(this);
        dialog.setCategory("flashhawk2k.zip");
        dialog.setItemName("camo1.jpg");

        butCamo = new ImageButton();
        Image[] array = (Image[]) dialog.getSelectedObjects();
        if (null != array)
            butCamo.setImage(array[0]);
        butCamo.setLabel("Choose Camo...");
        butCamo.setPreferredSize(84, 72);
View Full Code Here

TOP

Related Classes of megamek.client.ui.AWT.widget.ImageButton

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.