Example usage for javax.swing BorderFactory createBevelBorder

List of usage examples for javax.swing BorderFactory createBevelBorder

Introduction

In this page you can find the example usage for javax.swing BorderFactory createBevelBorder.

Prototype

public static Border createBevelBorder(int type) 

Source Link

Document

Creates a beveled border of the specified type, using brighter shades of the component's current background color for highlighting, and darker shading for shadows.

Usage

From source file:hermes.browser.dialog.EditNamingConfigDialog.java

public JComponent createContentPanel() {
    topPanel.setLayout(new BorderLayout());
    topPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));

    comboBox = new JComboBox(createComboBoxModel());

    comboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doSelectionChanged();/*  ww  w  . j a v a  2  s.c  om*/
        }
    });

    topPanel.add(comboBox, BorderLayout.NORTH);
    topPanel.add(scrollPane, BorderLayout.CENTER);

    comboBox.setSelectedItem(selectedConfig);

    return topPanel;
}

From source file:be.ac.ua.comp.scarletnebula.gui.ServerCellRenderer.java

private JPanel createServerPanel(final Server server, final JList list, final int index,
        final boolean isSelected) {
    final JXPanel p = new JXPanel();
    p.setLayout(new GridBagLayout());
    final Color background = Colors.alpha(getBackgroundColor(list, index, isSelected), 0.4f);

    p.setBackground(background);/*from w  ww.  ja  va 2 s.co m*/

    Color color1 = Colors.White.color(0.5f);
    Color color2 = Colors.Gray.color(0.95f);

    final Point2D start = new Point2D.Float(0, 0);
    Point2D stop = new Point2D.Float(150, 500);

    if (server != null && !server.sshWillFail() && server.getServerStatistics() != null) {
        final ServerStatisticsManager manager = server.getServerStatistics();
        final Datastream.WarnLevel warnlevel = manager.getHighestWarnLevel();

        if (warnlevel == Datastream.WarnLevel.HIGH) {
            color1 = Colors.Red.alpha(0.2f);
            color2 = Colors.Red.alpha(0.8f);
            stop = new Point2D.Float(500, 2);
        } else if (warnlevel == Datastream.WarnLevel.MEDIUM) {
            color1 = Colors.Orange.alpha(0.3f);
            color2 = Colors.Orange.alpha(0.8f);
            stop = new Point2D.Float(500, 2);
        } else if (warnlevel == Datastream.WarnLevel.LOW) {
            color1 = Colors.Orange.alpha(0.2f);
            color2 = Colors.Orange.alpha(0.4f);
            stop = new Point2D.Float(500, 2);
        }
    }

    final LinearGradientPaint gradientPaint = new LinearGradientPaint(start, stop, new float[] { 0.0f, 1.0f },
            new Color[] { color1, color2 });
    final MattePainter mattePainter = new MattePainter(gradientPaint, true);
    p.setBackgroundPainter(mattePainter);

    if (isSelected) {
        p.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createLineBorder(UIManager.getColor("List.background"), 2),
                BorderFactory.createBevelBorder(BevelBorder.LOWERED)));
    } else {
        p.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createLineBorder(UIManager.getColor("List.background"), 2),
                BorderFactory.createEtchedBorder()));

    }

    return p;
}

From source file:de.codesourcery.eve.skills.ui.utils.CalendarWidget.java

protected void setup() {

    // draw heading
    for (int x = 0; x < 7; x++) {
        final String day = getWeekDayName(getDateFor(x, 0));
        final JLabel label = new JLabel(day, JLabel.CENTER);
        label.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
        label.setOpaque(true);/*w w w . j a v  a  2  s.c  o  m*/
        add(label, new ConstraintsBuilder(x, 0).resizeHorizontally().weightY(0).end());
    }

    // draw 4x7 buttons
    for (int y = 0; y < 4; y++) {
        for (int x = 0; x < 7; x++) {
            buttons[y][x] = new MyButton(x, y);
            add(buttons[y][x], new ConstraintsBuilder(x, 1 + y).end());
        }
    }
}

From source file:gtu._work.etc.EnglishTester.java

