Example usage for javax.swing JTabbedPane JTabbedPane

List of usage examples for javax.swing JTabbedPane JTabbedPane

Introduction

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

Prototype

public JTabbedPane() 

Source Link

Document

Creates an empty TabbedPane with a default tab placement of JTabbedPane.TOP.

Usage

From source file:BorderDemo.java

public BorderDemo() {
    super(new GridLayout(1, 0));

    // Keep references to the next few borders,
    // for use in titles and compound borders.
    Border blackline, raisedetched, loweredetched, raisedbevel, loweredbevel, empty;

    // A border that puts 10 extra pixels at the sides and
    // bottom of each pane.
    Border paneEdge = BorderFactory.createEmptyBorder(0, 10, 10, 10);

    blackline = BorderFactory.createLineBorder(Color.black);
    raisedetched = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    raisedbevel = BorderFactory.createRaisedBevelBorder();
    loweredbevel = BorderFactory.createLoweredBevelBorder();
    empty = BorderFactory.createEmptyBorder();

    // First pane: simple borders
    JPanel simpleBorders = new JPanel();
    simpleBorders.setBorder(paneEdge);//  w  w w.  j a v a  2  s. co  m
    simpleBorders.setLayout(new BoxLayout(simpleBorders, BoxLayout.Y_AXIS));

    addCompForBorder(blackline, "line border", simpleBorders);
    addCompForBorder(raisedetched, "raised etched border", simpleBorders);
    addCompForBorder(loweredetched, "lowered etched border", simpleBorders);
    addCompForBorder(raisedbevel, "raised bevel border", simpleBorders);
    addCompForBorder(loweredbevel, "lowered bevel border", simpleBorders);
    addCompForBorder(empty, "empty border", simpleBorders);

    // Second pane: matte borders
    JPanel matteBorders = new JPanel();
    matteBorders.setBorder(paneEdge);
    matteBorders.setLayout(new BoxLayout(matteBorders, BoxLayout.Y_AXIS));

    ImageIcon icon = createImageIcon("images/wavy.gif", "wavy-line border icon"); // 20x22
    Border border = BorderFactory.createMatteBorder(-1, -1, -1, -1, icon);
    if (icon != null) {
        addCompForBorder(border, "matte border (-1,-1,-1,-1,icon)", matteBorders);
    } else {
        addCompForBorder(border, "matte border (-1,-1,-1,-1,<null-icon>)", matteBorders);
    }
    border = BorderFactory.createMatteBorder(1, 5, 1, 1, Color.red);
    addCompForBorder(border, "matte border (1,5,1,1,Color.red)", matteBorders);

    border = BorderFactory.createMatteBorder(0, 20, 0, 0, icon);
    if (icon != null) {
        addCompForBorder(border, "matte border (0,20,0,0,icon)", matteBorders);
    } else {
        addCompForBorder(border, "matte border (0,20,0,0,<null-icon>)", matteBorders);
    }

    // Third pane: titled borders
    JPanel titledBorders = new JPanel();
    titledBorders.setBorder(paneEdge);
    titledBorders.setLayout(new BoxLayout(titledBorders, BoxLayout.Y_AXIS));
    TitledBorder titled;

    titled = BorderFactory.createTitledBorder("title");
    addCompForBorder(titled, "default titled border" + " (default just., default pos.)", titledBorders);

    titled = BorderFactory.createTitledBorder(blackline, "title");
    addCompForTitledBorder(titled, "titled line border" + " (centered, default pos.)", TitledBorder.CENTER,
            TitledBorder.DEFAULT_POSITION, titledBorders);

    titled = BorderFactory.createTitledBorder(loweredetched, "title");
    addCompForTitledBorder(titled, "titled lowered etched border" + " (right just., default pos.)",
            TitledBorder.RIGHT, TitledBorder.DEFAULT_POSITION, titledBorders);

    titled = BorderFactory.createTitledBorder(loweredbevel, "title");
    addCompForTitledBorder(titled, "titled lowered bevel border" + " (default just., above top)",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.ABOVE_TOP, titledBorders);

    titled = BorderFactory.createTitledBorder(empty, "title");
    addCompForTitledBorder(titled, "titled empty border" + " (default just., bottom)",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.BOTTOM, titledBorders);

    // Fourth pane: compound borders
    JPanel compoundBorders = new JPanel();
    compoundBorders.setBorder(paneEdge);
    compoundBorders.setLayout(new BoxLayout(compoundBorders, BoxLayout.Y_AXIS));
    Border redline = BorderFactory.createLineBorder(Color.red);

    Border compound;
    compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel);
    addCompForBorder(compound, "compound border (two bevels)", compoundBorders);

    compound = BorderFactory.createCompoundBorder(redline, compound);
    addCompForBorder(compound, "compound border (add a red outline)", compoundBorders);

    titled = BorderFactory.createTitledBorder(compound, "title", TitledBorder.CENTER,
            TitledBorder.BELOW_BOTTOM);
    addCompForBorder(titled, "titled compound border" + " (centered, below bottom)", compoundBorders);

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Simple", null, simpleBorders, null);
    tabbedPane.addTab("Matte", null, matteBorders, null);
    tabbedPane.addTab("Titled", null, titledBorders, null);
    tabbedPane.addTab("Compound", null, compoundBorders, null);
    tabbedPane.setSelectedIndex(0);
    String toolTip = new String(
            "<html>Blue Wavy Line border art crew:<br>&nbsp;&nbsp;&nbsp;Bill Pauley<br>&nbsp;&nbsp;&nbsp;Cris St. Aubyn<br>&nbsp;&nbsp;&nbsp;Ben Wronsky<br>&nbsp;&nbsp;&nbsp;Nathan Walrath<br>&nbsp;&nbsp;&nbsp;Tommy Adams, special consultant</html>");
    tabbedPane.setToolTipTextAt(1, toolTip);

    add(tabbedPane);
}

