List of usage examples for javax.swing JTextField JTextField
public JTextField()
TextField
. From source file:net.aepik.alasca.gui.util.LoadFileFrame.java
/** * Build new LoadFileFrame object.//from w w w . ja v a2 s . co m */ public LoadFileFrame(JFrame f, SchemaManager m) { super(f, "Ouvrir un fichier Schema", true); this.setSize(400, 380); this.setResizable(false); this.setLocationRelativeTo(f); this.mainFrame = f; this.manager = m; this.filename = new JTextField(); this.syntaxes = new JComboBox(); this.boutonOpenFile = new JButton("..."); this.boutonOk = new JButton("Charger"); this.boutonAnnuler = new JButton("Annuler"); this.errorMessage = ""; initFrame(); }
From source file:au.org.ala.delta.ui.SearchDialog.java
/** * Create the dialog./*from w w w . j av a 2 s . co m*/ */ public SearchDialog(SearchController controller) { super(UIUtils.getParentFrame(controller.getOwningComponent())); hookInternalFrame(controller.getOwningComponent()); _controller = controller; UIUtils.centerDialog(this, controller.getOwningComponent().getParent()); setTitle(controller.getTitle()); setName(_controller.getTitle()); setBounds(100, 100, 366, 229); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); SingleFrameApplication application = (SingleFrameApplication) Application.getInstance(); ResourceMap messages = application.getContext().getResourceMap(); JLabel lblFind = new JLabel(messages.getString("searchDialog.lblFind")); lblFind.setMinimumSize(new Dimension(30, 0)); textField = new JTextField(); textField.setColumns(10); JPanel panel = new JPanel(); panel.setBorder(new TitledBorder(null, messages.getString("searchDialog.groupDirection"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); buttonGroup = new ButtonGroup(); rdbtnForwards = new JRadioButton(messages.getString("searchDialog.directionForwards")); rdbtnForwards.setSelected(true); buttonGroup.add(rdbtnForwards); rdbtnBackwards = new JRadioButton(messages.getString("searchDialog.directionBackwards")); buttonGroup.add(rdbtnBackwards); contentPanel.setLayout(new MigLayout("", "[growprio 0,grow,left][grow][grow]", "[20px][21px,grow][grow]")); contentPanel.add(lblFind, "cell 0 0,alignx left,aligny top"); contentPanel.add(textField, "cell 1 0 2 1,growx,aligny top"); final JPanel panel_1 = new JPanel(); panel_1.setBorder(new TitledBorder(null, messages.getString("searchDialog.optionsPanelTitle"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); contentPanel.add(panel_1, "cell 0 1 2 1,grow"); panel_1.setLayout(new BoxLayout(panel_1, BoxLayout.Y_AXIS)); chckbxMatchCase = new JCheckBox(messages.getString("searchDialog.lblMatchCase")); panel_1.add(chckbxMatchCase); chckbxWrapSearch = new JCheckBox(messages.getString("searchDialog.lblWrapSearch")); panel_1.add(chckbxWrapSearch); chckbxWrapSearch.setSelected(true); contentPanel.add(panel, "cell 2 1,grow"); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(rdbtnForwards); panel.add(rdbtnBackwards); { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton findButton = new JButton(messages.getString("searchDialog.btnFindNext")); findButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { findNext(); } }); buttonPane.add(findButton); getRootPane().setDefaultButton(findButton); } { JButton cancelButton = new JButton(messages.getString("searchDialog.btnCancel")); buttonPane.add(cancelButton); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }); } } }
From source file:com.funambol.json.admin.JsonConnectorConfigPanel.java
/** * Create the panel//from ww w . ja va2 s. c o m */ private void init() { JLabel title, serverLabel; JPanel seccPanel; JPanel behaviourOnErrorsPanel; title = new JLabel(); seccPanel = new JPanel(); behaviourOnErrorsPanel = new JPanel(); serverLabel = new JLabel(); serverValue = new JTextField(); setLayout(null); title.setFont(titlePanelFont); title.setText("Funambol Json Connector"); title.setBounds(new Rectangle(14, 5, 316, 28)); title.setAlignmentX(SwingConstants.CENTER); title.setBorder(new TitledBorder("")); seccPanel.setLayout(null); seccPanel.setBorder(new TitledBorder("HTTP Server Configuration")); serverLabel.setText("Server:"); seccPanel.add(serverLabel); serverLabel.setBounds(10, 20, 116, 15); seccPanel.add(serverValue); serverValue.setBounds(150, 20, 220, 19); serverValue.setFont(defaultFont); add(seccPanel); seccPanel.setBounds(10, 50, 380, 70); //the ssl option panel behaviourOnErrorsPanel.setBorder(new TitledBorder("Behaviour on errors")); behaviourOnErrorsPanel.setLayout(null); stopSyncOnFatalError.setText("Stop sync on fatal errors"); stopSyncOnFatalError.setBounds(10, 25, 200, 15); behaviourOnErrorsPanel.add(stopSyncOnFatalError); add(behaviourOnErrorsPanel); behaviourOnErrorsPanel.setBounds(10, 130, 380, 60); confirmButton.setFont(defaultFont); confirmButton.setText("Save"); add(confirmButton); confirmButton.setBounds(160, 200, 70, 25); confirmButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { validateValues(); getValues(); JsonConnectorConfigPanel.this.actionPerformed(new ActionEvent(JsonConnectorConfigPanel.this, ACTION_EVENT_UPDATE, event.getActionCommand())); } catch (Exception e) { notifyError(new AdminException(e.getMessage())); } } }); // // Setting font... // Component[] components = getComponents(); for (int i = 0; (components != null) && (i < components.length); ++i) { components[i].setFont(defaultFont); } // // We add it as the last one so that the font won't be changed // add(title); }
From source file:com.xtructure.xevolution.gui.components.CollectArgsDialog.java
/** * Creates a new {@link CollectArgsDialog} * /*from ww w . j a va 2 s .c o m*/ * @param frame * the parent JFrame for the new {@link CollectArgsDialog} * @param statusBar * the {@link StatusBar} to update (can be null) * @param title * the title of the new {@link CollectArgsDialog} * @param xOptions * the {@link Collection} of {@link XOption}s for which to * collect user input */ public CollectArgsDialog(JFrame frame, final StatusBar statusBar, String title, final Collection<XOption<?>> xOptions) { super(frame, title, true); argComponents = new ArrayList<JComponent>(); final CollectArgsDialog dialog = this; JPanel panel = new JPanel(new GridBagLayout()); getContentPane().add(panel); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(3, 3, 3, 3); c.fill = GridBagConstraints.BOTH; int row = 0; for (XOption<?> xOption : xOptions) { if (xOption.getName() == null) { continue; } if (xOption.hasArg()) { JLabel label = new JLabel(xOption.getName()); JTextField textField = new JTextField(); textField.setName(xOption.getOpt()); textField.setToolTipText(xOption.getDescription()); argComponents.add(textField); c.gridx = 0; c.gridy = row; panel.add(label, c); c.gridx = 1; c.gridy = row; panel.add(textField, c); } else { JCheckBox checkBox = new JCheckBox(xOption.getName()); checkBox.setName(xOption.getOpt()); checkBox.setToolTipText(xOption.getDescription()); argComponents.add(checkBox); c.gridx = 0; c.gridy = row; panel.add(checkBox, c); } row++; } JPanel buttonPanel = new JPanel(); c.gridx = 1; c.gridy = row; panel.add(buttonPanel, c); JButton okButton = new JButton(new AbstractAction("OK") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); if (statusBar != null) { statusBar.setMessage("building args..."); } ArrayList<String> args = new ArrayList<String>(); for (JComponent component : argComponents) { if (component instanceof JCheckBox) { JCheckBox checkbox = (JCheckBox) component; String opt = checkbox.getName(); if (checkbox.isSelected()) { args.add("-" + opt); } } if (component instanceof JTextField) { JTextField textField = (JTextField) component; String opt = textField.getName(); String text = textField.getText().trim(); if (!text.isEmpty()) { args.add("-" + opt); args.add("\"" + text + "\""); } } } if (statusBar != null) { statusBar.setMessage("parsing args..."); } try { Options options = new Options(); for (XOption<?> xOpt : xOptions) { options.addOption(xOpt); } XOption.parseArgs(options, args.toArray(new String[0])); dialog.success = true; } catch (ParseException e1) { e1.printStackTrace(); dialog.success = false; } if (statusBar != null) { statusBar.clearMessage(); } } }); buttonPanel.add(okButton); getRootPane().setDefaultButton(okButton); buttonPanel.add(new JButton(new AbstractAction("Cancel") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); if (statusBar != null) { statusBar.clearMessage(); } } })); pack(); setLocationRelativeTo(frame); setVisible(true); }
From source file:gtu._work.ui.LoadJspFetchJavascriptUI.java
private void initGUI() { try {//from ww w .j a v a 2s.c o m BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); jTabbedPane1.setPreferredSize(new java.awt.Dimension(436, 153)); { jPanel1 = new JPanel(); jTabbedPane1.addTab("jPanel1", null, jPanel1, null); jPanel1.setPreferredSize(new java.awt.Dimension(431, 125)); { jLabel1 = new JLabel(); jPanel1.add(jLabel1); jLabel1.setText("\u6a94\u6848\u8def\u5f91"); } { filePathText = new JTextField(); JCommonUtil.jTextFieldSetFilePathMouseEvent(filePathText, true); jPanel1.add(filePathText); filePathText.setPreferredSize(new java.awt.Dimension(354, 24)); } { jLabel2 = new JLabel(); jPanel1.add(jLabel2); jLabel2.setText("\u7db2\u9801\u526f\u6a94\u540d"); jLabel2.setPreferredSize(new java.awt.Dimension(81, 17)); } { subNameText = new JTextField(); jPanel1.add(subNameText); subNameText.setPreferredSize(new java.awt.Dimension(282, 24)); } { jLabel3 = new JLabel(); jPanel1.add(jLabel3); jLabel3.setText("\u8981\u6293\u7684TagPattern"); jLabel3.setPreferredSize(new java.awt.Dimension(115, 17)); } { tagPatternText = new JTextField(); jPanel1.add(tagPatternText); tagPatternText.setPreferredSize(new java.awt.Dimension(259, 24)); } { executeBtn = new JButton(); jPanel1.add(executeBtn); executeBtn.setText(""); executeBtn.setPreferredSize(new java.awt.Dimension(180, 45)); executeBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { executeBtnActionPerformed(evt); } }); } } } pack(); this.setSize(452, 218); } catch (Exception e) { //add your error handling code here e.printStackTrace(); } }
From source file:gtu._work.ui.EstoreDAOCodeGenerateUI.java
private void initGUI() { try {//www. jav a 2s . c o m BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); jTabbedPane1.setPreferredSize(new java.awt.Dimension(717, 582)); { jPanel1 = new JPanel(); GridLayout jPanel1Layout = new GridLayout(15, 1); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("", null, jPanel1, null); { jLabel1 = new JLabel(); jPanel1.add(jLabel1); jLabel1.setText("entity\u540d\u7a31"); } { entityNameText = new JTextField(); jPanel1.add(entityNameText); } { jLabel4 = new JLabel(); jPanel1.add(jLabel4); jLabel4.setText("DAOImpl\u540d\u7a31"); } { daoImplText = new JTextField(); jPanel1.add(daoImplText); } { jLabel5 = new JLabel(); jPanel1.add(jLabel5); jLabel5.setText("DAOInterface\u540d\u7a31"); } { daoInterfaceText = new JTextField(); jPanel1.add(daoInterfaceText); } { updateBtn = new JButton(); jPanel1.add(updateBtn); updateBtn.setText("\u66f4\u65b0"); updateBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { updateBtnActionPerformed(evt); } }); } { makeFileBtn = new JButton(); jPanel1.add(makeFileBtn); makeFileBtn.setText("\u7522\u751f\u6a94\u6848"); makeFileBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { makeFileBtnActionPerformed(evt); } catch (IOException e) { JCommonUtil.handleException(e); } } }); } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("xml", null, jPanel2, null); { jScrollPane1 = new JScrollPane(); jPanel2.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(712, 458)); { jScrollPane2 = new JScrollPane(); jScrollPane1.setViewportView(jScrollPane2); { xmlConfigArea = new JTextArea(); jScrollPane2.setViewportView(xmlConfigArea); } } } } } pack(); this.setSize(733, 525); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.cds06.speleograph.graph.ValueAxisEditor.java
/** * {@inheritDoc}//from w ww . ja v a 2s .c om */ @Override protected void setup() { PanelBuilder builder = new PanelBuilder(getFormLayout(), getPanel()); CellConstraints cc = new CellConstraints(); Dimension d = maxModifier.getPreferredSize(); maxModifier.setPreferredSize(new Dimension(d.width + 50, d.height)); d = minModifier.getPreferredSize(); minModifier.setPreferredSize(new Dimension(d.width + 50, d.height)); { builder.add(new JLabel("Titre de l'axe :")); final JTextField axisTitleField = new JTextField(); axisTitleField.setText(axis.getLabel()); builder.nextColumn(2); builder.add(axisTitleField, cc.xyw(3, 1, 5)); addListenerOnSuccess(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String text = axisTitleField.getText(); if (text != null && !text.equals("")) axis.setLabel(axisTitleField.getText()); } }); } { builder.nextLine(2); builder.add(new JLabel("Valeur min. :")); builder.nextColumn(2); builder.add(lowField); addListenerOnSuccess(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Double value = Double.valueOf(lowField.getText()); if (isApply) { axis.setLowerBound(value); } else if (isCancel && oldLowValue != null) axis.setLowerBound(oldLowValue); } catch (NumberFormatException e1) { canClose = false; JOptionPane.showMessageDialog(ValueAxisEditor.this.getParent(), "'" + lowField.getText() + "' n'est pas un nombre", "Erreur", JOptionPane.ERROR_MESSAGE); } } }); builder.nextColumn(2); builder.add(new JLabel("+")); builder.nextColumn(2); builder.add(minModifier); } { builder.nextLine(2); builder.add(new JLabel("Valeur max. :")); builder.nextColumn(2); builder.add(maxField); addListenerOnSuccess(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Double value = Double.valueOf(maxField.getText()); if (isApply) { axis.setUpperBound(value); } else if (isCancel && oldHighValue != null) axis.setUpperBound(oldHighValue); } catch (NumberFormatException e1) { canClose = false; JOptionPane.showMessageDialog(ValueAxisEditor.this.getParent(), "'" + maxField.getText() + "' n'est pas un nombre", "Erreur", JOptionPane.ERROR_MESSAGE); } } }); builder.nextColumn(2); builder.add(new JLabel("+")); builder.nextColumn(2); builder.add(maxModifier); } { builder.nextLine(2); builder.add(new JLabel("<HTML><strong>Sries associes l'axe</strong></HTML>"), cc.xyw(1, 7, 3)); String linkedSeries = "<html><ul>"; for (Series series : Series.getInstances()) { if (series.getAxis().equals(axis)) linkedSeries += "<li>" + series.toString(true) + "</li>"; } linkedSeries += "</ul></html>"; builder.add(new JLabel(linkedSeries), cc.xyw(1, 8, 3)); } JPanel buttonPanel = new JPanel(); ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(buttonPanel); buttonBuilder.addGlue(); { buttonBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("cancel")); } @Override public void actionPerformed(ActionEvent e) { isCancel = true; isApply = false; canClose = true; validateForm(); } }); } { buttonBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("apply")); } @Override public void actionPerformed(ActionEvent e) { isCancel = false; isApply = true; canClose = false; validateForm(); } }); } { buttonBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("ok")); } @Override public void actionPerformed(ActionEvent e) { isCancel = false; isApply = true; canClose = true; validateForm(); } }); } buttonBuilder.build(); buttonPanel.setVisible(true); builder.add(buttonBuilder.getPanel(), cc.xyw(1, 10, 10)); { translateSlider.setToolTipText("Translation des axes"); translateSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int maxValue = -translateSlider.getValue(); maxModifier.setText(String.valueOf(maxValue)); int lowValue = -translateSlider.getValue(); minModifier.setText(String.valueOf(lowValue)); } }); builder.add(translateSlider, cc.xywh(9, 1, 1, 8)); } { homotSlider.setToolTipText("Homothtie sur les axes"); homotSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int maxValue = -homotSlider.getValue(); maxModifier.setText(String.valueOf(maxValue)); int lowValue = homotSlider.getValue(); minModifier.setText(String.valueOf(lowValue)); } }); builder.add(homotSlider, cc.xywh(10, 1, 1, 8)); } builder.build(); getPanel().setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); addListenerOnSuccess(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (canClose) setVisible(false); } }); }
From source file:TrackEvent.java
public void init() { Container c = getContentPane(); c.setLayout(new GridLayout(event.length + 1, 2)); for (int i = 0; i < event.length; i++) { JTextField t = new JTextField(); t.setEditable(false);/* ww w .j a v a 2 s . c o m*/ c.add(new JLabel(event[i], JLabel.RIGHT)); c.add(t); h.put(event[i], t); } c.add(b1); c.add(b2); }
From source file:biomine.bmvis2.pipeline.TextFilterShower.java
public JComponent getSettingsComponent(final SettingsChangeCallback v, VisualGraph graph) { JPanel ret = new JPanel(); final JTextField filterField = new JTextField(); ret.add(filterField);/*from w ww.j a v a 2s.c o m*/ filterField.getDocument().addDocumentListener(new DocumentListener() { private void update() { if (filterField.getText().equals("")) return; if (filterField.getText().equals(TextFilterShower.this.filter)) return; TextFilterShower.this.filter = filterField.getText(); v.settingsChanged(false); } public void insertUpdate(DocumentEvent documentEvent) { this.update(); } public void removeUpdate(DocumentEvent documentEvent) { this.update(); } public void changedUpdate(DocumentEvent documentEvent) { this.update(); } }); return ret; }
From source file:utybo.easypastebin.windows.MainWindow.java
/** * Creates the window/*w w w . j a v a2s . 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); }