Example usage for java.awt.event MouseAdapter MouseAdapter

List of usage examples for java.awt.event MouseAdapter MouseAdapter

Introduction

In this page you can find the example usage for java.awt.event MouseAdapter MouseAdapter.

Prototype

MouseAdapter

Source Link

Usage

From source file:com.mirth.connect.client.ui.editors.transformer.TransformerPane.java

/**
 * This method is called from within the constructor to initialize the form.
 *///ww w . j a va2 s.  c o  m
public void initComponents() {

    // the available panels (cards)
    stepPanel = new BasePanel();
    blankPanel = new BasePanel();

    scriptTextArea = new MirthRTextScrollPane(null, true, SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, false);
    scriptTextArea.setBackground(new Color(204, 204, 204));
    scriptTextArea.setBorder(BorderFactory.createEtchedBorder());
    scriptTextArea.getTextArea().setEditable(false);
    scriptTextArea.getTextArea().setDropTarget(null);

    generatedScriptPanel = new JPanel();
    generatedScriptPanel.setBackground(Color.white);
    generatedScriptPanel.setLayout(new CardLayout());
    generatedScriptPanel.add(scriptTextArea, "");

    tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Step", stepPanel);

    tabbedPane.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            switchTab = (lastSelectedIndex == 0 && tabbedPane.getSelectedIndex() == 1) ? true : false;
            updateCodePanel(null);
        }
    });

    for (TransformerStepPlugin transformerStepPlugin : LoadedExtensions.getInstance()
            .getTransformerStepPlugins().values()) {
        transformerStepPlugin.initialize(this);
    }

    // establish the cards to use in the Transformer
    stepPanel.addCard(blankPanel, BLANK_TYPE);
    for (TransformerStepPlugin plugin : LoadedExtensions.getInstance().getTransformerStepPlugins().values()) {
        stepPanel.addCard(plugin.getPanel(), plugin.getPluginPointName());
    }
    transformerTablePane = new JScrollPane();
    transformerTablePane.setBorder(BorderFactory.createEmptyBorder());

    viewTasks = new JXTaskPane();
    viewTasks.setTitle("Mirth Views");
    viewTasks.setFocusable(false);
    viewTasks.add(initActionCallback("accept", "Return back to channel.",
            ActionFactory.createBoundAction("accept", "Back to Channel", "B"),
            new ImageIcon(Frame.class.getResource("images/resultset_previous.png"))));
    parent.setNonFocusable(viewTasks);
    viewTasks.setVisible(false);
    parent.taskPaneContainer.add(viewTasks, parent.taskPaneContainer.getComponentCount() - 1);

    transformerTasks = new JXTaskPane();
    transformerTasks.setTitle("Transformer Tasks");
    transformerTasks.setFocusable(false);

    transformerPopupMenu = new JPopupMenu();

    // add new step task
    transformerTasks.add(initActionCallback("addNewStep", "Add a new transformer step.",
            ActionFactory.createBoundAction("addNewStep", "Add New Step", "N"),
            new ImageIcon(Frame.class.getResource("images/add.png"))));
    JMenuItem addNewStep = new JMenuItem("Add New Step");
    addNewStep.setIcon(new ImageIcon(Frame.class.getResource("images/add.png")));
    addNewStep.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            addNewStep();
        }
    });
    transformerPopupMenu.add(addNewStep);

    // delete step task
    transformerTasks.add(initActionCallback("deleteStep", "Delete the currently selected transformer step.",
            ActionFactory.createBoundAction("deleteStep", "Delete Step", "X"),
            new ImageIcon(Frame.class.getResource("images/delete.png"))));
    JMenuItem deleteStep = new JMenuItem("Delete Step");
    deleteStep.setIcon(new ImageIcon(Frame.class.getResource("images/delete.png")));
    deleteStep.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            deleteStep();
        }
    });
    transformerPopupMenu.add(deleteStep);

    transformerTasks.add(initActionCallback("doImport", "Import a transformer from an XML file.",
            ActionFactory.createBoundAction("doImport", "Import Transformer", "I"),
            new ImageIcon(Frame.class.getResource("images/report_go.png"))));
    JMenuItem importTransformer = new JMenuItem("Import Transformer");
    importTransformer.setIcon(new ImageIcon(Frame.class.getResource("images/report_go.png")));
    importTransformer.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            doImport();
        }
    });
    transformerPopupMenu.add(importTransformer);

    transformerTasks.add(initActionCallback("doExport", "Export the transformer to an XML file.",
            ActionFactory.createBoundAction("doExport", "Export Transformer", "E"),
            new ImageIcon(Frame.class.getResource("images/report_disk.png"))));
    JMenuItem exportTransformer = new JMenuItem("Export Transformer");
    exportTransformer.setIcon(new ImageIcon(Frame.class.getResource("images/report_disk.png")));
    exportTransformer.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            doExport();
        }
    });
    transformerPopupMenu.add(exportTransformer);

    transformerTasks.add(initActionCallback("doValidate", "Validate the currently viewed script.",
            ActionFactory.createBoundAction("doValidate", "Validate Script", "V"),
            new ImageIcon(Frame.class.getResource("images/accept.png"))));
    JMenuItem validateStep = new JMenuItem("Validate Script");
    validateStep.setIcon(new ImageIcon(Frame.class.getResource("images/accept.png")));
    validateStep.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            doValidate();
        }
    });
    transformerPopupMenu.add(validateStep);

    // move step up task
    transformerTasks.add(initActionCallback("moveStepUp", "Move the currently selected step up.",
            ActionFactory.createBoundAction("moveStepUp", "Move Step Up", "P"),
            new ImageIcon(Frame.class.getResource("images/arrow_up.png"))));
    JMenuItem moveStepUp = new JMenuItem("Move Step Up");
    moveStepUp.setIcon(new ImageIcon(Frame.class.getResource("images/arrow_up.png")));
    moveStepUp.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            moveStepUp();
        }
    });
    transformerPopupMenu.add(moveStepUp);

    // move step down task
    transformerTasks.add(initActionCallback("moveStepDown", "Move the currently selected step down.",
            ActionFactory.createBoundAction("moveStepDown", "Move Step Down", "D"),
            new ImageIcon(Frame.class.getResource("images/arrow_down.png"))));
    JMenuItem moveStepDown = new JMenuItem("Move Step Down");
    moveStepDown.setIcon(new ImageIcon(Frame.class.getResource("images/arrow_down.png")));
    moveStepDown.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            moveStepDown();
        }
    });
    transformerPopupMenu.add(moveStepDown);

    // add the tasks to the taskpane, and the taskpane to the mirth client
    parent.setNonFocusable(transformerTasks);
    transformerTasks.setVisible(false);
    parent.taskPaneContainer.add(transformerTasks, parent.taskPaneContainer.getComponentCount() - 1);

    makeTransformerTable();

    // BGN LAYOUT
    transformerTable.setBorder(BorderFactory.createEmptyBorder());
    transformerTablePane.setBorder(BorderFactory.createEmptyBorder());
    transformerTablePane.setMinimumSize(new Dimension(0, 40));
    stepPanel.setBorder(BorderFactory.createEmptyBorder());

    hSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, transformerTablePane, tabbedPane);
    hSplitPane.setContinuousLayout(true);
    // hSplitPane.setDividerSize(6);
    hSplitPane.setOneTouchExpandable(true);
    vSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, hSplitPane, refPanel);
    // vSplitPane.setDividerSize(6);
    vSplitPane.setOneTouchExpandable(true);
    vSplitPane.setContinuousLayout(true);

    hSplitPane.setBorder(BorderFactory.createEmptyBorder());
    vSplitPane.setBorder(BorderFactory.createEmptyBorder());
    this.setLayout(new BorderLayout());
    this.add(vSplitPane, BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder());
    resizePanes();
    // END LAYOUT

}