private void initGUI() {
    try {/*  w w w.  j a  v a 2 s.  co  m*/
        JCommonUtil.defaultToolTipDelay();
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            jTabbedPane1.setPreferredSize(new java.awt.Dimension(462, 259));

            jTabbedPane1.addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent evt) {
                    // XXX
                    // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
                    jTabbedPane1.requestFocus();// FOCUS TODO
                    // XXX
                    // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
                }
            });
            jTabbedPane1.addKeyListener(new KeyAdapter() {
                public void keyPressed(KeyEvent evt) {
                    System.out.println("2===" + evt.getKeyCode());
                    if (evt.getKeyCode() == 49) {// 0
                        jTabbedPane1.setSelectedIndex(0);
                    }
                    if (evt.getKeyCode() == 50) {// 1
                        jTabbedPane1.setSelectedIndex(1);
                    }
                    if (evt.getKeyCode() == 10) {// enter
                        skipBtnAction();
                    }
                    if (evt.getKeyCode() == 32) {// 
                        removeBtnAction();
                    }
                }
            });
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("english", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(420, 141));
                    {
                        englishArea = new JTextArea();
                        jScrollPane1.setViewportView(englishArea);
                        englishArea.setFont(new java.awt.Font("Microsoft JhengHei", 0, 22));
                    }
                }
                {
                    jPanel5 = new JPanel();
                    jPanel1.add(jPanel5, BorderLayout.SOUTH);
                    jPanel5.setPreferredSize(new java.awt.Dimension(402, 65));
                    {
                        skipBtn = new JButton();
                        jPanel5.add(skipBtn);
                        skipBtn.setText("skip");
                        skipBtn.setPreferredSize(new java.awt.Dimension(187, 24));
                        skipBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                skipBtnAction();
                            }
                        });
                    }
                    {
                        removeBtn = new JButton();
                        jPanel5.add(removeBtn);
                        removeBtn.setText("remove");
                        removeBtn.setPreferredSize(new java.awt.Dimension(180, 24));
                        removeBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                removeBtnAction();
                            }
                        });
                    }
                    {
                        questionCountLabel = new JLabel();
                        jPanel5.add(questionCountLabel);
                        questionCountLabel.setPreferredSize(new java.awt.Dimension(47, 21));
                        questionCountLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
                        questionCountLabel.setToolTipText("");
                    }
                    {
                        propCountLabel = new JLabel();
                        jPanel5.add(propCountLabel);
                        propCountLabel.setPreferredSize(new java.awt.Dimension(45, 21));
                        propCountLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
                        propCountLabel.setToolTipText("");
                    }
                    {
                        googleSearchBtn = new JButton();
                        jPanel5.add(googleSearchBtn);
                        googleSearchBtn.setText("<html>GPic</html>");
                        googleSearchBtn.setPreferredSize(new java.awt.Dimension(58, 24));
                        googleSearchBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                try {
                                    String word = currentWordIndex.trim();
                                    ClipboardUtil.getInstance().setContents(word);
                                    word = word.replace(" ", "%20");
                                    URI uri = new URI(
                                            "https://www.google.com.tw/search?num=10&hl=zh-TW&site=imghp&tbm=isch&source=hp&biw=1280&bih=696&q="
                                                    + word);
                                    //URI uri = new URI("http://image.baidu.com/search/index?tn=baiduimage&ps=1&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=" + word);
                                    Desktop.getDesktop().browse(uri);
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        });
                    }
                    {
                        yahooDicBtn = new JButton();
                        jPanel5.add(yahooDicBtn);
                        yahooDicBtn.setText("<html>Dict</html>");
                        yahooDicBtn.setPreferredSize(new java.awt.Dimension(57, 24));
                        yahooDicBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                try {
                                    // URI uri = new
                                    // URI("http://tw.dictionary.yahoo.com/dictionary?p="
                                    // + currentWord.trim());
                                    URI uri = new URI("http://www.dreye.com/axis/ddict.jsp?ver=big5&dod=0102&w="
                                            + currentWordIndex.trim() + "&x=0&y=0");
                                    Desktop.getDesktop().browse(uri);
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        });
                    }
                    {
                        pickBtn = new JButton();
                        jPanel5.add(pickBtn);
                        pickBtn.setText("<html>+Pick</html>");
                        pickBtn.setPreferredSize(new java.awt.Dimension(60, 24));
                        pickBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                try {
                                    String key = currentWordIndex;
                                    String value = englishProp.getProperty(currentWordIndex);
                                    if (StringUtils.isEmpty(value)) {
                                        JCommonUtil._jOptionPane_showMessageDialog_error(
                                                "add pick failed : no such word => " + key);
                                    } else {
                                        pickProp.setProperty(key, value);
                                        JCommonUtil._jOptionPane_showMessageDialog_info(
                                                "key=" + key + "\nvalue=" + value + "\nsize=" + pickProp.size(),
                                                "??");
                                    }
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        });
                    }
                    {
                        scanPicBtn = new JButton();
                        scanPicBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                            }
                        });
                        jPanel5.add(scanPicBtn);
                        scanPicBtn.setPreferredSize(new java.awt.Dimension(46, 24));
                        scanPicBtn.addMouseListener(new MouseAdapter() {

                            public void mouseClicked(MouseEvent evt) {
                                if (picDir == null) {
                                    JCommonUtil._jOptionPane_showMessageDialog_error("picDir is null");
                                    return;
                                }

                                if (picSet != null && picSet.size() > 0) {
                                    try {
                                        Desktop.getDesktop().open(picSet.iterator().next());
                                    } catch (IOException e) {
                                        JCommonUtil.handleException(e);
                                    }
                                    return;
                                }

                                try {
                                    String text = currentWordIndex.trim().toLowerCase();
                                    ClipboardUtil.getInstance().setContents(text);
                                    text = text.replace(" ", "%20");
                                    URI uri = new URI(
                                            "https://www.google.com.tw/search?num=10&hl=zh-TW&site=imghp&tbm=isch&source=hp&biw=1280&bih=696&q="
                                                    + text);
                                    //URI uri = new URI("http://image.baidu.com/search/index?tn=baiduimage&ps=1&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=" + text);
                                    Desktop.getDesktop().browse(uri);
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        });
                    }
                    {
                        showChineseOption = new JCheckBox();
                        showChineseOption.setSelected(true);
                        jPanel5.add(showChineseOption);
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("chinese", null, jPanel2, null);
                jPanel2.setPreferredSize(new java.awt.Dimension(420, 211));
                {
                    showEnglishText = new JTextField();
                    jPanel2.add(showEnglishText, BorderLayout.NORTH);
                    showEnglishText.setEditable(false);
                }
                {
                    jPanel10 = new JPanel();
                    jPanel2.add(jPanel10, BorderLayout.CENTER);
                }
                {
                    answerBtn[0] = new JButton();
                    jPanel10.add(answerBtn[0]);
                    answerBtn[0].setPreferredSize(new java.awt.Dimension(190, 110));
                    answerBtn[0].addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            answerBtnClick(answerBtn[0]);
                        }
                    });
                }
                {
                    answerBtn[1] = new JButton();
                    jPanel10.add(answerBtn[1]);
                    answerBtn[1].setPreferredSize(new java.awt.Dimension(190, 110));
                    answerBtn[1].addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            answerBtnClick(answerBtn[1]);
                        }
                    });
                }
                {
                    answerBtn[2] = new JButton();
                    jPanel10.add(answerBtn[2]);
                    answerBtn[2].setPreferredSize(new java.awt.Dimension(190, 110));
                    answerBtn[2].addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            answerBtnClick(answerBtn[2]);
                        }
                    });
                }
                {
                    answerBtn[3] = new JButton();
                    jPanel10.add(answerBtn[3]);
                    answerBtn[3].setPreferredSize(new java.awt.Dimension(190, 110));
                    answerBtn[3].addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            answerBtnClick(answerBtn[3]);
                        }
                    });
                }
                {
                    for (int ii = 0; ii < 4; ii++) {
                        answerBtn[ii].setFont(new java.awt.Font("", 0, 14));
                    }
                }
            }
            {
                jPanel3 = new JPanel();
                BorderLayout jPanel3Layout = new BorderLayout();
                jPanel3.setLayout(jPanel3Layout);
                jTabbedPane1.addTab("word", null, jPanel3, null);
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel3.add(jScrollPane3, BorderLayout.CENTER);
                    jScrollPane3.setPreferredSize(new java.awt.Dimension(420, 187));
                    {
                        propTable = new JTable();
                        jScrollPane3.setViewportView(propTable);
                        JTableUtil.defaultSetting(propTable);
                        propTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                JPopupMenuUtil.newInstance(propTable)
                                        .addJMenuItem(JTableUtil.newInstance(propTable).getDefaultJMenuItems())
                                        .applyEvent(evt).show();
                            }
                        });
                    }
                }
                {
                    saveBtn = new JButton();
                    jPanel3.add(saveBtn, BorderLayout.SOUTH);
                    saveBtn.setText("save table");
                    saveBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            DefaultTableModel model = JTableUtil.newInstance(propTable).getModel();
                            for (int ii = 0; ii < model.getRowCount(); ii++) {
                                String key = (String) model.getValueAt(ii, 0);
                                String value = (String) model.getValueAt(ii, 1);
                                if (!englishProp.containsKey(key)) {
                                    englishProp.setProperty(key, value);
                                }
                            }
                            try {
                                englishProp.store(new FileOutputStream(englishFile), "comment");
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            JCommonUtil._jOptionPane_showMessageDialog_info("save file ok!  \n" + englishFile);
                        }
                    });
                }
                {
                    queryText = new JTextField();
                    jPanel3.add(queryText, BorderLayout.NORTH);
                    queryText.getDocument()
                            .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() {
                                @Override
                                public void process(DocumentEvent event) {
                                    String text = JCommonUtil.getDocumentText(event);
                                    Pattern pattern = Pattern.compile(text);
                                    Matcher matcher = null;
                                    DefaultTableModel propTableModel = JTableUtil.createModel(false, "english",
                                            "chinese");
                                    for (Enumeration<?> enu = englishProp.propertyNames(); enu
                                            .hasMoreElements();) {
                                        String key = (String) enu.nextElement();
                                        String value = englishProp.getProperty(key);
                                        if (key.contains(text)) {
                                            propTableModel.addRow(new Object[] { key, value });
                                            continue;
                                        }
                                        matcher = pattern.matcher(key);
                                        if (matcher.find()) {
                                            propTableModel.addRow(new Object[] { key, value });
                                            continue;
                                        }
                                    }
                                    propTable.setModel(propTableModel);
                                }
                            }));
                }
            }
            {
                jPanel4 = new JPanel();
                jTabbedPane1.addTab("config", null, jPanel4, null);
                {
                    savePickBtn = new JButton();
                    jPanel4.add(savePickBtn);
                    savePickBtn.setText("save pick");
                    savePickBtn.setPreferredSize(new java.awt.Dimension(116, 40));
                    savePickBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            if (englishFile == null) {
                                File file = new File(//
                                        PropertiesUtil.getJarCurrentPath(EnglishTester.class),
                                        "temp.properties");
                                englishFile = file;
                            }
                            if (pickProp.isEmpty()) {
                                JCommonUtil._jOptionPane_showMessageDialog_error("?!");
                                return;
                            }
                            String fileName = englishFile.getName().replaceAll("\\.properties",
                                    "_bak.properties");
                            File jarWhereFile = PropertiesUtil.getJarCurrentPath(EnglishTester.class);
                            fileName = JCommonUtil._jOptionPane_showInputDialog("save target properties",
                                    fileName);
                            if (StringUtils.isEmpty(fileName)) {
                                JCommonUtil._jOptionPane_showMessageDialog_error("can't save!");
                                return;
                            }
                            if (fileName.equalsIgnoreCase(englishFile.getName())) {
                                JCommonUtil._jOptionPane_showMessageDialog_error(
                                        "??englishFile???");
                                return;
                            }
                            if (!fileName.endsWith(".properties")) {
                                fileName += ".properties";
                            }
                            File newFile = new File(jarWhereFile, fileName);
                            Properties oldProp = new Properties();
                            if (newFile.exists()) {
                                try {
                                    oldProp.load(new FileInputStream(newFile));
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                            oldProp.putAll(pickProp);
                            try {
                                oldProp.store(new FileOutputStream(newFile), "comment");
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            JCommonUtil._jOptionPane_showMessageDialog_info("save file ok!  \n" + newFile);
                        }
                    });
                }
                {
                    saveConfigBtn2 = new JButton();
                    jPanel4.add(saveConfigBtn2);
                    saveConfigBtn2.setText("save config");
                    saveConfigBtn2.setPreferredSize(new java.awt.Dimension(108, 40));
                    saveConfigBtn2.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            saveConfigBtnAction();
                        }
                    });
                }
                {
                    startAllBtn = new JButton();
                    jPanel4.add(startAllBtn);
                    startAllBtn.setText("start all");
                    startAllBtn.setPreferredSize(new java.awt.Dimension(101, 40));
                    startAllBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            Object[] files = fileList.getSelectedValues();
                            if (files == null || files.length == 0) {
                                JCommonUtil
                                        ._jOptionPane_showMessageDialog_error("?properties");
                                return;
                            }
                            Properties allProp = new Properties();
                            Properties prop = new Properties();
                            for (Object ff : files) {
                                try {
                                    prop.load(new FileInputStream((File) ff));
                                } catch (Exception e) {
                                    JCommonUtil.handleException(e);
                                }
                                allProp.putAll(prop);
                            }
                            englishProp = allProp;
                            System.out.println("englishProp = " + englishProp.size());
                            startNow();
                        }
                    });
                }
                {
                    startNow = new JButton();
                    jPanel4.add(startNow);
                    startNow.setText("start now");
                    startNow.setPreferredSize(new java.awt.Dimension(101, 40));

                    startNow.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            startNow();
                        }
                    });
                }
                {
                    picOnly = new JCheckBox();
                    jPanel4.add(picOnly);
                    picOnly.setText("picOnly");
                }
                {
                    sortChkBox = new JCheckBox();
                    jPanel4.add(sortChkBox);
                    sortChkBox.setText("sort");
                }
                {
                    showPicChkBox = new JCheckBox();
                    showPicChkBox.setSelected(true);
                    jPanel4.add(showPicChkBox);
                    showPicChkBox.setText("showPic");
                }
                {
                    JCommonUtil.defaultToolTipDelay();
                    fontSizeSliber = new JSlider(JSlider.HORIZONTAL);
                    jPanel4.add(fontSizeSliber);
                    fontSizeSliber.setPreferredSize(new java.awt.Dimension(419, 35));
                    fontSizeSliber.setValue(22);
                    fontSizeSliber.setMinimum(22);
                    fontSizeSliber.setMaximum(300);
                    fontSizeSliber.setMajorTickSpacing(30);
                    fontSizeSliber.setMinorTickSpacing(5);
                    fontSizeSliber.setCursor(new Cursor(Cursor.HAND_CURSOR));
                    fontSizeSliber.setPaintTicks(false);
                    fontSizeSliber.setPaintLabels(true);
                    {
                        picFolderDirText = new JTextField();
                        JCommonUtil.jTextFieldSetFilePathMouseEvent(picFolderDirText, true);
                        jPanel4.add(picFolderDirText);
                        picFolderDirText.setColumns(20);
                    }
                    fontSizeSliber.addChangeListener(new ChangeListener() {
                        @Override
                        public void stateChanged(ChangeEvent e) {
                            int size = fontSizeSliber.getValue();
                            fontSizeSliber.setToolTipText("" + size);
                            englishArea.setFont(new java.awt.Font("Microsoft JhengHei", 0, size));
                        }
                    });

                }
            }
            {
                jPanel6 = new JPanel();
                jTabbedPane1.addTab("files", null, jPanel6, null);
                BorderLayout jPanel6Layout = new BorderLayout();
                jPanel6.setLayout(jPanel6Layout);
                {
                    jScrollPane4 = new JScrollPane();
                    jPanel6.add(jScrollPane4, BorderLayout.CENTER);
                    jScrollPane4.setPreferredSize(new java.awt.Dimension(420, 211));
                    {
                        fileList = new JList();
                        reloadFileList();
                        jScrollPane4.setViewportView(fileList);
                        fileList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                final File file = JListUtil.getLeadSelectionObject(fileList);
                                if (JMouseEventUtil.buttonRightClick(1, evt)) {
                                    JPopupMenuUtil.newInstance(EnglishTester.this.fileList).applyEvent(evt)//
                                            .addJMenuItem("reload", new ActionListener() {
                                                @Override
                                                public void actionPerformed(ActionEvent e) {
                                                    reloadFileList();
                                                }
                                            })//
                                            .addJMenuItem("delete : " + file.getName(), new ActionListener() {
                                                @Override
                                                public void actionPerformed(ActionEvent e) {
                                                    boolean result = JCommonUtil
                                                            ._JOptionPane_showConfirmDialog_yesNoOption(
                                                                    "delete : " + file.getName() + " ?",
                                                                    "confirm");
                                                    if (result) {
                                                        file.delete();
                                                        reloadFileList();
                                                    }
                                                }//
                                            }).show();
                                    return;
                                }
                                if (evt.getClickCount() == 1) {
                                    return;
                                }
                                if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption(
                                        "?,?\n" + file.getName(),
                                        "")) {
                                    loadEnglishFile(file);
                                }
                            }
                        });
                        fileList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                JListUtil.newInstance(fileList).defaultJListKeyPressed(evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel9 = new JPanel();
                jTabbedPane1.addTab("pic", null, jPanel9, null);
                {
                    picCheckText = new JTextField();
                    jPanel9.add(picCheckText);
                    picCheckText.setPreferredSize(new java.awt.Dimension(177, 39));
                }
                {
                    picCheckBtn = new JButton();
                    jPanel9.add(picCheckBtn);
                    picCheckBtn.setText("check");
                    picCheckBtn.setPreferredSize(new java.awt.Dimension(98, 43));
                    {
                        jPanel11 = new JPanel();
                        jTabbedPane1.addTab("", null, jPanel11, null);
                        jPanel11.setLayout(new BorderLayout(0, 0));
                        {
                            inputTestArea2 = new JTextArea();
                            inputTestArea2.setFont(new Font("", Font.PLAIN, 12));
                            inputTestArea2.addKeyListener(new KeyAdapter() {
                                @Override
                                public void keyReleased(KeyEvent e) {
                                    inputTestTrainer.keyin(e);
                                }
                            });
                            jPanel11.add(inputTestArea2, BorderLayout.SOUTH);
                        }
                        {
                            inputTestArea1 = new JTextArea();
                            JTextAreaUtil.setWrapTextArea(inputTestArea1);
                            inputTestArea1.setFont(new Font("", Font.PLAIN, 22));
                            jPanel11.add(inputTestArea1, BorderLayout.CENTER);
                        }
                        {
                            panel = new JPanel();
                            jPanel11.add(panel, BorderLayout.NORTH);
                            {
                                inputTestLabel = new JLabel("");
                                panel.add(inputTestLabel);
                            }
                            {
                                inputTestChk = new JCheckBox("");
                                inputTestChk.addActionListener(new ActionListener() {
                                    public void actionPerformed(ActionEvent e) {
                                        inputTestTrainer.initQuestion();
                                    }
                                });
                                panel.add(inputTestChk);
                            }
                        }
                    }
                    picCheckBtn.addActionListener(new ActionListener() {
                        void scanPic(String searchWord, File file, Set<File> findFile) {
                            if (file.isDirectory()) {
                                File[] list = null;
                                if ((list = file.listFiles()) != null) {
                                    for (File f : list) {
                                        scanPic(searchWord, f, findFile);
                                    }
                                }
                            } else {
                                String text = searchWord;
                                String name = file.getName().toLowerCase();
                                if (isMatch(name, text)) {
                                    findFile.add(file);
                                }
                            }
                        }

                        public void actionPerformed(ActionEvent evt) {
                            picDir = new File(picFolderDirText.getText());
                            if (picDir == null) {
                                JCommonUtil._jOptionPane_showMessageDialog_error("picDir is null");
                                return;
                            }
                            if (!picDir.exists() || !picDir.isDirectory()) {
                                JCommonUtil._jOptionPane_showMessageDialog_error("picDir ");
                                return;
                            }

                            picCheckBtn.setText("search..");

                            String searchWord = picCheckText.getText().toLowerCase().trim();

                            Set<File> picSet2 = new HashSet<File>();
                            scanPic(searchWord, picDir, picSet2);

                            if (picSet2 != null && picSet2.size() > 0) {
                                picCheckBtn.setText("" + picSet2.size());

                                try {
                                    Desktop.getDesktop().open(picSet2.iterator().next());
                                } catch (IOException e) {
                                    JCommonUtil.handleException(e);
                                }
                            } else {
                                picCheckBtn.setText("0");
                            }
                        }
                    });
                }
            }
        }

        JCommonUtil.setJFrameIcon(this, "resource/images/ico/english_tester.ico");

        pack();
        this.setSize(423, 314);

        configHelper.init();
    } catch (Exception e) {
        // add your error handling code here
        e.printStackTrace();
    }
}