From source file:edu.ku.brc.specify.utilapps.RegisterApp.java

/**
 * //from  w  w w .  ja v a 2s .  com
 */
protected void createUI() {
    JTabbedPane tabbedPane = new JTabbedPane();

    rp = new RegProcessor();
    rp.processSQL();

    tree = new JTree(rp.getRoot(INCL_ANON));
    propsTable = new JTable();

    tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            fillPropsTable();
        }
    });
    tree.setCellRenderer(new MyTreeCellRenderer());

    Component topComp = UIHelper.createScrollPane(tree);
    Component botComp = UIHelper.createScrollPane(propsTable);
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topComp, botComp);

    splitPane.setDividerLocation(0.5);
    splitPane.setOneTouchExpandable(true);

    splitPane.setLastDividerLocation(300);
    Dimension minimumSize = new Dimension(200, 400);
    topComp.setMinimumSize(minimumSize);
    botComp.setMinimumSize(minimumSize);

    tabbedPane.add("Registration", splitPane);

    final List<Pair<String, String>> trackDescPairs = rp.getTrackKeyDescPairs();
    Vector<String> trkItems = new Vector<String>();
    for (Pair<String, String> p : trackDescPairs) {
        trkItems.add(p.second);
    }

    //Collections.sort(trkItems);
    final JList list = new JList(trkItems);
    //pb.add(UIHelper.createScrollPane(list), cc.xy(1, 1));
    list.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                int inx = list.getSelectedIndex();
                if (inx > -1) {
                    fillUsageItemsList(trackDescPairs.get(inx).first);
                }
            }
        }
    });

    tabbedPane.add("Reg Stats", getStatsPane("Registration", rp.getRegNumHash().values(), "register"));

    DefaultListModel model = new DefaultListModel();
    trackItemsList = new JList(model);

    topComp = UIHelper.createScrollPane(list);
    botComp = UIHelper.createScrollPane(trackItemsList);
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topComp, botComp);
    splitPane.setDividerLocation(0.5);
    splitPane.setOneTouchExpandable(true);

    topComp.setMinimumSize(minimumSize);
    botComp.setMinimumSize(minimumSize);

    splitPane.setDividerLocation(0.5);
    trackUsageHash = rp.getTrackCatsHash();
    tabbedPane.add("Usage Tracking", splitPane);

    tabbedPane.add("User Stats", getStatsPane("Tracking", rp.getTrackIdHash().values(), "track"));

    add(tabbedPane, BorderLayout.CENTER);
}