From source file:de.ailis.xadrian.frames.MainFrame.java

/**
 * Installs status handler for the specified component an all its child
 * components.//from  ww w . j a va2 s  .co m
 *
 * @param component
 *            The component to install the status handler for.
 */
private void installStatusHandler(final JComponent component) {
    final JLabel statusBar = this.statusBar;
    final String text = component.getToolTipText();
    if (text != null && !text.isEmpty()) {
        component.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseExited(final MouseEvent e) {
                statusBar.setText(" ");
            }

            @Override
            public void mouseEntered(final MouseEvent e) {
                statusBar.setText(component.getToolTipText());
            }
        });
    }
    for (final Component child : component.getComponents()) {
        if (!(child instanceof JComponent))
            continue;
        installStatusHandler((JComponent) child);
    }
    if (component instanceof JMenu) {
        for (final MenuElement menuElement : ((JMenu) component).getSubElements()) {
            if (!(menuElement instanceof JComponent))
                continue;
            installStatusHandler((JComponent) menuElement);
        }
    }
}

From source file:gdt.jgui.entity.fields.JFieldsEditor.java

/**
 * Create a new facet renderer./* ww w.j  a  va  2 s. c o m*/
 * @param console the main console.
 * @param locator$ the locator string.
 * @return the fields editor.
 */
@Override
public JFacetRenderer instantiate(JMainConsole console, String locator$) {
    try {
        //System.out.println("FieldsEditor.instantiate:begin");
        this.console = console;
        Properties locator = Locator.toProperties(locator$);
        entihome$ = locator.getProperty(Entigrator.ENTIHOME);
        entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);

        requesterResponseLocator$ = locator.getProperty(JRequester.REQUESTER_RESPONSE_LOCATOR);
        table = new JTable();
        DefaultTableModel model = new DefaultTableModel(null, new String[] { "Name", "Value" });
        entigrator = console.getEntigrator(entihome$);
        entity = entigrator.getEntityAtKey(entityKey$);
        entityLabel$ = entity.getProperty("label");
        Core[] ca = entity.elementGet("field");
        if (ca != null)
            for (Core aCa : ca) {
                model.addRow(new String[] { aCa.name, aCa.value });

            }
        table.setModel(model);
        scrollPane.setViewportView(table);
        table.getTableHeader().setDefaultRenderer(new SimpleHeaderRenderer());
        table.getTableHeader().addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                int col = table.columnAtPoint(e.getPoint());
                String name = table.getColumnName(col);
                // System.out.println("Column index selected " + col + " " + name);
                sort(name);
            }
        });
    } catch (Exception e) {
        LOGGER.severe(e.toString());

    }
    return this;

}

From source file:edu.ku.brc.specify.tasks.subpane.LocalityMapperSubPane.java

/**
 *
 *//* w w w.j  a v a 2s  .  co m*/