From source file:eu.delving.sip.Application.java

private JPanel createStatePanel() {
    statusPanel.setReaction(ABSENT, allFrames.prepareForNothing());
    statusPanel.setReaction(NO_DATA, importAction);
    statusPanel.setReaction(IMPORTED, new InputAnalyzer());
    statusPanel.setReaction(ANALYZED_IMPORT, allFrames.prepareForDelimiting());
    statusPanel.setReaction(DELIMITED, new ConvertPerformer());
    statusPanel.setReaction(SOURCED, new InputAnalyzer());
    statusPanel.setReaction(ANALYZED_SOURCE, allFrames.prepareForMapping(desktop));
    statusPanel.setReaction(MAPPING, validateAction);
    if (uploadAction == null) {
        statusPanel.setReaction(VALIDATED, allFrames.prepareForNothing());
    } else {/*ww  w. j a va2s.co m*/
        statusPanel.setReaction(VALIDATED, uploadAction);
    }
    JPanel p = new JPanel(new GridLayout(1, 0, 6, 6));
    p.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createBevelBorder(0),
            BorderFactory.createEmptyBorder(6, 6, 6, 6)));
    p.add(statusPanel);
    JPanel rightPanel = new JPanel(new BorderLayout());
    rightPanel.add(new WorkPanel(sipModel), BorderLayout.CENTER);
    rightPanel.add(createButtonPanel(), BorderLayout.WEST);
    p.add(rightPanel);
    return p;
}