From source file:fll.scheduler.SchedulerUI.java

public SchedulerUI() {
    super(BASE_TITLE);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    _progressDialog = new ProgressDialog(SchedulerUI.this, "Please Wait");
    _progressDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

    setJMenuBar(createMenubar());//  www .j  a  va  2s  . c  om

    final Container cpane = getContentPane();
    cpane.setLayout(new BorderLayout());

    mTabbedPane = new JTabbedPane();
    cpane.add(mTabbedPane, BorderLayout.CENTER);

    final JPanel scheduleDescriptionPanel = new JPanel(new BorderLayout());
    mTabbedPane.addTab("Description", scheduleDescriptionPanel);

    mDescriptionFilename = new JLabel("");
    scheduleDescriptionPanel.add(createDescriptionToolbar(), BorderLayout.PAGE_START);

    mScheduleDescriptionEditor = new SolverParamsEditor();
    final JScrollPane editorScroller = new JScrollPane(mScheduleDescriptionEditor);
    scheduleDescriptionPanel.add(editorScroller, BorderLayout.CENTER);

    // start out with default values
    mScheduleDescriptionEditor.setParams(new SolverParams());

    final JPanel schedulePanel = new JPanel(new BorderLayout());
    mTabbedPane.addTab("Schedule", schedulePanel);

    mScheduleFilename = new JLabel("");
    schedulePanel.add(createScheduleToolbar(), BorderLayout.PAGE_START);

    mScheduleTable = new JTable();
    mScheduleTable.setAutoCreateRowSorter(true);
    mScheduleTable.setDefaultRenderer(Date.class, schedTableRenderer);
    mScheduleTable.setDefaultRenderer(String.class, schedTableRenderer);
    mScheduleTable.setDefaultRenderer(Integer.class, schedTableRenderer);
    mScheduleTable.setDefaultRenderer(Object.class, schedTableRenderer);
    final JScrollPane dataScroller = new JScrollPane(mScheduleTable);

    violationTable = new JTable();
    violationTable.setDefaultRenderer(String.class, violationTableRenderer);
    violationTable.getSelectionModel().addListSelectionListener(violationSelectionListener);
    final JScrollPane violationScroller = new JScrollPane(violationTable);

    final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, dataScroller, violationScroller);
    schedulePanel.add(splitPane, BorderLayout.CENTER);

    // initial state
    mWriteSchedulesAction.setEnabled(false);
    mDisplayGeneralScheduleAction.setEnabled(false);
    mRunOptimizerAction.setEnabled(false);
    mReloadFileAction.setEnabled(false);

    pack();
}

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

