Subversion Repositories mkgmap

Rev

Rev 576 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*
 * Copyright (C) 2007 Steve Ratcliffe
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as
 *  published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *
 * Author: Steve Ratcliffe
 * Create date: 13-Oct-2007
 */

package uk.me.parabola.mkgmap.gui;

import javax.swing.*;
import java.awt.*;
import java.util.ResourceBundle;

/**
 * @author Steve Ratcliffe
 */

public class Buttons {
        private JButton addFileButton;
        private JButton removeButton;

        {
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
                $$$setupUI$$$();
        }

        /**
         * Method generated by IntelliJ IDEA GUI Designer
         * >>> IMPORTANT!! <<<
         * DO NOT edit this method OR call it in your code!
         *
         * @noinspection ALL
         */

        private void $$$setupUI$$$() {
                final JPanel panel1 = new JPanel();
                panel1.setLayout(new GridBagLayout());
                addFileButton = new JButton();
                this.$$$loadButtonText$$$(addFileButton, ResourceBundle.getBundle("uk/me/parabola/mkgmap/gui/MainFileList").getString("button.add.file"));
                GridBagConstraints gbc;
                gbc = new GridBagConstraints();
                gbc.gridx = 0;
                gbc.gridy = 0;
                gbc.anchor = GridBagConstraints.WEST;
                panel1.add(addFileButton, gbc);
                removeButton = new JButton();
                removeButton.setText("Remove");
                gbc = new GridBagConstraints();
                gbc.gridx = 0;
                gbc.gridy = 1;
                gbc.fill = GridBagConstraints.HORIZONTAL;
                panel1.add(removeButton, gbc);
                final JPanel spacer1 = new JPanel();
                gbc = new GridBagConstraints();
                gbc.gridx = 0;
                gbc.gridy = 2;
                gbc.fill = GridBagConstraints.VERTICAL;
                panel1.add(spacer1, gbc);
        }

        /**
         * @noinspection ALL
         */

        private void $$$loadButtonText$$$(AbstractButton component, String text) {
                StringBuffer result = new StringBuffer();
                boolean haveMnemonic = false;
                char mnemonic = '\0';
                int mnemonicIndex = -1;
                for (int i = 0; i < text.length(); i++) {
                        if (text.charAt(i) == '&') {
                                i++;
                                if (i == text.length()) break;
                                if (!haveMnemonic && text.charAt(i) != '&') {
                                        haveMnemonic = true;
                                        mnemonic = text.charAt(i);
                                        mnemonicIndex = result.length();
                                }
                        }
                        result.append(text.charAt(i));
                }
                component.setText(result.toString());
                if (haveMnemonic) {
                        component.setMnemonic(mnemonic);
                        component.setDisplayedMnemonicIndex(mnemonicIndex);
                }
        }
}