From source file:edu.ku.brc.specify.plugins.latlon.LatLonUI.java

/**
 * Creates the UI.//  w ww  .j  a  v a  2 s  . c o  m
 * @param localityCEP the locality object (can be null)
 */
protected void createEditUI() {
    loadAndPushResourceBundle("specify_plugins");

    PanelBuilder builder = new PanelBuilder(new FormLayout("p", "p, 2px, p"), this);

    Color bgColor = getBackground();
    bgColor = new Color(Math.min(bgColor.getRed() + 20, 255), Math.min(bgColor.getGreen() + 20, 255),
            Math.min(bgColor.getBlue() + 20, 255));
    //System.out.println(bgColor);
    setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(bgColor),
            BorderFactory.createEmptyBorder(4, 4, 4, 4)));

    for (int i = 0; i < types.length; i++) {
        typeMapper.put(types[i], typeStrs[i]);
    }

    currentType = LatLonUIIFace.LatLonType.LLPoint;

    pointImages = new ImageIcon[pointNames.length];
    for (int i = 0; i < pointNames.length; i++) {
        pointImages[i] = IconManager.getIcon(pointNames[i], IconManager.IconSize.Std16);
    }

    String[] formatLabels = new String[formats.length];
    for (int i = 0; i < formats.length; i++) {
        formatLabels[i] = getResourceString(formats[i]);
    }
    cardPanel = new JPanel(cardLayout);
    formatSelector = createComboBox(formatLabels);
    latLonPanes = new JComponent[formatLabels.length];

    formatSelector.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            swapForm(formatSelector.getSelectedIndex(), currentType);

            cardLayout.show(cardPanel, ((JComboBox) ae.getSource()).getSelectedItem().toString());

            //stateChanged(null);
        }
    });

    Dimension preferredSize = new Dimension(0, 0);
    cardSubPanes = new JPanel[formats.length * 2];
    panels = new DDDDPanel[formats.length * 2];
    int paneInx = 0;
    for (int i = 0; i < formats.length; i++) {
        cardSubPanes[i] = new JPanel(new BorderLayout());
        try {
            String packageName = "edu.ku.brc.specify.plugins.latlon.";
            DDDDPanel latLon1 = Class.forName(packageName + formatClass[i]).asSubclass(DDDDPanel.class)
                    .newInstance();
            latLon1.setIsRequired(isRequired);
            latLon1.setViewMode(isViewMode);
            latLon1.init();
            latLon1.setChangeListener(this);

            JPanel panel1 = latLon1;
            panel1.setBorder(panelBorder);
            panels[paneInx++] = latLon1;
            latLonPanes[i] = panel1;

            DDDDPanel latlon2 = Class.forName(packageName + formatClass[i]).asSubclass(DDDDPanel.class)
                    .newInstance();
            latlon2.setIsRequired(isRequired);
            latlon2.setViewMode(isViewMode);
            latlon2.init();
            latlon2.setChangeListener(this);

            panels[paneInx++] = latlon2;

            JTabbedPane tabbedPane = new JTabbedPane(
                    UIHelper.getOSType() == UIHelper.OSTYPE.MacOSX ? SwingConstants.BOTTOM
                            : SwingConstants.RIGHT);
            tabbedPane.addTab(null, pointImages[0], panels[paneInx - 2]);
            tabbedPane.addTab(null, pointImages[0], panels[paneInx - 1]);
            latLonPanes[i] = tabbedPane;

            Dimension size = tabbedPane.getPreferredSize();
            preferredSize.width = Math.max(preferredSize.width, size.width);
            preferredSize.height = Math.max(preferredSize.height, size.height);

            tabbedPane.removeAll();
            cardSubPanes[i].add(panel1, BorderLayout.CENTER);
            cardPanel.add(formatLabels[i], cardSubPanes[i]);

            /*if (locality != null)
            {
            latLon1.set(locality.getLatitude1(), locality.getLongitude1(), locality.getLat1text(), locality.getLong1text());
            latlon2.set(locality.getLatitude2(), locality.getLongitude2(), locality.getLat2text(), locality.getLong2text());
            }*/

        } catch (Exception e) {
            e.printStackTrace();
            edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(LatLonUI.class, e);
        }
    }

    // Makes they are all the same size
    for (int i = 0; i < formats.length; i++) {
        cardSubPanes[i].setPreferredSize(preferredSize);
    }

    //final LatLonPanel thisPanel = this;

    PanelBuilder botBtnBar = new PanelBuilder(new FormLayout("p:g,p,10px,p,10px,p,p:g", "p"));

    ButtonGroup btnGroup = new ButtonGroup();
    botBtns = new JToggleButton[typeNames.length];

    if (UIHelper.isMacOS()) {
        /*for (int i=0;i<botBtns.length;i++)
        {
        ImageIcon selIcon   = IconManager.getIcon(typeNames[i]+"Sel", IconManager.IconSize.Std16);
        ImageIcon unselIcon = IconManager.getIcon(typeNames[i], IconManager.IconSize.Std16);
                
        MacIconRadioButton rb = new MacIconRadioButton(selIcon, unselIcon);
        botBtns[i] = rb;
        rb.setBorder(new MacBtnBorder());
                
        Dimension size = rb.getPreferredSize();
        int max = Math.max(size.width, size.height);
        size.setSize(max, max);
        rb.setPreferredSize(size);
        }*/

        BorderedRadioButton.setSelectedBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
        BorderedRadioButton.setUnselectedBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
        for (int i = 0; i < botBtns.length; i++) {
            BorderedRadioButton rb = new BorderedRadioButton(
                    IconManager.getIcon(typeNames[i], IconManager.IconSize.Std16));
            botBtns[i] = rb;
            rb.makeSquare();
            rb.setBorder(new MacBtnBorder());
        }
    } else {
        BorderedRadioButton.setSelectedBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
        BorderedRadioButton.setUnselectedBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
        for (int i = 0; i < botBtns.length; i++) {
            BorderedRadioButton rb = new BorderedRadioButton(
                    IconManager.getIcon(typeNames[i], IconManager.IconSize.Std16));
            botBtns[i] = rb;
            rb.makeSquare();
        }
    }

    for (int i = 0; i < botBtns.length; i++) {
        botBtns[i].setToolTipText(typeToolTips[i]);
        botBtnBar.add(botBtns[i], cc.xy((i * 2) + 2, 1));
        btnGroup.add(botBtns[i]);
        selectedTypeHash.put(botBtns[i], types[i]);

        botBtns[i].addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ce) {
                stateChanged(null);
                currentType = selectedTypeHash.get(ce.getSource());
                swapForm(formatSelector.getSelectedIndex(), currentType);
            }
        });
    }
    botBtns[0].setSelected(true);

    if (isViewMode) {
        typeLabel = createLabel(" ");
    }

    ActionListener infoAL = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doPrefs();
        }
    };

    JButton infoBtn = UIHelper.createIconBtn("Preferences", IconManager.IconSize.Std16,
            getResourceString("PREFERENCES"), true, infoAL);
    infoBtn.setEnabled(true);

    PanelBuilder topPane = new PanelBuilder(
            new FormLayout("l:p, c:p:g" + (isViewMode ? "" : ",4px,p,8px"), "p"));
    topPane.add(formatSelector, cc.xy(1, 1));
    topPane.add(isViewMode ? typeLabel : botBtnBar.getPanel(), cc.xy(2, 1));
    if (!isViewMode)
        topPane.add(infoBtn, cc.xy(4, 1));

    builder.add(topPane.getPanel(), cc.xy(1, 1));
    builder.add(cardPanel, cc.xy(1, 3));

    prefsPanel = new PrefsPanel(false);
    prefsPanel.add(getResourceString("LatLonUI.LL_SEP"));
    prefsPanel.add(CompType.eCheckbox, getResourceString("LatLonUI.LATDEF_DIR"), LAT_PREF, Boolean.class, true);
    prefsPanel.add(CompType.eCheckbox, getResourceString("LatLonUI.LONDEF_DIR"), LON_PREF, Boolean.class, true);
    prefsPanel.add(CompType.eComboBox, getResourceString("LatLonUI.DEF_TYP"), TYP_PREF, Integer.class,
            typeNamesLabels, 0);
    prefsPanel.add(CompType.eComboBox, getResourceString("LatLonUI.DEF_FMT"), FMT_PREF, Integer.class,
            formatLabels, 0);
    prefsPanel.createForm(null, null);

    popResourceBundle();
}