private void initGUI() {
    try {//  ww w . j  a  v  a2 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:com.eviware.soapui.impl.wsdl.panels.mock.WsdlMockServiceDesktopPanel.java

private JComponent buildContent() {
    JTabbedPane tabs = new JTabbedPane();
    inspectorPanel = JInspectorPanelFactory.build(buildOperationList());

    tabs.addTab("Operations", inspectorPanel.getComponent());
    addTabs(tabs, inspectorPanel);/*from  w w w  .j  a  va  2  s  .  c om*/

    if (StringUtils.hasContent(getModelItem().getDescription())
            && getModelItem().getSettings().getBoolean(UISettings.SHOW_DESCRIPTIONS)) {
        inspectorPanel.setCurrentInspector("Description");
    }

    return UISupport.createTabPanel(tabs, true);
}

From source file:ch.zhaw.simulation.diagram.charteditor.DefaultAxisEditor.java

/**
 * Standard constructor: builds a panel for displaying/editing the
 * properties of the specified axis.//  w ww .  j ava  2 s . c o m
 * 
 * @param axis
 *            the axis whose properties are to be displayed/edited in the
 *            panel.
 */
public DefaultAxisEditor(Axis axis) {
    this.labelFont = axis.getLabelFont();
    this.labelPaintSample = new PaintSample(axis.getLabelPaint());
    this.tickLabelFont = axis.getTickLabelFont();
    this.tickLabelPaintSample = new PaintSample(axis.getTickLabelPaint());

    // Insets values
    this.tickLabelInsets = axis.getTickLabelInsets();
    this.labelInsets = axis.getLabelInsets();

    setLayout(new BorderLayout());

    JPanel general = new JPanel(new BorderLayout());
    general.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
            localizationResources.getString("General")));

    JPanel interior = new JPanel(new LCBLayout(5));
    interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    interior.add(new JLabel(localizationResources.getString("Label")));
    this.label = new JTextField(axis.getLabel());
    interior.add(this.label);
    interior.add(new JPanel());

    interior.add(new JLabel(localizationResources.getString("Font")));
    this.labelFontField = new FontDisplayField(this.labelFont);
    interior.add(this.labelFontField);
    JButton b = new JButton(localizationResources.getString("Select..."));
    b.setActionCommand("SelectLabelFont");
    b.addActionListener(this);
    interior.add(b);

    interior.add(new JLabel(localizationResources.getString("Paint")));
    interior.add(this.labelPaintSample);
    b = new JButton(localizationResources.getString("Select..."));
    b.setActionCommand("SelectLabelPaint");
    b.addActionListener(this);
    interior.add(b);

    general.add(interior);

    add(general, BorderLayout.NORTH);

    this.slot1 = new JPanel(new BorderLayout());

    JPanel other = new JPanel(new BorderLayout());
    other.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
            localizationResources.getString("Other")));

    this.otherTabs = new JTabbedPane();
    this.otherTabs.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));

    JPanel ticks = new JPanel(new LCBLayout(3));
    ticks.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    this.showTickLabelsCheckBox = new JCheckBox(localizationResources.getString("Show_tick_labels"),
            axis.isTickLabelsVisible());
    ticks.add(this.showTickLabelsCheckBox);
    ticks.add(new JPanel());
    ticks.add(new JPanel());

    ticks.add(new JLabel(localizationResources.getString("Tick_label_font")));
    this.tickLabelFontField = new FontDisplayField(this.tickLabelFont);
    ticks.add(this.tickLabelFontField);
    b = new JButton(localizationResources.getString("Select..."));
    b.setActionCommand("SelectTickLabelFont");
    b.addActionListener(this);
    ticks.add(b);

    this.showTickMarksCheckBox = new JCheckBox(localizationResources.getString("Show_tick_marks"),
            axis.isTickMarksVisible());
    ticks.add(this.showTickMarksCheckBox);
    ticks.add(new JPanel());
    ticks.add(new JPanel());

    this.otherTabs.add(localizationResources.getString("Ticks"), ticks);

    other.add(this.otherTabs);

    this.slot1.add(other);

    this.slot2 = new JPanel(new BorderLayout());
    this.slot2.add(this.slot1, BorderLayout.NORTH);
    add(this.slot2);

}

From source file:net.sf.jabref.gui.plaintextimport.TextInputDialog.java

private void jbInit() {
    getContentPane().setLayout(new BorderLayout());
    StringBuilder typeStr = new StringBuilder("Plain text import");
    if (entry.getType() != null) {
        typeStr.append(' ').append(Localization.lang("for")).append(' ').append(entry.getType());
    }/*w  ww .j av a 2 s.c om*/

    this.setTitle(typeStr.toString());
    getContentPane().add(panel1, BorderLayout.CENTER);

    initRawPanel();
    initButtonPanel();
    initSourcePanel();

    JTabbedPane tabbed = new JTabbedPane();

    tabbed.add(rawPanel, Localization.lang("Raw source"));
    tabbed.add(sourcePanel, Localization.lang("BibTeX source"));

    // Panel Layout
    panel1.setLayout(new BorderLayout());
    panel1.add(tabbed, BorderLayout.CENTER);
    panel1.add(buttons, BorderLayout.SOUTH);

    // Key bindings:
    ActionMap am = buttons.getActionMap();
    InputMap im = buttons.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
}