protected void createUI() {
    kmlGen = new CollectingEventLocalityKMLGenerator();
    this.collectingEvents = new ArrayList<CollectingEvent>();

    CollectingEvent startCE = null;
    CollectingEvent endCE = null;

    Vector<Locality> localities = new Vector<Locality>();
    Vector<String> labels = new Vector<String>();
    for (Object obj : colEvents) {
        CollectingEvent collectingEvent = (CollectingEvent) obj;

        Locality locality = collectingEvent.getLocality();
        if (locality == null || locality.getLatitude1() == null || locality.getLongitude1() == null) {
            continue;
        }

        collectingEvents.add(collectingEvent);
        kmlGen.addDataObj(collectingEvent, "");

        if (collectingEvents.size() == 1) {
            startCE = collectingEvent;
            endCE = collectingEvent;
        }
        // XXX TODO FIX ME!
        if (startCE == null || endCE == null) {
            return;
        }
        // There may be an End Date that is further out than than the End Date of the last item
        // with the latest Start Date
        if (startCE.getStartDate().compareTo(collectingEvent.getStartDate()) > 1) {
            startCE = collectingEvent;
        }
        Calendar leftCal = endCE.getEndDate() != null ? endCE.getEndDate() : endCE.getStartDate();
        Calendar rightCal = collectingEvent.getEndDate() != null ? collectingEvent.getEndDate()
                : collectingEvent.getStartDate();
        if (leftCal.compareTo(rightCal) < 0) {
            endCE = collectingEvent;
        }

        Hashtable<String, Object> map = new Hashtable<String, Object>();

        Set<CollectionObject> colObjs = collectingEvent.getCollectionObjects();

        map.put("startDate", collectingEvent.getStartDate());
        map.put("endDate", collectingEvent.getEndDate());

        Set<Object> taxonNames = new HashSet<Object>();
        for (CollectionObject co : colObjs) {
            for (Determination d : co.getDeterminations()) {
                if (d.isCurrentDet()) {
                    //System.out.println(d.getTaxon().getName() + "("+co.getCountAmt()+")");
                    Taxon taxon = d.getPreferredTaxon();
                    if (taxon != null) {
                        taxonNames.add(taxon.getName()
                                + (co.getCountAmt() != null ? " (" + co.getCountAmt() + ")" : ""));
                        if (taxon.getRankId() == 220) {
                            Taxon genus = taxon.getParent();
                            if (genus.getRankId() == 180) {
                                ImageGetter imgGetter = new ImageGetter(imageGetterList, imageMap, imageURLs,
                                        genus.getName(), taxon.getName());
                                imageGetterList.add(imgGetter);
                            }
                        }
                    }
                    break;
                }
            }
        }
        map.put("taxonItems", taxonNames);

        map.put("latitude1", locality.getLatitude1());
        map.put("longitude1", locality.getLongitude1());

        /*
        Calendar cal = collectingEvent.getStartDate();
        if (cal != null)
        {
          labels.add(scrDateFormat.format(cal.getTime()));
                
        } else if (collectingEvent.getVerbatimDate() != null)
        {
          labels.add(collectingEvent.getVerbatimDate());
                
        } else
        {
          labels.add(Integer.toString(collectingEvent.getCollectingEventId()));
                
        }
        */
        labels.add(Integer.toString(collectingEvents.size()));
        localities.add(locality);
        valueList.add(map);

    }

    // XXX Fix me shouldn't be hard coded here to make it work
    localityMapper.setMaxMapWidth(515);
    localityMapper.setMaxMapHeight(375);

    Color arrow = new Color(220, 220, 220);
    localityMapper.setArrowColor(arrow);
    localityMapper.setDotColor(Color.WHITE);
    localityMapper.setDotSize(4);
    localityMapper.setLabelColor(Color.RED);

    int inx = 0;
    for (Locality locality : localities) {
        localityMapper.addLocationAndLabel(locality, labels != null ? labels.get(inx) : null);
        inx++;
    }
    localityMapper.setCurrentLoc(localities.get(0));
    localityMapper.setCurrentLocColor(Color.RED);

    // XXX DEMO  (Hard Coded 'null' means everyone would have one which may not be true)
    // "null" ViewSet name means it should use the default
    ViewIFace view = AppContextMgr.getInstance().getView("LocalityMapper");

    // TODO WHERE's the ERROR checking !
    multiView = new MultiView(null, null, view, AltViewIFace.CreationMode.VIEW, MultiView.NO_OPTIONS);
    multiView.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(new Color(138, 128, 128)),
                    BorderFactory.createEmptyBorder(4, 4, 4, 4)));

    formViewObj = multiView.getCurrentViewAsFormViewObj();
    formViewObj.getUIComponent().setBackground(Color.WHITE);

    imageJList = formViewObj.getCompById("taxonItems");
    imageJList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                String nameStr = (String) imageJList.getSelectedValue();
                if (nameStr != null) {
                    int index = nameStr.indexOf(" (");
                    if (index > -1) {
                        nameStr = nameStr.substring(0, index);
                    }
                }

                //System.out.println("Getting["+name+"]");
                Image img = null;
                if (StringUtils.isNotEmpty(nameStr)) {
                    img = imageMap.get(nameStr); // might return null
                    ImageDisplay imgDisplay = formViewObj.getCompById("image");
                    if (img != null) {
                        imgDisplay.setImage(new ImageIcon(img));
                    } else {
                        imgDisplay.setImage((Image) null);
                    }
                }

            }
        }
    });

    // XXX TODO FIX ME!
    if (startCE == null || endCE == null) {
        return;
    }
    String startDateStr = scrDateFormat.format(startCE.getStartDate().getTime());
    String endDateStr = scrDateFormat
            .format((endCE.getEndDate() != null ? endCE.getEndDate() : endCE.getStartDate()).getTime());

    Formatter formatter = new Formatter();
    titleLabel.setText(formatter
            .format(getResourceString("LocalityMapperTitle"), new Object[] { startDateStr, endDateStr })
            .toString());

    Font font = titleLabel.getFont();
    titleLabel.setFont(new Font(font.getFontName(), Font.BOLD, font.getSize() + 2));

    recordSetController = new ResultSetController(null, false, false, false, null, collectingEvents.size(),
            true);
    recordSetController.addListener(this);
    recordSetController.getPanel().setBackground(Color.WHITE);

    controlPanel = new ControlBarPanel(getBackground());
    controlPanel.add(recordSetController.getPanel());
    controlPanel.setRecordSetController(recordSetController);
    controlPanel.setBackground(Color.WHITE);

    googleBtn = new JButton(IconManager.getIcon("GoogleEarth", IconManager.STD_ICON_SIZE));
    googleBtn.setMargin(new Insets(1, 1, 1, 1));
    googleBtn.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    googleBtn.setSize(new Dimension(18, 18));
    googleBtn.setPreferredSize(new Dimension(18, 18));
    googleBtn.setMaximumSize(new Dimension(18, 18));
    googleBtn.setFocusable(false);
    googleBtn.setBackground(Color.WHITE);

    controlPanel.addButtons(new JButton[] { googleBtn }, false);

    googleBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            try {
                UIRegistry.displayStatusBarText("Exporting Collecting Events in KML."); // XXX I18N
                kmlGen.setSpeciesToImageMapper(imageURLs);
                kmlGen.outputToFile(System.getProperty("user.home") + File.separator + "specify.kml");

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

    addMouseMotionListener(new MouseMotionListener() {
        public void mouseDragged(MouseEvent e) {
            // nothing
        }

        public void mouseMoved(MouseEvent e) {
            checkMouseLocation(e.getPoint(), false);
        }
    });

    addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            checkMouseLocation(e.getPoint(), true);
        }

    });

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            getLocalityMap();
        }
    });

}