From source file:org.esa.snap.rcp.spectrum.SpectrumTopComponent.java

private void initUI() {
    final JFreeChart chart = ChartFactory.createXYLineChart(Bundle.CTL_SpectrumTopComponent_Name(),
            "Wavelength (nm)", "", null, PlotOrientation.VERTICAL, true, true, false);
    chart.getXYPlot().getRangeAxis().addChangeListener(axisChangeEvent -> {
        if (!isCodeInducedAxisChange) {
            rangeAxisAdjustmentIsFrozen = !((ValueAxis) axisChangeEvent.getAxis()).isAutoRange();
        }//from w w  w .ja  v a2 s  .  co  m
    });
    chart.getXYPlot().getDomainAxis().addChangeListener(axisChangeEvent -> {
        if (!isCodeInducedAxisChange) {
            domainAxisAdjustmentIsFrozen = !((ValueAxis) axisChangeEvent.getAxis()).isAutoRange();
        }
    });
    chart.getXYPlot().getRangeAxis().setAutoRange(false);
    rangeAxisAdjustmentIsFrozen = false;
    chart.getXYPlot().getDomainAxis().setAutoRange(false);
    domainAxisAdjustmentIsFrozen = false;
    chartPanel = new ChartPanel(chart);
    chartHandler = new ChartHandler(chart);
    final XYPlotMarker plotMarker = new XYPlotMarker(chartPanel, new XYPlotMarker.Listener() {
        @Override
        public void pointSelected(XYDataset xyDataset, int seriesIndex, Point2D dataPoint) {
            //do nothing
        }

        @Override
        public void pointDeselected() {
            //do nothing
        }
    });

    filterButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Filter24.gif"), false);
    filterButton.setName("filterButton");
    filterButton.setEnabled(false);
    filterButton.addActionListener(e -> {
        selectSpectralBands();
        recreateChart();
    });

    showSpectrumForCursorButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/CursorSpectrum24.gif"), true);
    showSpectrumForCursorButton.addActionListener(e -> recreateChart());
    showSpectrumForCursorButton.setName("showSpectrumForCursorButton");
    showSpectrumForCursorButton.setSelected(true);
    showSpectrumForCursorButton.setToolTipText("Show spectrum at cursor position.");

    showSpectraForSelectedPinsButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/SelectedPinSpectra24.gif"), true);
    showSpectraForSelectedPinsButton.addActionListener(e -> {
        if (isShowingSpectraForAllPins()) {
            showSpectraForAllPinsButton.setSelected(false);
        } else if (!isShowingSpectraForSelectedPins()) {
            plotMarker.setInvisible();
        }
        recreateChart();
    });
    showSpectraForSelectedPinsButton.setName("showSpectraForSelectedPinsButton");
    showSpectraForSelectedPinsButton.setToolTipText("Show spectra for selected pins.");

    showSpectraForAllPinsButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/PinSpectra24.gif"), true);
    showSpectraForAllPinsButton.addActionListener(e -> {
        if (isShowingSpectraForSelectedPins()) {
            showSpectraForSelectedPinsButton.setSelected(false);
        } else if (!isShowingSpectraForAllPins()) {
            plotMarker.setInvisible();
        }
        recreateChart();
    });
    showSpectraForAllPinsButton.setName("showSpectraForAllPinsButton");
    showSpectraForAllPinsButton.setToolTipText("Show spectra for all pins.");

    showGridButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/SpectrumGrid24.gif"), true);
    showGridButton.addActionListener(e -> chartHandler.setGridVisible(showGridButton.isSelected()));
    showGridButton.setName("showGridButton");
    showGridButton.setToolTipText("Show diagram grid.");

    AbstractButton exportSpectraButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/Export24.gif"), false);
    exportSpectraButton.addActionListener(new SpectraExportAction(this));
    exportSpectraButton.setToolTipText("Export spectra to text file.");
    exportSpectraButton.setName("exportSpectraButton");

    AbstractButton helpButton = ToolButtonFactory.createButton(new HelpAction(this), false);
    helpButton.setName("helpButton");
    helpButton.setToolTipText("Help.");

    final JPanel buttonPane = GridBagUtils.createPanel();
    final GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets.top = 2;
    gbc.gridy = 0;
    buttonPane.add(filterButton, gbc);
    gbc.gridy++;
    buttonPane.add(showSpectrumForCursorButton, gbc);
    gbc.gridy++;
    buttonPane.add(showSpectraForSelectedPinsButton, gbc);
    gbc.gridy++;
    buttonPane.add(showSpectraForAllPinsButton, gbc);
    gbc.gridy++;
    buttonPane.add(showGridButton, gbc);
    gbc.gridy++;
    buttonPane.add(exportSpectraButton, gbc);

    gbc.gridy++;
    gbc.insets.bottom = 0;
    gbc.fill = GridBagConstraints.VERTICAL;
    gbc.weighty = 1.0;
    gbc.gridwidth = 2;
    buttonPane.add(new JLabel(" "), gbc); // filler
    gbc.fill = GridBagConstraints.NONE;
    gbc.weighty = 0.0;
    gbc.gridy = 10;
    gbc.anchor = GridBagConstraints.EAST;
    buttonPane.add(helpButton, gbc);

    chartPanel.setPreferredSize(new Dimension(300, 200));
    chartPanel.setBackground(Color.white);
    chartPanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createBevelBorder(BevelBorder.LOWERED), BorderFactory.createEmptyBorder(2, 2, 2, 2)));
    chartPanel.addChartMouseListener(plotMarker);

    JPanel mainPane = new JPanel(new BorderLayout(4, 4));
    mainPane.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    mainPane.add(BorderLayout.CENTER, chartPanel);
    mainPane.add(BorderLayout.EAST, buttonPane);
    mainPane.setPreferredSize(new Dimension(320, 200));

    SnapApp.getDefault().getProductManager().addListener(new ProductManager.Listener() {
        @Override
        public void productAdded(ProductManager.Event event) {
            // ignored
        }

        @Override
        public void productRemoved(ProductManager.Event event) {
            final Product product = event.getProduct();
            if (getCurrentProduct() == product) {
                chartPanel.getChart().getXYPlot().setDataset(null);
                setCurrentView(null);
                setCurrentProduct(null);
            }
            if (currentView != null) {
                final RasterDataNode currentRaster = currentView.getRaster();
                if (rasterToSpectraMap.containsKey(currentRaster)) {
                    rasterToSpectraMap.remove(currentRaster);
                }
                if (rasterToSpectralBandsMap.containsKey(currentRaster)) {
                    rasterToSpectralBandsMap.remove(currentRaster);
                }
            }
            PlacemarkGroup pinGroup = product.getPinGroup();
            for (int i = 0; i < pinGroup.getNodeCount(); i++) {
                chartHandler.removePinInformation(pinGroup.get(i));
            }
        }
    });

    final ProductSceneView view = getSelectedProductSceneView();
    if (view != null) {
        productSceneViewSelected(view);
    }
    setDisplayName(Bundle.CTL_SpectrumTopComponent_Name());
    setLayout(new BorderLayout());
    add(mainPane, BorderLayout.CENTER);
    updateUIState();
}