From source file:cs.stats.gui.StatsCharts.java

private JPanel createChartTab() {

    JPanel mainPanel = new JPanel();
    tabbedPane = new JTabbedPane();

    tabbedPane.addTab("Probability of thread resolution time exceeding " + tresholdTRT + " days",
            createChart("Probability of thread resolution time exceeding " + tresholdTRT + " days", 0));
    tabbedPane.addTab("Probability of thread resolution time exceeding " + tresholdTRT + " days",
            createChart("Probability of thread resolution time exceeding " + tresholdTRT + " days", 1));
    //tabbedPane.addTab("Mean thread resolution time", createChart("Mean thread resolution time", 4));
    //tabbedPane.addTab("Average Replies Number", createChart("Average Replies Number", 2));
    //tabbedPane.addTab("Demand-Supply Change", createChart("Demand-Supply Change", 3));

    mainPanel.add(tabbedPane);//ww w  .ja v a  2 s .  c  om

    return mainPanel;
}

From source file:userinterface.properties.GUIGraphHandler.java

private void initComponents() {
    theTabs = new JTabbedPane() {

        @Override/*from   w  w  w .  j a  v a 2s. c om*/
        public String getTitleAt(int index) {
            try {
                TabClosePanel panel = (TabClosePanel) getTabComponentAt(index);
                return panel.getTitle();
            } catch (Exception e) {
                return "";
            }
        }

        @Override
        public String getToolTipTextAt(int index) {
            return ((TabClosePanel) getTabComponentAt(index)).getToolTipText();
        }

        @Override
        public void setTitleAt(int index, String title) {

            if (((TabClosePanel) getTabComponentAt(index)) == null) {
                return;
            }

            ((TabClosePanel) getTabComponentAt(index)).setTitle(title);
        }

        @Override
        public void setIconAt(int index, Icon icon) {
            ((TabClosePanel) getTabComponentAt(index)).setIcon(icon);
        }

        @Override
        public void setToolTipTextAt(int index, String toolTipText) {
            ((TabClosePanel) getTabComponentAt(index)).setToolTip(toolTipText);
        }

    };

    theTabs.addMouseListener(this);
    theTabs.addMouseWheelListener(new MouseWheelListener() {

        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {
            if (e.getPreciseWheelRotation() > 0.0) {

                if (theTabs.getSelectedIndex() != (theTabs.getTabCount() - 1))
                    theTabs.setSelectedIndex(theTabs.getSelectedIndex() + 1);
            } else {

                if (theTabs.getSelectedIndex() != 0)
                    theTabs.setSelectedIndex(theTabs.getSelectedIndex() - 1);
            }
        }
    });

    setLayout(new BorderLayout());
    add(theTabs, BorderLayout.CENTER);

    graphOptions = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            GraphOptions graphOptions = options.get(theTabs.getSelectedIndex());
            graphOptions.setVisible(true);
        }
    };

    graphOptions.putValue(Action.NAME, "Graph options");
    graphOptions.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_G));
    graphOptions.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallOptions.png"));
    graphOptions.putValue(Action.LONG_DESCRIPTION, "Displays the options dialog for the graph.");

    zoomIn = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            JPanel mgm = models.get(theTabs.getSelectedIndex());

            if (mgm instanceof ChartPanel)
                ((ChartPanel) mgm).zoomInBoth(-1, -1);
            else if (mgm instanceof Graph3D) {
                double rho = ((Graph3D) mgm).getChart3DPanel().getViewPoint().getRho();
                ((Graph3D) mgm).getChart3DPanel().getViewPoint().setRho(rho - 5);
                ((Graph3D) mgm).getChart3DPanel().repaint();
            }
        }
    };

    zoomIn.putValue(Action.NAME, "In");
    zoomIn.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_I));
    zoomIn.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPlayerFwd.png"));
    zoomIn.putValue(Action.LONG_DESCRIPTION, "Zoom in on the graph.");

    zoomOut = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            JPanel mgm = models.get(theTabs.getSelectedIndex());

            if (mgm instanceof ChartPanel)
                ((ChartPanel) mgm).zoomOutBoth(-1, -1);
            else if (mgm instanceof Graph3D) {
                double rho = ((Graph3D) mgm).getChart3DPanel().getViewPoint().getRho();
                ((Graph3D) mgm).getChart3DPanel().getViewPoint().setRho(rho + 5);
                ((Graph3D) mgm).getChart3DPanel().repaint();
            }
        }
    };

    zoomOut.putValue(Action.NAME, "Out");
    zoomOut.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_O));
    zoomOut.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPlayerRew.png"));
    zoomOut.putValue(Action.LONG_DESCRIPTION, "Zoom out of the graph.");

    zoomDefault = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            JPanel mgm = models.get(theTabs.getSelectedIndex());

            if (mgm instanceof ChartPanel)
                ((ChartPanel) mgm).restoreAutoBounds();
            else if (mgm instanceof Graph3D) {
                ((Graph3D) mgm).getChart3DPanel().zoomToFit();
                ((Graph3D) mgm).getChart3DPanel().getDrawable()
                        .setViewPoint(new ViewPoint3D(-Math.PI / 2, Math.PI * 1.124, 70.0, 0.0));
                ((Graph3D) mgm).getChart3DPanel().repaint();

            }
        }
    };

    zoomDefault.putValue(Action.NAME, "Default");
    zoomDefault.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D));
    zoomDefault.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPlayerStart.png"));
    zoomDefault.putValue(Action.LONG_DESCRIPTION, "Set the default zoom for the graph.");

    importXML = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (plug.showOpenFileDialog(graFilter) != JFileChooser.APPROVE_OPTION)
                return;
            try {
                Graph mgm = Graph.load(plug.getChooserFile());
                addGraph(mgm);
            } catch (GraphException ex) {
                plug.error("Could not import PRISM graph file:\n" + ex.getMessage());
            }
        }
    };
    importXML.putValue(Action.NAME, "PRISM graph (*.gra)");
    importXML.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_I));
    importXML.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileGraph.png"));
    importXML.putValue(Action.LONG_DESCRIPTION, "Imports a saved PRISM graph from a file.");

    addFunction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {

            plotNewFunction();
        }
    };
    addFunction.putValue(Action.NAME, "Plot function");
    addFunction.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P));
    addFunction.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFunction.png"));
    addFunction.putValue(Action.LONG_DESCRIPTION, "Plots a new specified function on the current graph");

    exportXML = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (plug.showSaveFileDialog(graFilter) != JFileChooser.APPROVE_OPTION)
                return;
            Graph mgm = (Graph) models.get(theTabs.getSelectedIndex());
            try {
                mgm.save(plug.getChooserFile());
            } catch (PrismException ex) {
                plug.error("Could not export PRISM graph file:\n" + ex.getMessage());
            }
        }
    };
    exportXML.putValue(Action.NAME, "PRISM graph (*.gra)");
    exportXML.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_X));
    exportXML.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileGraph.png"));
    exportXML.putValue(Action.LONG_DESCRIPTION, "Export graph as a PRISM graph file.");

    exportImageJPG = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            JPanel model = getModel(theTabs.getSelectedIndex());

            GUIImageExportDialog imageDialog = new GUIImageExportDialog(plug.getGUI(), model,
                    GUIImageExportDialog.JPEG);
            saveImage(imageDialog);
        }
    };
    exportImageJPG.putValue(Action.NAME, "JPEG Interchange Format (*.jpg, *.jpeg)");
    exportImageJPG.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_J));
    exportImageJPG.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileImage.png"));
    exportImageJPG.putValue(Action.LONG_DESCRIPTION, "Export graph as a JPEG file.");

    exportImagePNG = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            JPanel model = getModel(theTabs.getSelectedIndex());
            GUIImageExportDialog imageDialog = new GUIImageExportDialog(plug.getGUI(), model,
                    GUIImageExportDialog.PNG);
            saveImage(imageDialog);

        }
    };
    exportImagePNG.putValue(Action.NAME, "Portable Network Graphics (*.png)");
    exportImagePNG.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P));
    exportImagePNG.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileImage.png"));
    exportImagePNG.putValue(Action.LONG_DESCRIPTION, "Export graph as a Portable Network Graphics file.");

    exportPDF = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (plug.showSaveFileDialog(pdfFilter) != JFileChooser.APPROVE_OPTION)
                return;

            JPanel mgm = models.get(theTabs.getSelectedIndex());

            if (mgm instanceof ChartPanel)
                Graph.exportToPDF(plug.getChooserFile(), ((ChartPanel) mgm).getChart());
            else if (mgm instanceof Graph3D) {

                Graph3D.exportToPDF(plug.getChooserFile(), ((Graph3D) mgm).getChart3DPanel());
            }

        }
    };
    exportPDF.putValue(Action.NAME, "Portable document format (*.pdf)");
    exportPDF.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P));
    exportPDF.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFilePdf.png"));
    exportPDF.putValue(Action.LONG_DESCRIPTION, "Export the graph as a Portable document format file.");

    exportImageEPS = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            JPanel model = getModel(theTabs.getSelectedIndex());

            if (model instanceof ChartPanel) {

                GUIImageExportDialog imageDialog = new GUIImageExportDialog(plug.getGUI(), (ChartPanel) model,
                        GUIImageExportDialog.EPS);

                saveImage(imageDialog);

            }
        }
    };
    exportImageEPS.putValue(Action.NAME, "Encapsulated PostScript (*.eps)");
    exportImageEPS.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_E));
    exportImageEPS.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFilePdf.png"));
    exportImageEPS.putValue(Action.LONG_DESCRIPTION, "Export graph as an Encapsulated PostScript file.");

    exportMatlab = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (plug.showSaveFileDialog(matlabFilter) != JFileChooser.APPROVE_OPTION)
                return;

            JPanel mgm = models.get(theTabs.getSelectedIndex());

            if (mgm instanceof Graph) {

                try {

                    ((Graph) mgm).exportToMatlab(plug.getChooserFile());

                } catch (IOException ex) {
                    plug.error("Could not export Matlab file:\n" + ex.getMessage());
                }

            } else if (mgm instanceof Graph3D) {

                try {

                    ((Graph3D) mgm).exportToMatlab(plug.getChooserFile());

                } catch (IOException e1) {

                    plug.error("Could not export Matlab file:\n" + e1.getMessage());
                    e1.printStackTrace();
                }
            }

        }
    };
    exportMatlab.putValue(Action.NAME, "Matlab file (*.m)");
    exportMatlab.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_M));
    exportMatlab.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileMatlab.png"));
    exportMatlab.putValue(Action.LONG_DESCRIPTION, "Export graph as a Matlab file.");

    exportGnuplot = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (plug.showSaveFileDialog(gnuplotFilter) != JFileChooser.APPROVE_OPTION)
                return;

            JPanel mgm = models.get(theTabs.getSelectedIndex());

            if (mgm instanceof ChartPanel) {

                try {
                    if (mgm instanceof Graph && !(mgm instanceof ParametricGraph)) {

                        ((Graph) mgm).exportToGnuplot(plug.getChooserFile());
                    } else if (mgm instanceof ParametricGraph) {

                        ((ParametricGraph) mgm).exportToGnuplot(plug.getChooserFile());
                    } else if (mgm instanceof Histogram) {
                        ((Histogram) mgm).exportToGnuplot(plug.getChooserFile());
                    }

                } catch (IOException ex) {
                    plug.error("Could not export Gnuplot file:\n" + ex.getMessage());
                }
            }

            else if (mgm instanceof Graph3D) {

                try {

                    ((Graph3D) mgm).exportToGnuplot(plug.getChooserFile());

                } catch (IOException ex) {

                    plug.error("Could not export Gnuplot file:\n" + ex.getMessage());
                    ex.printStackTrace();
                }
            }

        }
    };

    exportGnuplot.putValue(Action.NAME, "GNU Plot file(*.gnuplot)");
    exportGnuplot.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_G));
    exportGnuplot.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallgnuplot.png"));
    exportGnuplot.putValue(Action.LONG_DESCRIPTION, "Export graph as a GNU plot file.");

    printGraph = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            JPanel graph = models.get(theTabs.getSelectedIndex());

            if (graph instanceof ChartPanel) {

                if (graph instanceof Graph) {

                    if (!((Graph) graph).getDisplaySettings().getBackgroundColor().equals(Color.white)) {
                        if (plug.questionYesNo(
                                "Your graph has a coloured background, this background will show up on the \n"
                                        + "printout. Would you like to make the current background colour white?") == 0) {

                            ((Graph) graph).getDisplaySettings().setBackgroundColor(Color.white);
                        }
                    }

                } else if (graph instanceof Histogram) {

                    if (!((Histogram) graph).getDisplaySettings().getBackgroundColor().equals(Color.white)) {
                        if (plug.questionYesNo(
                                "Your graph has a coloured background, this background will show up on the \n"
                                        + "printout. Would you like to make the current background colour white?") == 0) {
                            ((Histogram) graph).getDisplaySettings().setBackgroundColor(Color.white);
                        }
                    }

                }

                ((ChartPanel) graph).createChartPrintJob();
            }

            if (graph instanceof Graph3D) {

                ((Graph3D) graph).createPrintJob();
            }
        }
    };

    printGraph.putValue(Action.NAME, "Print graph");
    printGraph.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P));
    printGraph.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPrint.png"));
    printGraph.putValue(Action.LONG_DESCRIPTION, "Print the graph to a printer or file");

    deleteGraph = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            JPanel graph = models.get(theTabs.getSelectedIndex());

            models.remove(theTabs.getSelectedIndex());
            options.remove(theTabs.getSelectedIndex());
            theTabs.remove(graph);
        }
    };
    deleteGraph.putValue(Action.NAME, "Delete graph");
    deleteGraph.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D));
    deleteGraph.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallDelete.png"));
    deleteGraph.putValue(Action.LONG_DESCRIPTION, "Deletes the graph.");

    zoomMenu = new JMenu("Zoom");
    zoomMenu.setMnemonic('Z');
    zoomMenu.setIcon(GUIPrism.getIconFromImage("smallView.png"));
    zoomMenu.add(zoomIn);
    zoomMenu.add(zoomOut);
    zoomMenu.add(zoomDefault);

    exportMenu = new JMenu("Export graph");
    exportMenu.setMnemonic('E');
    exportMenu.setIcon(GUIPrism.getIconFromImage("smallExport.png"));
    exportMenu.add(exportXML);
    exportMenu.add(exportImagePNG);
    exportMenu.add(exportPDF);
    exportMenu.add(exportImageEPS);
    exportMenu.add(exportImageJPG);

    exportMenu.add(exportMatlab);
    exportMenu.add(exportGnuplot);

    importMenu = new JMenu("Import graph");
    importMenu.setMnemonic('I');
    importMenu.setIcon(GUIPrism.getIconFromImage("smallImport.png"));
    importMenu.add(importXML);

    graphMenu.add(graphOptions);
    graphMenu.add(zoomMenu);
    graphMenu.addSeparator();
    graphMenu.add(printGraph);
    graphMenu.add(deleteGraph);
    graphMenu.addSeparator();
    graphMenu.add(exportMenu);
    graphMenu.add(importMenu);
    graphMenu.add(addFunction);

    /* Tab context menu */
    backMenu.add(importXML);
}

From source file:jatools.component.chart.customizer.Tabs.java

protected final void initializeCustomizer(int type) {
    GridBagLayout gbl = new GridBagLayout();
    setLayout(gbl);/*from ww  w. j a v a  2  s  .  c  o m*/

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = CommonFinal.INSETS;
    gbc.fill = GridBagConstraints.BOTH;

    tp = new JTabbedPane();

    gbc.weightx = 1;
    gbc.weighty = 1;

    dataPanel = new DataSelector();
    initDataPanel();
    dataPanel.addChangeListener(this);

    dataPanel.setPrompt(dataPrompts[type]);
    dataPanel.setType(type);
    tp.add(dataPanel, "");

    initTabbed();

    add(tp, gbc);
}