From source file:com._17od.upm.gui.MainWindow.java

private void addComponentsToPane() {

    // Ensure the layout manager is a BorderLayout
    if (!(getContentPane().getLayout() instanceof GridBagLayout)) {
        getContentPane().setLayout(new GridBagLayout());
    }// ww  w  .  j  a v  a2 s  . c om

    // Create the menubar
    setJMenuBar(createMenuBar());

    GridBagConstraints c = new GridBagConstraints();

    // The toolbar Row
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.insets = new Insets(0, 0, 0, 0);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.HORIZONTAL;
    Component toolbar = createToolBar();
    getContentPane().add(toolbar, c);

    // Keep the frame background color consistent
    getContentPane().setBackground(toolbar.getBackground());

    // The seperator Row
    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.HORIZONTAL;
    getContentPane().add(new JSeparator(), c);

    // The search field row
    searchIcon = new JLabel(Util.loadImage("search.gif"));
    searchIcon.setDisabledIcon(Util.loadImage("search_d.gif"));
    searchIcon.setEnabled(false);
    c.gridx = 0;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(5, 1, 5, 1);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    getContentPane().add(searchIcon, c);

    searchField = new JTextField(15);
    searchField.setEnabled(false);
    searchField.setMinimumSize(searchField.getPreferredSize());
    searchField.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            // This method never seems to be called
        }

        public void insertUpdate(DocumentEvent e) {
            dbActions.filter();
        }

        public void removeUpdate(DocumentEvent e) {
            dbActions.filter();
        }
    });
    searchField.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                dbActions.resetSearch();
            } else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                // If the user hits the enter key in the search field and
                // there's only one item
                // in the listview then open that item (this code assumes
                // that the one item in
                // the listview has already been selected. this is done
                // automatically in the
                // DatabaseActions.filter() method)
                if (accountsListview.getModel().getSize() == 1) {
                    viewAccountMenuItem.doClick();
                }
            }
        }
    });
    c.gridx = 1;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(5, 1, 5, 1);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    getContentPane().add(searchField, c);

    resetSearchButton = new JButton(Util.loadImage("stop.gif"));
    resetSearchButton.setDisabledIcon(Util.loadImage("stop_d.gif"));
    resetSearchButton.setEnabled(false);
    resetSearchButton.setToolTipText(Translator.translate(RESET_SEARCH_TXT));
    resetSearchButton.setActionCommand(RESET_SEARCH_TXT);
    resetSearchButton.addActionListener(this);
    resetSearchButton.setBorder(BorderFactory.createEmptyBorder());
    resetSearchButton.setFocusable(false);
    c.gridx = 2;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(5, 1, 5, 1);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    getContentPane().add(resetSearchButton, c);

    // The accounts listview row
    accountsListview = new JList();
    accountsListview.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    accountsListview.setSelectedIndex(0);
    accountsListview.setVisibleRowCount(10);
    accountsListview.setModel(new SortedListModel());
    JScrollPane accountsScrollList = new JScrollPane(accountsListview, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    accountsListview.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent e) {
            // If the listview gets focus, there is one ore more items in
            // the listview and there is nothing
            // already selected, then select the first item in the list
            if (accountsListview.getModel().getSize() > 0 && accountsListview.getSelectedIndex() == -1) {
                accountsListview.setSelectionInterval(0, 0);
            }
        }
    });
    accountsListview.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            dbActions.setButtonState();
        }
    });
    accountsListview.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                viewAccountMenuItem.doClick();
            }
        }
    });
    accountsListview.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                viewAccountMenuItem.doClick();
            }
        }
    });
    // Create a shortcut to delete account functionality with DEL(delete)
    // key

    accountsListview.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {

                try {
                    dbActions.reloadDatabaseBefore(new DeleteAccountAction());
                } catch (InvalidPasswordException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (ProblemReadingDatabaseFile e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (IOException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }

            }
        }
    });

    c.gridx = 0;
    c.gridy = 3;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 1, 1, 1);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.BOTH;
    getContentPane().add(accountsScrollList, c);

    // The "File Changed" panel
    c.gridx = 0;
    c.gridy = 4;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 1, 0, 1);
    c.ipadx = 3;
    c.ipady = 3;
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.BOTH;
    databaseFileChangedPanel = new JPanel();
    databaseFileChangedPanel.setLayout(new BoxLayout(databaseFileChangedPanel, BoxLayout.X_AXIS));
    databaseFileChangedPanel.setBackground(new Color(249, 172, 60));
    databaseFileChangedPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    JLabel fileChangedLabel = new JLabel("Database file changed");
    fileChangedLabel.setAlignmentX(LEFT_ALIGNMENT);
    databaseFileChangedPanel.add(fileChangedLabel);
    databaseFileChangedPanel.add(Box.createHorizontalGlue());
    JButton reloadButton = new JButton("Reload");
    reloadButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                dbActions.reloadDatabaseFromDisk();
            } catch (Exception ex) {
                dbActions.errorHandler(ex);
            }
        }
    });
    databaseFileChangedPanel.add(reloadButton);
    databaseFileChangedPanel.setVisible(false);
    getContentPane().add(databaseFileChangedPanel, c);

    // Add the statusbar
    c.gridx = 0;
    c.gridy = 5;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 1, 1, 1);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.HORIZONTAL;
    getContentPane().add(statusBar, c);

}

From source file:com.limegroup.gnutella.gui.GUIUtils.java

/**
 * Returns a <code>MouseListener</code> that changes the cursor and
 * notifies <code>actionListener</code> on click.
 *//*from w  ww .  ja  v a2 s .  c  o m*/
public static MouseListener getURLInputListener(final ActionListener actionListener) {
    return new MouseAdapter() {
        public void mouseEntered(MouseEvent e) {
            JComponent comp = (JComponent) e.getComponent();
            comp.getTopLevelAncestor().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        }

        public void mouseExited(MouseEvent e) {
            JComponent comp = (JComponent) e.getComponent();
            comp.getTopLevelAncestor().setCursor(Cursor.getDefaultCursor());
        }

        public void mouseClicked(MouseEvent e) {
            actionListener.actionPerformed(new ActionEvent(e.getComponent(), 0, null));
        }
    };
}