From source file:edu.ku.brc.specify.utilapps.sp5utils.Sp5Forms.java

/**
 * @return/*from  w w  w. ja v  a  2 s.  c  om*/
 */
protected JPanel createElipseBtn() {
    CellConstraints cc = new CellConstraints();
    PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g", "f:p:g,p,f:p:g"));
    JButton btn = new JButton("...");
    btn.setMargin(new Insets(2, 4, 2, 4));
    btn.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));

    pb.add(btn, cc.xy(2, 2));
    return pb.getPanel();
}

From source file:it.cnr.icar.eric.client.ui.swing.RegistryBrowser.java

/**
 * Creates a new RegistryBrowser object.
 *///  ww w . ja  v a2  s  .  co  m
@SuppressWarnings("unchecked")
private RegistryBrowser() {
    instance = this;

    classLoader = getClass().getClassLoader(); // new
    // JAXRBrowserClassLoader(getClass().getClassLoader());
    Thread.currentThread().setContextClassLoader(classLoader);

    /*
     * try { classLoader.loadClass("javax.xml.soap.SOAPMessage"); } catch
     * (ClassNotFoundException e) {
     * log.error("Could not find class javax.xml.soap.SOAPMessage", e); }
     */

    UIManager.addPropertyChangeListener(new UISwitchListener(getRootPane()));

    // add listener for 'locale' bound property
    addPropertyChangeListener(PROPERTY_LOCALE, this);

    menuBar = new JMenuBar();
    fileMenu = new JMenu();
    editMenu = new JMenu();
    viewMenu = new JMenu();
    helpMenu = new JMenu();

    JSeparator JSeparator1 = new JSeparator();
    newItem = new JMenuItem();
    importItem = new JMenuItem();
    saveItem = new JMenuItem();
    saveAsItem = new JMenuItem();
    exitItem = new JMenuItem();
    cutItem = new JMenuItem();
    copyItem = new JMenuItem();
    pasteItem = new JMenuItem();
    aboutItem = new JMenuItem();
    setJMenuBar(menuBar);
    setTitle(resourceBundle.getString("title.registryBrowser.java"));
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout(0, 0));

    // Scale window to be centered using 70% of screen
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

    setBounds((int) (dim.getWidth() * .15), (int) (dim.getHeight() * .1), (int) (dim.getWidth() * .7),
            (int) (dim.getHeight() * .75));
    setVisible(false);
    saveFileDialog.setMode(FileDialog.SAVE);
    saveFileDialog.setTitle(resourceBundle.getString("dialog.save.title"));

    GridBagLayout gb = new GridBagLayout();

    topPanel.setLayout(gb);
    getContentPane().add("North", topPanel);

    GridBagConstraints c = new GridBagConstraints();
    toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));
    toolbarPanel.setBounds(0, 0, 488, 29);

    discoveryToolBar = createDiscoveryToolBar();
    toolbarPanel.add(discoveryToolBar);

    // c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 0);
    gb.setConstraints(toolbarPanel, c);
    topPanel.add(toolbarPanel);

    // Panel containing context info like registry location and user context
    JPanel contextPanel = new JPanel();
    GridBagLayout gb1 = new GridBagLayout();
    contextPanel.setLayout(gb1);

    locationLabel = new JLabel(resourceBundle.getString("label.registryLocation"));

    // locationLabel.setPreferredSize(new Dimension(80, 23));
    // c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 0, 0);
    gb1.setConstraints(locationLabel, c);

    // contextPanel.setBackground(Color.green);
    contextPanel.add(locationLabel);

    selectAnItemText = new ItemText(selectAnItem);
    registryCombo.addItem(selectAnItemText.toString());

    ConfigurationType uiConfigurationType = UIUtility.getInstance().getConfigurationType();
    RegistryURIListType urlList = uiConfigurationType.getRegistryURIList();

    List<String> urls = urlList.getRegistryURI();
    Iterator<String> urlsIter = urls.iterator();
    while (urlsIter.hasNext()) {
        ItemText url = new ItemText(urlsIter.next());
        registryCombo.addItem(url.toString());
    }

    registryCombo.setEditable(true);
    registryCombo.setEnabled(true);
    registryCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            final String url = (String) registryCombo.getSelectedItem();
            if ((url == null) || (url.equals(selectAnItem))) {
                return;
            }

            // Clean tabbedPaneParent. Will create new content
            tabbedPaneParent.removeAll();
            conceptsTreeDialog = null;
            ConceptsTreeDialog.clearCache();

            // design:
            // 1. connect and construct tabbedPane in a now swing thread
            // 2. add tabbedPane in swing thread
            // 3. call reloadModel that should use WingWorkers
            final SwingWorker worker1 = new SwingWorker(RegistryBrowser.this) {
                public Object doNonUILogic() {
                    try {
                        // Try to connect
                        if (connectToRegistry(url)) {
                            return new JBTabbedPane();
                        }
                    } catch (JAXRException e1) {
                        displayError(e1);
                    }
                    return null;
                }

                public void doUIUpdateLogic() {
                    tabbedPane = (JBTabbedPane) get();
                    if (tabbedPane != null) {
                        tabbedPaneParent.add(tabbedPane, BorderLayout.CENTER);
                        tabbedPane.reloadModel();
                        try {
                            // DBH 1/30/04 - Add the submissions panel if
                            // the user is authenticated.
                            ConnectionImpl connection = RegistryBrowser.client.connection;
                            boolean newValue = connection.isAuthenticated();
                            firePropertyChange(PROPERTY_AUTHENTICATED, false, newValue);
                            getRootPane().updateUI();
                        } catch (JAXRException e1) {
                            displayError(e1);
                        }
                    }
                }
            };
            worker1.start();
        }
    });
    // c.gridx = 1;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.9;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 0, 5, 0);
    gb1.setConstraints(registryCombo, c);
    contextPanel.add(registryCombo);

    JLabel currentUserLabel = new JLabel(resourceBundle.getString("label.currentUser"),
            SwingConstants.TRAILING);
    c.gridx = 2;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 0);
    gb1.setConstraints(currentUserLabel, c);

    // contextPanel.add(currentUserLabel);
    currentUserText.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            @SuppressWarnings("unused")
            String text = currentUserText.getText();
        }
    });

    currentUserText.setEditable(false);
    c.gridx = 3;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.9;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 5, 5);
    gb1.setConstraints(currentUserText, c);

    // contextPanel.add(currentUserText);
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.9;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 0, 0, 0);
    gb.setConstraints(contextPanel, c);
    topPanel.add(contextPanel, c);

    tabbedPaneParent.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    tabbedPaneParent.setLayout(new BorderLayout());
    tabbedPaneParent.setToolTipText(resourceBundle.getString("tabbedPane.tip"));

    getContentPane().add("Center", tabbedPaneParent);

    fileMenu.setText(resourceBundle.getString("menu.file"));
    fileMenu.setActionCommand("File");
    fileMenu.setMnemonic((int) 'F');
    menuBar.add(fileMenu);

    saveItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    saveItem.setText(resourceBundle.getString("menu.save"));
    saveItem.setActionCommand("Save");
    saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK));
    saveItem.setMnemonic((int) 'S');

    // fileMenu.add(saveItem);
    fileMenu.add(JSeparator1);
    importItem.setText(resourceBundle.getString("menu.import"));
    importItem.setActionCommand("Import");
    importItem.setMnemonic((int) 'I');
    importItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            RegistryBrowser.setWaitCursor();
            importFromFile();
            RegistryBrowser.setDefaultCursor();
        }
    });
    fileMenu.add(importItem);

    exitItem.setText(resourceBundle.getString("menu.exit"));
    exitItem.setActionCommand("Exit");
    exitItem.setMnemonic((int) 'X');
    fileMenu.add(exitItem);

    editMenu.setText(resourceBundle.getString("menu.edit"));
    editMenu.setActionCommand("Edit");
    editMenu.setMnemonic((int) 'E');

    // menuBar.add(editMenu);
    cutItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    cutItem.setText(resourceBundle.getString("menu.cut"));
    cutItem.setActionCommand("Cut");
    cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK));
    cutItem.setMnemonic((int) 'T');
    editMenu.add(cutItem);

    copyItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    copyItem.setText(resourceBundle.getString("menu.copy"));
    copyItem.setActionCommand("Copy");
    copyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK));
    copyItem.setMnemonic((int) 'C');
    editMenu.add(copyItem);

    pasteItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    pasteItem.setText(resourceBundle.getString("menu.paste"));
    pasteItem.setActionCommand("Paste");
    pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK));
    pasteItem.setMnemonic((int) 'P');
    editMenu.add(pasteItem);

    viewMenu.setText(resourceBundle.getString("menu.view"));
    viewMenu.setActionCommand("view");
    viewMenu.setMnemonic((int) 'V');

    themeMenu = new MetalThemeMenu(resourceBundle.getString("menu.theme"), themes);
    viewMenu.add(themeMenu);
    menuBar.add(viewMenu);

    helpMenu.setText(resourceBundle.getString("menu.help"));
    helpMenu.setActionCommand("Help");
    helpMenu.setMnemonic((int) 'H');
    menuBar.add(helpMenu);
    aboutItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    aboutItem.setText(resourceBundle.getString("menu.about"));
    aboutItem.setActionCommand("About...");
    aboutItem.setMnemonic((int) 'A');

    aboutItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Object[] aboutArgs = { BROWSER_VERSION };
            MessageFormat form = new MessageFormat(resourceBundle.getString("dialog.about.text"));
            JOptionPane.showMessageDialog(RegistryBrowser.this, form.format(aboutArgs),
                    resourceBundle.getString("dialog.about.title"), JOptionPane.INFORMATION_MESSAGE);
        }
    });

    helpMenu.add(aboutItem);

    // REGISTER_LISTENERS
    SymWindow aSymWindow = new SymWindow();

    this.addWindowListener(aSymWindow);

    SymAction lSymAction = new SymAction();

    saveItem.addActionListener(lSymAction);
    exitItem.addActionListener(lSymAction);

    SwingUtilities.updateComponentTreeUI(getContentPane());
    SwingUtilities.updateComponentTreeUI(menuBar);
    SwingUtilities.updateComponentTreeUI(fileChooser);

    // Auto select the registry that is configured to connect to by default
    String selectedIndexStr = ProviderProperties.getInstance()
            .getProperty("jaxr-ebxml.registryBrowser.registryLocationCombo.initialSelectionIndex", "0");

    int index = Integer.parseInt(selectedIndexStr);

    try {
        registryCombo.setSelectedIndex(index);
    } catch (IllegalArgumentException e) {
        Object[] invalidIndexArguments = { new Integer(index) };
        MessageFormat form = new MessageFormat(resourceBundle.getString("message.error.invalidIndex"));
        displayError(form.format(invalidIndexArguments), e);
    }
}