From source file:gtu._work.ui.TextScanUI.java

private void initGUI() {
    try {/* w ww . j  a  va2  s .  co m*/
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.addComponentListener(new ComponentAdapter() {
            public void componentResized(ComponentEvent evt) {
                thisComponentResized(evt);
            }
        });
        this.addWindowStateListener(new WindowStateListener() {
            public void windowStateChanged(WindowEvent evt) {
                System.out.println("this.windowStateChanged, event=" + evt);
                // TODO add your code for this.windowStateChanged
            }
        });
        this.addWindowListener(new WindowAdapter() {
            public void windowIconified(WindowEvent evt) {
                System.out.println("this.windowIconified, event=" + evt);
                // TODO add your code for this.windowIconified
            }
        });
        this.setTitle(TITLE);
        {
            jPanel1 = new JPanel();
            getContentPane().add(jPanel1, BorderLayout.NORTH);
            GroupLayout jPanel1Layout = new GroupLayout((JComponent) jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1.setPreferredSize(new java.awt.Dimension(521, 89));
            jPanel1.setBounds(0, 0, 521, 89);
            {
                jButton1 = new JButton();
                jButton1.setText("File");
                jButton1.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jButton1ActionPerformed(evt);
                    }
                });
            }
            {
                jButton2 = new JButton();
                jButton2.setText("Clipboard");
                jButton2.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jButton2ActionPerformed(evt);
                    }
                });
            }
            {
                contentFilter = new JTextField();
                contentFilter.getDocument().addDocumentListener(new DocumentListener() {
                    public void insertUpdate(DocumentEvent paramDocumentEvent) {
                        jTextField2filterAgain();
                    }

                    public void removeUpdate(DocumentEvent paramDocumentEvent) {
                        jTextField2filterAgain();
                    }

                    public void changedUpdate(DocumentEvent paramDocumentEvent) {
                        jTextField2filterAgain();
                    }
                });
            }
            {
                fileFilter = new JTextField();
                fileFilter.getDocument().addDocumentListener(new DocumentListener() {
                    public void insertUpdate(DocumentEvent paramDocumentEvent) {
                        jTextField1DocumentListener(paramDocumentEvent);
                    }

                    public void removeUpdate(DocumentEvent paramDocumentEvent) {
                        jTextField1DocumentListener(paramDocumentEvent);
                    }

                    public void changedUpdate(DocumentEvent paramDocumentEvent) {
                        jTextField1DocumentListener(paramDocumentEvent);
                    }
                });
            }
            {
                totalLabel = new JLabel();
            }
            {
                matchLabel = new JLabel();
            }
            {
                jLabel4 = new JLabel();
                jLabel4.setText("Match : ");
            }
            {
                jLabel2 = new JLabel();
                jLabel2.setText("Total : ");
            }
            {
                ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(new String[] { "All", "Match" });
                contextFilter = new JComboBox();
                contextFilter.setModel(jComboBox1Model);
                contextFilter.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jTextField2filterAgain();
                    }
                });
            }
            {
                ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(new String[] { "Regex", "find" });
                fileChk = new JComboBox();
                fileChk.setModel(jComboBox1Model);
                fileChk.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        fileChkActionPerformed(evt);
                    }
                });
            }
            {
                jScrollPane2 = new JScrollPane();
                {
                    ListModel groupListModel = new DefaultComboBoxModel();
                    groupList = new JList();
                    jScrollPane2.setViewportView(groupList);
                    groupList.setModel(groupListModel);
                    groupList.addKeyListener(new KeyAdapter() {
                        public void keyPressed(KeyEvent evt) {
                            groupListKeyPressed(evt);
                        }
                    });
                }
            }
            jPanel1Layout.setVerticalGroup(jPanel1Layout.createSequentialGroup().addContainerGap(16, 16)
                    .addGroup(jPanel1Layout.createParallelGroup()
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                            .addComponent(jButton1, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(fileFilter, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel2, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
                                            .addComponent(fileChk, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.PREFERRED_SIZE))
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addGroup(jPanel1Layout.createParallelGroup().addGroup(jPanel1Layout
                                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                                            .addComponent(jButton2, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(contentFilter, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel4, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
                                            .addComponent(contextFilter, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.PREFERRED_SIZE))
                                            .addComponent(matchLabel, GroupLayout.Alignment.LEADING,
                                                    GroupLayout.PREFERRED_SIZE, 24,
                                                    GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel1Layout.createParallelGroup()
                                    .addComponent(totalLabel, GroupLayout.Alignment.LEADING,
                                            GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jScrollPane2, GroupLayout.Alignment.LEADING,
                                            GroupLayout.PREFERRED_SIZE, 61, GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap(12, 12));
            jPanel1Layout.setHorizontalGroup(jPanel1Layout.createSequentialGroup().addContainerGap(12, 12)
                    .addGroup(jPanel1Layout.createParallelGroup()
                            .addComponent(contextFilter, GroupLayout.Alignment.LEADING,
                                    GroupLayout.PREFERRED_SIZE, 87, GroupLayout.PREFERRED_SIZE)
                            .addComponent(fileChk, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    87, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup()
                            .addComponent(jLabel4, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    45, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup()
                            .addComponent(matchLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    67, GroupLayout.PREFERRED_SIZE)
                            .addComponent(totalLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    67, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup()
                            .addComponent(contentFilter, GroupLayout.Alignment.LEADING,
                                    GroupLayout.PREFERRED_SIZE, 266, GroupLayout.PREFERRED_SIZE)
                            .addComponent(fileFilter, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    266, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel1Layout.createParallelGroup()
                            .addComponent(jButton1, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    91, GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    91, GroupLayout.PREFERRED_SIZE))
                    .addGap(19)
                    .addComponent(jScrollPane2, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(16, 16));
        }
        {
            jScrollPane1 = new JScrollPane();
            getContentPane().add(jScrollPane1, BorderLayout.CENTER);
            jScrollPane1.setPreferredSize(new java.awt.Dimension(581, 235));
            {
                ListModel jList1Model = new DefaultComboBoxModel();
                matchList = new JList();
                jScrollPane1.setViewportView(matchList);

                // matchList.setPreferredSize(new java.awt.Dimension(575,
                // 232));// ???
                // ??
                // XXX
                // TODO
                // IMPORT
                // !!!!

                matchList.addMouseListener(new MouseAdapter() {
                    public void mouseClicked(MouseEvent evt) {
                        jList1MouseClicked(evt);
                    }
                });
                matchList.setModel(jList1Model);
            }
        }
        this.setSize(697, 440);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:cz.muni.fi.javaseminar.kafa.bookregister.gui.MainWindow.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*  w  w w.  j ava  2 s . c o  m*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    authorsPanel = new javax.swing.JPanel();
    authorsLabel = new javax.swing.JLabel();
    authorsScrollPane = new javax.swing.JScrollPane();
    authorsTable = new javax.swing.JTable();
    booksPanel = new javax.swing.JPanel();
    booksScrollPane = new javax.swing.JScrollPane();
    booksTable = new javax.swing.JTable();
    booksLabel = new javax.swing.JLabel();
    mainMenuBar = new javax.swing.JMenuBar();
    fileMenu = new javax.swing.JMenu();
    newAuthorMenuItem = new javax.swing.JMenuItem();
    newBookMenuItem = new javax.swing.JMenuItem();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Book Register 1.0");
    setMinimumSize(new java.awt.Dimension(1024, 480));
    setPreferredSize(new java.awt.Dimension(1024, 640));
    getContentPane().setLayout(new java.awt.GridLayout(2, 1));

    authorsPanel.setLayout(new java.awt.BorderLayout());

    java.util.ResourceBundle bundle = java.util.ResourceBundle
            .getBundle("cz/muni/fi/javaseminar/kafa/bookregister/gui/Bundle"); // NOI18N
    authorsLabel.setText(bundle.getString("Table.authors.title")); // NOI18N
    authorsPanel.add(authorsLabel, java.awt.BorderLayout.PAGE_START);

    authorsTable.setModel(authorsTableModel);
    authorsTable.setMinimumSize(new java.awt.Dimension(480, 640));
    authorsScrollPane.setViewportView(authorsTable);

    authorsPanel.add(authorsScrollPane, java.awt.BorderLayout.CENTER);

    getContentPane().add(authorsPanel);

    booksPanel.setLayout(new java.awt.BorderLayout());

    booksTable.setModel(booksTableModel);
    booksScrollPane.setViewportView(booksTable);

    booksPanel.add(booksScrollPane, java.awt.BorderLayout.CENTER);

    booksLabel.setText(bundle.getString("Table.books.title")); // NOI18N
    booksPanel.add(booksLabel, java.awt.BorderLayout.PAGE_START);

    getContentPane().add(booksPanel);

    fileMenu.setText(bundle.getString("Menu.file")); // NOI18N

    newAuthorMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A,
            java.awt.event.InputEvent.CTRL_MASK));
    newAuthorMenuItem.setText(bundle.getString("Menu.file.newAuthor")); // NOI18N
    newAuthorMenuItem.setMnemonic(KeyEvent.VK_N);
    newAuthorMenuItem.setAction(spawnNewAuthorWindowAction);
    newAuthorMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK));
    fileMenu.add(newAuthorMenuItem);

    newBookMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B,
            java.awt.event.InputEvent.CTRL_MASK));
    newBookMenuItem.setText(bundle.getString("Menu.file.newBook")); // NOI18N
    newBookMenuItem.setMnemonic(KeyEvent.VK_B);
    newBookMenuItem.setAction(spawnNewBookWindowAction);
    newBookMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_DOWN_MASK));

    newBookMenuItem.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            JMenuItem m = (JMenuItem) e.getSource();
            if (!m.isEnabled())
                JOptionPane.showMessageDialog(MainWindow.this, "You have to create an author first.");
        }
    });
    fileMenu.add(newBookMenuItem);

    fileMenu.setMnemonic(KeyEvent.VK_F);

    mainMenuBar.add(fileMenu);

    setJMenuBar(mainMenuBar);

    pack();
}

From source file:com.qspin.qtaste.ui.reporter.TestCaseReportTable.java

public void putEntry(TestResult tr, String campaignReportName) {
    boolean isInteractiveCommand = tr.getTestCaseDirectory().endsWith("QTaste_interactive");
    String testReportName = TestResultsReportManager.getInstance().getReportName();
    boolean isManualSUTStartOrStop = testReportName != null && testReportName.startsWith("Manual SUT");
    if (interactive) {
        if (!isInteractiveCommand && !isManualSUTStartOrStop) {
            return;
        }// w w  w .ja  v  a2 s.co  m
    } else {
        if (isInteractiveCommand) {
            return;
        }
        if (campaignReportName != null && !campaignReportName.equals(runName)) {
            return;
        }
        if (campaignReportName == null && !runName.equals("Run1")) {
            return;
        }
    }
    if (!testCases.containsKey(tr)) {
        Object[] cols = new Object[7];
        cols[TEST_CASE] = convertToUniqueTc(tr);
        cols[DETAILS] = tr.getExtraResultDetails();
        if (tr.getReturnValue() != null) {
            cols[RESULT] = tr.getReturnValue();
        }
        cols[STATUS] = getImage(tr.getStatus());
        if (tr.getStatus() != TestResult.Status.RUNNING) {
            cols[EXEC_TIME] = tr.getFormattedElapsedTime(false);
        }

        TestBedConfiguration testbed = TestBedConfiguration.getInstance();
        cols[TESTBED] = testbed.getFile().getName().replace("." + StaticConfiguration.CAMPAIGN_FILE_EXTENSION,
                "");

        cols[TC] = tr;
        //tcModel.addRow(cols);
        Integer rowNum = new Integer(tcModel.getRowCount());
        testCases.put(tr, rowNum);
        long currentScrollBarMax = 0;

        JScrollPane scrollPane = (JScrollPane) tcTable.getParent().getParent();
        JScrollBar scrollbar = scrollPane.getVerticalScrollBar();
        if (scrollbar != null) {
            if (scrollbar.getMouseListeners().length == 1) {
                scrollPane.addMouseWheelListener(new MouseWheelListener() {

                    public void mouseWheelMoved(MouseWheelEvent e) {
                        userScrollPosition = true;
                    }
                });
                scrollbar.addMouseListener(new MouseAdapter() {

                    @Override
                    public void mouseClicked(MouseEvent e) {
                        userScrollPosition = true;
                    }

                    @Override
                    public void mousePressed(MouseEvent e) {
                        userScrollPosition = true;
                    }
                });
            }
            currentScrollBarMax = scrollbar.getMaximum() - scrollbar.getSize().height - tcTable.getRowHeight();
            tcModel.addRow(cols);
            if (!userScrollPosition) {
                tcTable.scrollRectToVisible(tcTable.getCellRect(tcModel.getRowCount() - 1, 0, true));
                return;
            } else if (scrollbar.getValue() >= currentScrollBarMax) {
                tcTable.scrollRectToVisible(tcTable.getCellRect(tcModel.getRowCount() - 1, 0, true));
                userScrollPosition = false;
                return;
            } else {
                System.out.println("Scrollbar pos=" + scrollbar.getValue() + "; max=" + currentScrollBarMax
                        + "height=" + scrollbar.getSize().height);
            }
        } else {
            tcModel.addRow(cols);
        }
    } else {
        updateTestCaseRow(tr);
    }

}