From source file:org.esa.beam.visat.toolviews.spectrum.SpectrumToolView.java

@Override
public JComponent createControl() {
    final JFreeChart chart = ChartFactory.createXYLineChart(CHART_TITLE, "Wavelength (nm)", "", null,
            PlotOrientation.VERTICAL, true, true, false);
    chart.getXYPlot().getRangeAxis().addChangeListener(new AxisChangeListener() {
        @Override//  w  w w .j  a v a 2 s .c  o m
        public void axisChanged(AxisChangeEvent axisChangeEvent) {
            if (!isCodeInducedAxisChange) {
                rangeAxisAdjustmentIsFrozen = !((ValueAxis) axisChangeEvent.getAxis()).isAutoRange();
            }
        }
    });
    chart.getXYPlot().getDomainAxis().addChangeListener(new AxisChangeListener() {
        @Override
        public void axisChanged(AxisChangeEvent axisChangeEvent) {
            if (!isCodeInducedAxisChange) {
                domainAxisAdjustmentIsFrozen = !((ValueAxis) axisChangeEvent.getAxis()).isAutoRange();
            }
        }
    });
    chart.getXYPlot().getRangeAxis().setAutoRange(false);
    rangeAxisAdjustmentIsFrozen = false;
    chart.getXYPlot().getDomainAxis().setAutoRange(false);
    domainAxisAdjustmentIsFrozen = false;
    chartPanel = new ChartPanel(chart);
    chartHandler = new ChartHandler(chart);
    final XYPlotMarker plotMarker = new XYPlotMarker(chartPanel, new XYPlotMarker.Listener() {
        @Override
        public void pointSelected(XYDataset xyDataset, int seriesIndex, Point2D dataPoint) {
            if (hasDiagram()) {
                if (cursorSynchronizer == null) {
                    cursorSynchronizer = new CursorSynchronizer(VisatApp.getApp());
                }
                if (!cursorSynchronizer.isEnabled()) {
                    cursorSynchronizer.setEnabled(true);
                }
            }
        }

        @Override
        public void pointDeselected() {
            cursorSynchronizer.setEnabled(false);
        }
    });

    titleBase = getDescriptor().getTitle();
    filterButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Filter24.gif"), false);
    filterButton.setName("filterButton");
    filterButton.setEnabled(false);
    filterButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            selectSpectralBands();
            recreateChart();
        }
    });

    showSpectrumForCursorButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/CursorSpectrum24.gif"), true);
    showSpectrumForCursorButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            recreateChart();
        }
    });
    showSpectrumForCursorButton.setName("showSpectrumForCursorButton");
    showSpectrumForCursorButton.setSelected(true);
    showSpectrumForCursorButton.setToolTipText("Show spectrum at cursor position.");

    showSpectraForSelectedPinsButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/SelectedPinSpectra24.gif"), true);
    showSpectraForSelectedPinsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (isShowingSpectraForAllPins()) {
                showSpectraForAllPinsButton.setSelected(false);
            } else if (!isShowingSpectraForSelectedPins()) {
                plotMarker.setInvisible();
            }
            recreateChart();
        }
    });
    showSpectraForSelectedPinsButton.setName("showSpectraForSelectedPinsButton");
    showSpectraForSelectedPinsButton.setToolTipText("Show spectra for selected pins.");

    showSpectraForAllPinsButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/PinSpectra24.gif"), true);
    showSpectraForAllPinsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (isShowingSpectraForSelectedPins()) {
                showSpectraForSelectedPinsButton.setSelected(false);
            } else if (!isShowingSpectraForAllPins()) {
                plotMarker.setInvisible();
            }
            recreateChart();
        }
    });
    showSpectraForAllPinsButton.setName("showSpectraForAllPinsButton");
    showSpectraForAllPinsButton.setToolTipText("Show spectra for all pins.");

    // todo - not yet implemented for 4.1 but planned for 4.2 (mp - 31.10.2007)
    //        showAveragePinSpectrumButton = ToolButtonFactory.createButton(
    //                UIUtils.loadImageIcon("icons/AverageSpectrum24.gif"), true);
    //        showAveragePinSpectrumButton.addActionListener(new ActionListener() {
    //            public void actionPerformed(ActionEvent e) {
    //                // todo - implement
    //            }
    //        });
    //        showAveragePinSpectrumButton.setName("showAveragePinSpectrumButton");
    //        showAveragePinSpectrumButton.setToolTipText("Show average spectrum of all pin spectra.");

    showGridButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/SpectrumGrid24.gif"), true);
    showGridButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            chartHandler.setGridVisible(showGridButton.isSelected());
        }
    });
    showGridButton.setName("showGridButton");
    showGridButton.setToolTipText("Show diagram grid.");

    // todo - not yet implemented for 4.1 but planned for 4.2 (mp - 31.10.2007)
    //        showGraphPointsButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/GraphPoints24.gif"), true);
    //        showGraphPointsButton.addActionListener(new ActionListener() {
    //            public void actionPerformed(ActionEvent e) {
    //                // todo - implement
    //                JOptionPane.showMessageDialog(null, "Not implemented");
    //            }
    //        });
    //        showGraphPointsButton.setName("showGraphPointsButton");
    //        showGraphPointsButton.setToolTipText("Show graph points grid.");

    AbstractButton exportSpectraButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/Export24.gif"), false);
    exportSpectraButton.addActionListener(new SpectraExportAction(this));
    exportSpectraButton.setToolTipText("Export spectra to text file.");
    exportSpectraButton.setName("exportSpectraButton");

    AbstractButton helpButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Help22.png"),
            false);
    helpButton.setName("helpButton");
    helpButton.setToolTipText("Help."); /*I18N*/

    final JPanel buttonPane = GridBagUtils.createPanel();
    final GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets.top = 2;
    gbc.gridy = 0;
    buttonPane.add(filterButton, gbc);
    gbc.gridy++;
    buttonPane.add(showSpectrumForCursorButton, gbc);
    gbc.gridy++;
    buttonPane.add(showSpectraForSelectedPinsButton, gbc);
    gbc.gridy++;
    buttonPane.add(showSpectraForAllPinsButton, gbc);
    gbc.gridy++;
    // todo - not yet implemented for 4.1 but planned for 4.2 (mp - 31.10.2007)
    //        buttonPane.add(showAveragePinSpectrumButton, gbc);
    //        gbc.gridy++;
    buttonPane.add(showGridButton, gbc);
    gbc.gridy++;
    // todo - not yet implemented for 4.1 but planned for 4.2 (mp - 31.10.2007)
    //        buttonPane.add(showGraphPointsButton, gbc);
    //        gbc.gridy++;
    buttonPane.add(exportSpectraButton, gbc);

    gbc.gridy++;
    gbc.insets.bottom = 0;
    gbc.fill = GridBagConstraints.VERTICAL;
    gbc.weighty = 1.0;
    gbc.gridwidth = 2;
    buttonPane.add(new JLabel(" "), gbc); // filler
    gbc.fill = GridBagConstraints.NONE;
    gbc.weighty = 0.0;
    gbc.gridy = 10;
    gbc.anchor = GridBagConstraints.EAST;
    buttonPane.add(helpButton, gbc);

    chartPanel.setPreferredSize(new Dimension(300, 200));
    chartPanel.setBackground(Color.white);
    chartPanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createBevelBorder(BevelBorder.LOWERED), BorderFactory.createEmptyBorder(2, 2, 2, 2)));
    chartPanel.addChartMouseListener(plotMarker);

    JPanel mainPane = new JPanel(new BorderLayout(4, 4));
    mainPane.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    mainPane.add(BorderLayout.CENTER, chartPanel);
    mainPane.add(BorderLayout.EAST, buttonPane);
    mainPane.setPreferredSize(new Dimension(320, 200));

    if (getDescriptor().getHelpId() != null) {
        HelpSys.enableHelpOnButton(helpButton, getDescriptor().getHelpId());
        HelpSys.enableHelpKey(mainPane, getDescriptor().getHelpId());
    }

    // Add an internal frame listener to VISAT so that we can update our
    // spectrum dialog with the information of the currently activated
    // product scene view.
    //
    VisatApp.getApp().addInternalFrameListener(new SpectrumIFL());

    VisatApp.getApp().getProductManager().addListener(new ProductManager.Listener() {
        @Override
        public void productAdded(ProductManager.Event event) {
            // ignored
        }

        @Override
        public void productRemoved(ProductManager.Event event) {
            final Product product = event.getProduct();
            if (getCurrentProduct() == product) {
                chartPanel.getChart().getXYPlot().setDataset(null);
                setCurrentView(null);
                setCurrentProduct(null);
            }
            if (productToAllSpectraMap.containsKey(product)) {
                productToAllSpectraMap.remove(product);
            }
            if (productToBandsMap.containsKey(product)) {
                productToBandsMap.remove(product);
            }
            PlacemarkGroup pinGroup = product.getPinGroup();
            for (int i = 0; i < pinGroup.getNodeCount(); i++) {
                chartHandler.removePinInformation(pinGroup.get(i));
            }
        }
    });

    final ProductSceneView view = VisatApp.getApp().getSelectedProductSceneView();
    if (view != null) {
        handleViewActivated(view);
    } else {
        setCurrentView(view);
    }
    updateUIState();
    return mainPane;
}