From source file:utybo.easypastebin.windows.MainWindow.java

/**
 * Creates the window/*from  ww  w .  j av  a2 s . c om*/
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public MainWindow() {
    EasyPastebin.LOGGER.log("Initializing the window", SinkJLevel.INFO);
    setTitle("EasyPastebin");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 664, 431);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    contentPane.add(tabbedPane, BorderLayout.CENTER);

    JPanel main = new JPanel();
    tabbedPane.addTab("EasyPastebin", null, main, null);
    main.setLayout(null);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(62, 39, 312, 132);
    main.add(scrollPane);

    pasteContent = new JTextArea();
    pasteContent.setFont(new Font("Monospaced", Font.PLAIN, 11));
    pasteContent.setWrapStyleWord(true);
    pasteContent.setLineWrap(true);
    pasteContent.setToolTipText("Put your paste here!");
    scrollPane.setViewportView(pasteContent);

    JLabel titleLabel = new JLabel("Title :");
    titleLabel.setFont(new Font("Tahoma", Font.PLAIN, 12));
    titleLabel.setBounds(10, 11, 42, 21);
    main.add(titleLabel);

    pasteTitle = new JTextField();
    pasteTitle.setBounds(62, 12, 312, 20);
    main.add(pasteTitle);
    pasteTitle.setColumns(10);

    JLabel lblPaste = new JLabel("Paste :");
    lblPaste.setForeground(Color.RED);
    lblPaste.setFont(new Font("Tahoma", Font.PLAIN, 12));
    lblPaste.setBounds(10, 85, 53, 21);
    main.add(lblPaste);

    pasteExpireDate = new JComboBox();
    pasteExpireDate.setFont(new Font("Tahoma", Font.PLAIN, 12));
    pasteExpireDate.setModel(new DefaultComboBoxModel(EnumExpireDate.values()));
    pasteExpireDate.setBounds(468, 12, 155, 21);
    main.add(pasteExpireDate);

    JLabel lblExpireDate = new JLabel("Expire Date :");
    lblExpireDate.setFont(new Font("Tahoma", Font.PLAIN, 12));
    lblExpireDate.setBounds(384, 14, 81, 14);
    main.add(lblExpireDate);

    JLabel lblfieldsInRed = new JLabel("(Fields in red are required)");
    lblfieldsInRed.setBounds(72, 182, 302, 14);
    main.add(lblfieldsInRed);

    btnSubmit = new JButton("Submit!");
    btnSubmit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            EasyPastebin.LOGGER.log("Starting Submit script", SinkJLevel.INFO);
            btnSubmit.setEnabled(false);
            btnSubmit.setText("Please wait...");

            boolean success = true;
            String paste = pasteContent.getText();
            String title = pasteTitle.getText();
            EnumExpireDate expireDate = (EnumExpireDate) pasteExpireDate.getSelectedItem();

            if (paste.equals("") || paste.equals(" ") || paste.equals(null)) {
                pastebinUrl.setText("ERROR");
                JOptionPane.showMessageDialog(null, "You cannot send empty pastes!",
                        "Error while processing paste", JOptionPane.ERROR_MESSAGE);
            } else {
                try {
                    EasyPastebin.LOGGER.log("Setting options", SinkJLevel.INFO);
                    Map map = new HashMap<String, String>();
                    map.put("api_dev_key", HttpHelper.API_KEY);
                    map.put("api_option", "paste");
                    map.put("api_paste_code", paste);
                    if (!(expireDate.equals(null) || expireDate.equals(EnumExpireDate.NEVER)))
                        map.put("api_paste_expire_date", expireDate.getRawName());
                    if (!(title.equals("") || title.equals(" ") || title.equals(null)))
                        map.put("api_paste_name", title);

                    EasyPastebin.LOGGER.log("Sending paste", SinkJLevel.INFO);
                    String actionResult = HttpHelper.sendPost("http://pastebin.com/api/api_post.php", map)
                            .asString();
                    EasyPastebin.LOGGER.log("Paste sent, checking output", SinkJLevel.INFO);
                    // Exception handlers
                    if (actionResult.equals("Bad API request, invalid api_option")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null,
                                "Error while processing paste. Incorrect Pastebin option!", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                    if (actionResult.equals("Bad API request, invalid api_dev_key")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null,
                                "Error while processing paste. Incorrect dev key! Try again with a more recent version!",
                                "Error", JOptionPane.ERROR_MESSAGE);
                    }
                    if (actionResult.equals("Bad API request, IP blocked")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null, "Error while processing paste. Your IP is blocked!",
                                "Error", JOptionPane.ERROR_MESSAGE);
                    }
                    if (actionResult.equals(
                            "Bad API request, maximum number of 25 unlisted pastes for your free account")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                    }
                    if (actionResult.equals(
                            "Bad API request, maximum number of 10 private pastes for your free account")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                    }
                    if (actionResult.equals("Bad API request, api_paste_code was empty")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                    }
                    if (actionResult.equals("Bad API request, maximum paste file size exceeded")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null,
                                "Error while processing paste. Your paste is too big!", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                    if (actionResult.equals("Bad API request, invalid api_expire_date")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null,
                                "Error while processing paste. Invalid expire date!", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                    if (actionResult.equals("Bad API request, invalid api_paste_private")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null,
                                "Error while processing paste. Invalid privacy value!", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                    if (actionResult.equals("Bad API request, invalid api_paste_format")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null, "Error while processing paste. Invalid format!",
                                "Error", JOptionPane.ERROR_MESSAGE);
                    }
                    // END

                    // Starting display stuff
                    if (success == false) {
                        EasyPastebin.LOGGER.log("Submit script failed : success == false", SinkJLevel.ERROR);
                        pastebinUrl.setText("ERROR");
                    }
                    if (success == true) {
                        EasyPastebin.LOGGER.log("Paste sent! Starting display script!", SinkJLevel.INFO);
                        pastebinUrl.setText(actionResult);
                        JOptionPane.showMessageDialog(null, "Paste successfully sent!", "Done!",
                                JOptionPane.INFORMATION_MESSAGE);
                        EasyPastebin.LOGGER.log("Display script finished! Paste URL is : " + actionResult,
                                SinkJLevel.INFO);
                    }

                } catch (ClientProtocolException e) {
                    EasyPastebin.LOGGER.log("Unexpected error! " + e, SinkJLevel.ERROR);
                    JOptionPane.showMessageDialog(null, "Error while processing paste : " + e, "Error",
                            JOptionPane.ERROR_MESSAGE);
                    e.printStackTrace();
                } catch (IOException e) {
                    EasyPastebin.LOGGER.log("Unexpected error! " + e, SinkJLevel.ERROR);
                    JOptionPane.showMessageDialog(null, "Error while processing paste : " + e, "Error",
                            JOptionPane.ERROR_MESSAGE);
                    e.printStackTrace();
                } catch (MissingParamException e) {
                    EasyPastebin.LOGGER.log("Unexpected error! " + e, SinkJLevel.ERROR);
                    JOptionPane.showMessageDialog(null, "Error while processing paste : " + e
                            + "! This is a severe programming error! Try again with a more recent version!",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    e.printStackTrace();
                }
            }

            EasyPastebin.LOGGER.log("Re-enabling the Submit button ", SinkJLevel.INFO);
            btnSubmit.setEnabled(true);
            btnSubmit.setText("Submit another paste!");
            EasyPastebin.LOGGER.log("Finished submit script! Success : " + success, SinkJLevel.INFO);
        }
    });
    btnSubmit.setBounds(386, 45, 237, 44);
    main.add(btnSubmit);

    pastebinUrl = new JTextField();
    pastebinUrl.setText("The paste's URL will be shown here!");
    pastebinUrl.setEditable(false);
    pastebinUrl.setBounds(384, 198, 239, 32);
    main.add(pastebinUrl);
    pastebinUrl.setColumns(10);

    JPanel about = new JPanel();
    tabbedPane.addTab("About", null, about, null);

    JLabel label = new JLabel("EasyPastebin");
    label.setBounds(12, 12, 623, 39);
    label.setHorizontalAlignment(SwingConstants.CENTER);
    label.setFont(new Font("Dialog", Font.PLAIN, 25));

    JLabel lblTheEasiestWay = new JLabel("The easiest way to use Pastebin.com");
    lblTheEasiestWay.setBounds(12, 63, 623, 32);
    lblTheEasiestWay.setFont(new Font("Dialog", Font.PLAIN, 16));
    lblTheEasiestWay.setHorizontalAlignment(SwingConstants.CENTER);
    about.setLayout(null);
    about.add(label);
    about.add(lblTheEasiestWay);

    JButton btnForkM = new JButton("Fork me on Github!");
    btnForkM.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            goToUrl("https://github.com/utybo/EasyPastebin");
        }
    });
    btnForkM.setBounds(12, 117, 623, 25);
    about.add(btnForkM);

    JButton btnCheckOutUtybos = new JButton("Check out utybo's projects!");
    btnCheckOutUtybos.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            goToUrl("http://utybo.github.io/");
        }
    });
    btnCheckOutUtybos.setBounds(12, 154, 623, 25);
    about.add(btnCheckOutUtybos);

    JButton btnGoToPastebincom = new JButton("Go to Pastebin.com!");
    btnGoToPastebincom.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            goToUrl("http://www.pastebin.com");
        }
    });
    btnGoToPastebincom.setBounds(12, 191, 623, 25);
    about.add(btnGoToPastebincom);

    JLabel lblcUtybo = new JLabel(
            "This soft was made by utybo. It uses Apache's libraries for the interaction with Pastebin's API");
    lblcUtybo.setFont(new Font("Dialog", Font.PLAIN, 10));
    lblcUtybo.setHorizontalAlignment(SwingConstants.CENTER);
    lblcUtybo.setBounds(12, 324, 623, 15);
    about.add(lblcUtybo);

    JLabel lblClickMeTo = new JLabel("Click me to go to Apache's licence official website");
    lblClickMeTo.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            goToUrl("http://www.apache.org/licenses/LICENSE-2.0");
        }
    });
    lblClickMeTo.setHorizontalAlignment(SwingConstants.CENTER);
    lblClickMeTo.setFont(new Font("Dialog", Font.PLAIN, 10));
    lblClickMeTo.setBounds(12, 342, 623, 15);
    about.add(lblClickMeTo);

    setVisible(true);

    EasyPastebin.LOGGER.log("Done!", SinkJLevel.INFO);
}