Example usage for javax.swing JLabel setHorizontalAlignment

List of usage examples for javax.swing JLabel setHorizontalAlignment

Introduction

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

Prototype

@BeanProperty(visualUpdate = true, enumerationValues = { "SwingConstants.LEFT", "SwingConstants.CENTER",
        "SwingConstants.RIGHT", "SwingConstants.LEADING",
        "SwingConstants.TRAILING" }, description = "The alignment of the label's content along the X axis.")
public void setHorizontalAlignment(int alignment) 

Source Link

Document

Sets the alignment of the label's contents along the X axis.

Usage

From source file:com.hexidec.ekit.component.UnicodeDialog.java

public void init(int startIndex) {
    String customFont = Translatrix.getTranslationString("UnicodeDialogButtonFont");
    if (customFont != null && customFont.length() > 0) {
        buttonFont = new Font(Translatrix.getTranslationString("UnicodeDialogButtonFont"), Font.PLAIN, 12);
    } else {/*from   w w  w  .j a va 2 s .c o m*/
        buttonFont = new Font("Monospaced", Font.PLAIN, 12);
    }

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);

    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new GridLayout(0, 17, 0, 0));
    buttonGroup = new ButtonGroup();

    int prefButtonWidth = 32;
    int prefButtonHeight = 32;

    centerPanel.add(new JLabel(""));
    for (int labelLoop = 0; labelLoop < 16; labelLoop++) {
        JLabel jlblMarker = new JLabel(
                "x" + (labelLoop > 9 ? "" + (char) (65 + (labelLoop - 10)) : "" + labelLoop));
        jlblMarker.setHorizontalAlignment(SwingConstants.CENTER);
        jlblMarker.setVerticalAlignment(SwingConstants.CENTER);
        jlblMarker.setForeground(new Color(0.5f, 0.5f, 0.75f));
        centerPanel.add(jlblMarker);
    }

    int labelcount = 0;
    for (int counter = 0; counter < UNICODEBLOCKSIZE; counter++) {
        if ((counter % 16) == 0) {
            JLabel jlblMarker = new JLabel(
                    (labelcount > 9 ? "" + (char) (65 + (labelcount - 10)) : "" + labelcount) + "x");
            jlblMarker.setHorizontalAlignment(SwingConstants.CENTER);
            jlblMarker.setVerticalAlignment(SwingConstants.CENTER);
            jlblMarker.setForeground(new Color(0.5f, 0.5f, 0.75f));
            centerPanel.add(jlblMarker);
            labelcount++;
        }
        buttonArray[counter] = new JToggleButton(" ");
        buttonArray[counter].getModel().setActionCommand("");
        buttonArray[counter].setFont(buttonFont);
        buttonArray[counter].setBorder(
                javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED));
        buttonArray[counter].addActionListener(this);
        if (counter == 0) {
            FontRenderContext frcLocal = ((java.awt.Graphics2D) (parentEkit.getGraphics()))
                    .getFontRenderContext();
            Rectangle2D fontBounds = buttonFont.getMaxCharBounds(frcLocal);
            int maxCharWidth = (int) (Math.abs(fontBounds.getX())) + (int) (Math.abs(fontBounds.getWidth()));
            int maxCharHeight = (int) (Math.abs(fontBounds.getY())) + (int) (Math.abs(fontBounds.getHeight()));
            Insets buttonInsets = buttonArray[counter].getBorder().getBorderInsets(buttonArray[counter]);
            prefButtonWidth = maxCharWidth + buttonInsets.left + buttonInsets.right;
            prefButtonHeight = maxCharHeight + buttonInsets.top + buttonInsets.bottom;
        }
        buttonArray[counter].setPreferredSize(new Dimension(prefButtonWidth, prefButtonHeight));
        centerPanel.add(buttonArray[counter]);
        buttonGroup.add(buttonArray[counter]);
    }

    JPanel selectorPanel = new JPanel();

    jcmbBlockSelector = new JComboBox(unicodeBlocks);
    jcmbBlockSelector.setSelectedIndex(startIndex);
    jcmbBlockSelector.setActionCommand(CMDCHANGEBLOCK);
    jcmbBlockSelector.addActionListener(this);

    String[] sPages = { "1" };
    jcmbPageSelector = new JComboBox(sPages);
    jcmbPageSelector.setSelectedIndex(0);
    jcmbPageSelector.setActionCommand(CMDCHANGEBLOCK);
    jcmbPageSelector.addActionListener(this);

    selectorPanel.add(new JLabel(Translatrix.getTranslationString("SelectorToolUnicodeBlock")));
    selectorPanel.add(jcmbBlockSelector);
    selectorPanel.add(new JLabel(Translatrix.getTranslationString("SelectorToolUnicodePage")));
    selectorPanel.add(jcmbPageSelector);

    JPanel buttonPanel = new JPanel();

    JButton closeButton = new JButton(Translatrix.getTranslationString("DialogClose"));
    closeButton.setActionCommand("close");
    closeButton.addActionListener(this);
    buttonPanel.add(closeButton);

    contentPane.add(centerPanel, BorderLayout.CENTER);
    contentPane.add(selectorPanel, BorderLayout.NORTH);
    contentPane.add(buttonPanel, BorderLayout.SOUTH);

    this.pack();

    populateButtons(startIndex, 0);

    this.setVisible(true);
}

From source file:ca.phon.app.session.editor.view.session_information.SessionInfoEditorView.java

private void init() {
    setLayout(new BorderLayout());

    contentPanel = new TierDataLayoutPanel();

    dateField = createDateField();/*from   w w w .  j  ava  2  s  .  c o m*/
    dateField.getTextField().setColumns(10);
    dateField.setBackground(Color.white);

    mediaLocationField = new MediaSelectionField(getEditor().getProject());
    mediaLocationField.setEditor(getEditor());
    mediaLocationField.getTextField().setColumns(10);
    mediaLocationField.addPropertyChangeListener(FileSelectionField.FILE_PROP, mediaLocationListener);

    participantTable = new JXTable();
    participantTable.setVisibleRowCount(3);

    ComponentInputMap participantTableInputMap = new ComponentInputMap(participantTable);
    ActionMap participantTableActionMap = new ActionMap();

    ImageIcon deleteIcon = IconManager.getInstance().getIcon("actions/delete_user", IconSize.SMALL);
    final PhonUIAction deleteAction = new PhonUIAction(this, "deleteParticipant");
    deleteAction.putValue(PhonUIAction.SHORT_DESCRIPTION, "Delete selected participant");
    deleteAction.putValue(PhonUIAction.SMALL_ICON, deleteIcon);
    participantTableActionMap.put("DELETE_PARTICIPANT", deleteAction);
    participantTableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DELETE_PARTICIPANT");
    participantTableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "DELETE_PARTICIPANT");

    removeParticipantButton = new JButton(deleteAction);

    participantTable.setInputMap(WHEN_FOCUSED, participantTableInputMap);
    participantTable.setActionMap(participantTableActionMap);

    addParticipantButton = new JButton(new NewParticipantAction(getEditor(), this));
    addParticipantButton.setFocusable(false);

    ImageIcon editIcon = IconManager.getInstance().getIcon("actions/edit_user", IconSize.SMALL);
    final PhonUIAction editParticipantAct = new PhonUIAction(this, "editParticipant");
    editParticipantAct.putValue(PhonUIAction.NAME, "Edit participant...");
    editParticipantAct.putValue(PhonUIAction.SHORT_DESCRIPTION, "Edit selected participant...");
    editParticipantAct.putValue(PhonUIAction.SMALL_ICON, editIcon);
    editParticipantButton = new JButton(editParticipantAct);
    editParticipantButton.setFocusable(false);

    final CellConstraints cc = new CellConstraints();
    FormLayout participantLayout = new FormLayout("fill:pref:grow, pref, pref, pref", "pref, pref, pref:grow");
    JPanel participantPanel = new JPanel(participantLayout);
    participantPanel.setBackground(Color.white);
    participantPanel.add(new JScrollPane(participantTable), cc.xywh(1, 2, 3, 2));
    participantPanel.add(addParticipantButton, cc.xy(2, 1));
    participantPanel.add(editParticipantButton, cc.xy(3, 1));
    participantPanel.add(removeParticipantButton, cc.xy(4, 2));
    participantTable.addMouseListener(new MouseInputAdapter() {

        @Override
        public void mouseClicked(MouseEvent arg0) {
            if (arg0.getClickCount() == 2 && arg0.getButton() == MouseEvent.BUTTON1) {
                editParticipantAct.actionPerformed(new ActionEvent(arg0.getSource(), arg0.getID(), "edit"));
            }
        }

    });

    languageField = new LanguageField();
    languageField.getDocument().addDocumentListener(languageFieldListener);

    int rowIdx = 0;
    final JLabel dateLbl = new JLabel("Session Date");
    dateLbl.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(dateLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx));
    contentPanel.add(dateField, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++));

    final JLabel mediaLbl = new JLabel("Media");
    mediaLbl.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(mediaLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx));
    contentPanel.add(mediaLocationField, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++));

    final JLabel partLbl = new JLabel("Participants");
    partLbl.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(partLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx));
    contentPanel.add(participantPanel, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++));

    final JLabel langLbl = new JLabel("Language");
    langLbl.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(langLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx));
    contentPanel.add(languageField, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++));

    add(new JScrollPane(contentPanel), BorderLayout.CENTER);

    update();
}

From source file:misc.ModalityDemo.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method is invoked from the/*from   www .  ja  v a  2  s .  co  m*/
 * event-dispatching thread.
 */
private void createAndShowGUI() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gd.getDefaultConfiguration();
    Insets ins = Toolkit.getDefaultToolkit().getScreenInsets(gc);
    int sw = gc.getBounds().width - ins.left - ins.right;
    int sh = gc.getBounds().height - ins.top - ins.bottom;

    // first document

    // frame f1

    f1 = new JFrame("Book 1 (parent frame)");
    f1.setBounds(32, 32, 300, 200);
    f1.addWindowListener(closeWindow);
    // create radio buttons
    rb11 = new JRadioButton("Biography", true);
    rb12 = new JRadioButton("Funny tale", false);
    rb13 = new JRadioButton("Sonnets", false);
    // place radio buttons into a single group
    ButtonGroup bg1 = new ButtonGroup();
    bg1.add(rb11);
    bg1.add(rb12);
    bg1.add(rb13);
    JButton b1 = new JButton("OK");
    b1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // get label of selected radiobutton
            String title = null;
            if (rb11.isSelected()) {
                title = rb11.getText();
            } else if (rb12.isSelected()) {
                title = rb12.getText();
            } else {
                title = rb13.getText();
            }
            // prepend radio button label to dialogs' titles
            d2.setTitle(title + " (modeless dialog)");
            d3.setTitle(title + " (document-modal dialog)");
            d2.setVisible(true);
        }
    });
    Container cp1 = f1.getContentPane();
    // create three containers to improve layouting
    cp1.setLayout(new GridLayout(1, 3));
    // an empty container
    Container cp11 = new Container();
    // a container to layout components
    Container cp12 = new Container();
    // an empty container
    Container cp13 = new Container();
    // add a button into a separate panel
    JPanel p1 = new JPanel();
    p1.setLayout(new FlowLayout());
    p1.add(b1);
    // add radio buttons and the OK button one after another into a single column
    cp12.setLayout(new GridLayout(4, 1));
    cp12.add(rb11);
    cp12.add(rb12);
    cp12.add(rb13);
    cp12.add(p1);
    // add three containers
    cp1.add(cp11);
    cp1.add(cp12);
    cp1.add(cp13);

    // dialog d2

    d2 = new JDialog(f1);
    d2.setBounds(132, 132, 300, 200);
    d2.addWindowListener(closeWindow);
    JLabel l2 = new JLabel("Enter your name: ");
    l2.setHorizontalAlignment(SwingConstants.CENTER);
    tf2 = new JTextField(12);
    JButton b2 = new JButton("OK");
    b2.setHorizontalAlignment(SwingConstants.CENTER);
    b2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //pass a name into the document modal dialog
            l3.setText("by " + tf2.getText());
            d3.setVisible(true);
        }
    });
    Container cp2 = d2.getContentPane();
    // add label, text field and button one after another into a single column
    cp2.setLayout(new BorderLayout());
    cp2.add(l2, BorderLayout.NORTH);
    cp2.add(tf2, BorderLayout.CENTER);
    JPanel p2 = new JPanel();
    p2.setLayout(new FlowLayout());
    p2.add(b2);
    cp2.add(p2, BorderLayout.SOUTH);

    // dialog d3

    d3 = new JDialog(d2, "", Dialog.ModalityType.DOCUMENT_MODAL);
    d3.setBounds(232, 232, 300, 200);
    d3.addWindowListener(closeWindow);
    JTextArea ta3 = new JTextArea();
    l3 = new JLabel();
    l3.setHorizontalAlignment(SwingConstants.RIGHT);
    Container cp3 = d3.getContentPane();
    cp3.setLayout(new BorderLayout());
    cp3.add(new JScrollPane(ta3), BorderLayout.CENTER);
    JPanel p3 = new JPanel();
    p3.setLayout(new FlowLayout(FlowLayout.RIGHT));
    p3.add(l3);
    cp3.add(p3, BorderLayout.SOUTH);

    // second document

    // frame f4

    f4 = new JFrame("Book 2 (parent frame)");
    f4.setBounds(sw - 300 - 32, 32, 300, 200);
    f4.addWindowListener(closeWindow);
    // create radio buttons
    rb41 = new JRadioButton("Biography", true);
    rb42 = new JRadioButton("Funny tale", false);
    rb43 = new JRadioButton("Sonnets", false);
    // place radio buttons into a single group
    ButtonGroup bg4 = new ButtonGroup();
    bg4.add(rb41);
    bg4.add(rb42);
    bg4.add(rb43);
    JButton b4 = new JButton("OK");
    b4.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // get label of selected radiobutton
            String title = null;
            if (rb41.isSelected()) {
                title = rb41.getText();
            } else if (rb42.isSelected()) {
                title = rb42.getText();
            } else {
                title = rb43.getText();
            }
            // prepend radiobutton label to dialogs' titles
            d5.setTitle(title + " (modeless dialog)");
            d6.setTitle(title + " (document-modal dialog)");
            d5.setVisible(true);
        }
    });
    Container cp4 = f4.getContentPane();
    // create three containers to improve layouting
    cp4.setLayout(new GridLayout(1, 3));
    Container cp41 = new Container();
    Container cp42 = new Container();
    Container cp43 = new Container();
    // add the button into a separate panel
    JPanel p4 = new JPanel();
    p4.setLayout(new FlowLayout());
    p4.add(b4);
    // add radiobuttons and the OK button one after another into a single column
    cp42.setLayout(new GridLayout(4, 1));
    cp42.add(rb41);
    cp42.add(rb42);
    cp42.add(rb43);
    cp42.add(p4);
    //add three containers
    cp4.add(cp41);
    cp4.add(cp42);
    cp4.add(cp43);

    // dialog d5

    d5 = new JDialog(f4);
    d5.setBounds(sw - 400 - 32, 132, 300, 200);
    d5.addWindowListener(closeWindow);
    JLabel l5 = new JLabel("Enter your name: ");
    l5.setHorizontalAlignment(SwingConstants.CENTER);
    tf5 = new JTextField(12);
    tf5.setHorizontalAlignment(SwingConstants.CENTER);
    JButton b5 = new JButton("OK");
    b5.setHorizontalAlignment(SwingConstants.CENTER);
    b5.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //pass a name into the document modal dialog
            l6.setText("by " + tf5.getText());
            d6.setVisible(true);
        }
    });
    Container cp5 = d5.getContentPane();
    // add label, text field and button one after another into a single column
    cp5.setLayout(new BorderLayout());
    cp5.add(l5, BorderLayout.NORTH);
    cp5.add(tf5, BorderLayout.CENTER);
    JPanel p5 = new JPanel();
    p5.setLayout(new FlowLayout());
    p5.add(b5);
    cp5.add(p5, BorderLayout.SOUTH);

    // dialog d6

    d6 = new JDialog(d5, "", Dialog.ModalityType.DOCUMENT_MODAL);
    d6.setBounds(sw - 500 - 32, 232, 300, 200);
    d6.addWindowListener(closeWindow);
    JTextArea ta6 = new JTextArea();
    l6 = new JLabel();
    l6.setHorizontalAlignment(SwingConstants.RIGHT);
    Container cp6 = d6.getContentPane();
    cp6.setLayout(new BorderLayout());
    cp6.add(new JScrollPane(ta6), BorderLayout.CENTER);
    JPanel p6 = new JPanel();
    p6.setLayout(new FlowLayout(FlowLayout.RIGHT));
    p6.add(l6);
    cp6.add(p6, BorderLayout.SOUTH);

    // third document

    // frame f7

    f7 = new JFrame("Classics (excluded frame)");
    f7.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
    f7.setBounds(32, sh - 200 - 32, 300, 200);
    f7.addWindowListener(closeWindow);
    JLabel l7 = new JLabel("Famous writers: ");
    l7.setHorizontalAlignment(SwingConstants.CENTER);
    // create radio buttons
    rb71 = new JRadioButton("Burns", true);
    rb72 = new JRadioButton("Dickens", false);
    rb73 = new JRadioButton("Twain", false);
    // place radio buttons into a single group
    ButtonGroup bg7 = new ButtonGroup();
    bg7.add(rb71);
    bg7.add(rb72);
    bg7.add(rb73);
    Container cp7 = f7.getContentPane();
    // create three containers to improve layouting
    cp7.setLayout(new GridLayout(1, 3));
    Container cp71 = new Container();
    Container cp72 = new Container();
    Container cp73 = new Container();
    // add the label into a separate panel
    JPanel p7 = new JPanel();
    p7.setLayout(new FlowLayout());
    p7.add(l7);
    // add a label and radio buttons one after another into a single column
    cp72.setLayout(new GridLayout(4, 1));
    cp72.add(p7);
    cp72.add(rb71);
    cp72.add(rb72);
    cp72.add(rb73);
    // add three containers
    cp7.add(cp71);
    cp7.add(cp72);
    cp7.add(cp73);

    // fourth document

    // frame f8

    f8 = new JFrame("Feedback (parent frame)");
    f8.setBounds(sw - 300 - 32, sh - 200 - 32, 300, 200);
    f8.addWindowListener(closeWindow);
    JButton b8 = new JButton("Rate yourself");
    b8.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showConfirmDialog(null, "I really like my book", "Question (application-modal dialog)",
                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        }
    });
    Container cp8 = f8.getContentPane();
    cp8.setLayout(new FlowLayout(FlowLayout.CENTER, 8, 8));
    cp8.add(b8);
}

From source file:de.tor.tribes.ui.components.DatePicker.java

private void init() {
    //build Header
    for (int i = 0; i < 7; i++) {
        JLabel head = new JLabel(dayNames[i]);
        head.setBackground(GRAY);/*from w w  w . j a v a2 s .  c  om*/
        head.setOpaque(true);
        head.setPreferredSize(new Dimension(20, 20));
        head.setMinimumSize(new Dimension(20, 20));
        head.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        GridBagConstraints gbc = new GridBagConstraints();
        gbc.anchor = GridBagConstraints.PAGE_START;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridx = i;
        gbc.gridy = 0;
        gbc.insets = new Insets(2, 2, 6, 2);
        gbc.ipadx = 0;
        gbc.ipady = 0;
        gbc.weightx = 1.0;
        gbc.weighty = 0.0;
        jPanelDaySelection.add(head, gbc);
    }

    daysInMonth = new CrossedLabel[WEEKS_TO_SHOW][7];
    datesInMonth = new Date[WEEKS_TO_SHOW][7];
    for (int i = 0; i < WEEKS_TO_SHOW; i++) {
        for (int j = 0; j < 7; j++) {
            daysInMonth[i][j] = new CrossedLabel();
            daysInMonth[i][j].setPreferredSize(new Dimension(20, 20));
            daysInMonth[i][j].setMinimumSize(new Dimension(20, 20));
            daysInMonth[i][j].setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            daysInMonth[i][j].addMouseListener(new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent mouseevent) {
                    dayClicked(mouseevent);
                }
            });

            GridBagConstraints gbc = new GridBagConstraints();
            gbc.anchor = GridBagConstraints.PAGE_START;
            gbc.fill = GridBagConstraints.HORIZONTAL;
            gbc.gridx = j;
            gbc.gridy = i + 1;
            gbc.insets = new Insets(2, 2, 2, 2);
            gbc.ipadx = 0;
            gbc.ipady = 0;
            gbc.weightx = 1.0;
            gbc.weighty = 0.0;
            jPanelDaySelection.add(daysInMonth[i][j], gbc);
        }
    }

    buildCalendar();
}

From source file:burp.BurpExtender.java

private void createSettingsLabel(String label, Container cont) {
    JLabel labelField = new JLabel(label);
    labelField.setHorizontalAlignment(SwingConstants.LEFT);
    callbacks.customizeUiComponent(labelField);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = 1;//w  w  w .  ja  v a  2  s. c  om
    gbc.gridx = 0;
    gbc.insets = new Insets(0, 12, 0, 0);
    gbc.anchor = GridBagConstraints.WEST;
    cont.add(labelField, gbc);
}

From source file:LicenseGenerator.java

/**
 * Initialize the contents of the frame.
 *///w  w  w  . j a  v  a 2s  . c om
private void initialize() {
    try {
        UIManager.setLookAndFeel(new WindowsLookAndFeel());
    } catch (UnsupportedLookAndFeelException ex) {
    }

    m_frame = new JFrame();
    m_frame.setTitle("License?");
    m_frame.setResizable(false);
    m_frame.setBounds(100, 100, 496, 483);
    m_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    m_frame.getContentPane().setLayout(null);

    chkDate = new JCheckBox("?");
    chkDate.setSelected(true);
    chkDate.setBounds(6, 6, 103, 23);
    m_frame.getContentPane().add(chkDate);

    txtDate = new JTextField();
    txtDate.setText("20131231");
    txtDate.setHorizontalAlignment(SwingConstants.RIGHT);
    txtDate.setBounds(131, 7, 193, 21);
    m_frame.getContentPane().add(txtDate);
    txtDate.setColumns(10);

    chkAdapterNum = new JCheckBox("???");
    chkAdapterNum.setSelected(true);
    chkAdapterNum.setBounds(6, 37, 119, 23);
    m_frame.getContentPane().add(chkAdapterNum);

    txtAdapterNum = new JTextField();
    txtAdapterNum.setText("000012");
    txtAdapterNum.setHorizontalAlignment(SwingConstants.RIGHT);
    txtAdapterNum.setColumns(10);
    txtAdapterNum.setBounds(131, 38, 193, 21);
    m_frame.getContentPane().add(txtAdapterNum);

    chkAdapter = new JCheckBox(
            "??? (?? ???)");
    chkAdapter.setSelected(true);
    chkAdapter.setBounds(6, 76, 465, 23);
    m_frame.getContentPane().add(chkAdapter);

    chkHTTP_C = new JCheckBox("http.c");
    chkHTTP_C.setSelected(true);
    chkHTTP_C.setBounds(43, 130, 76, 23);
    m_frame.getContentPane().add(chkHTTP_C);

    txtHTTP_C = new JTextField();
    txtHTTP_C.setText("20131231");
    txtHTTP_C.setHorizontalAlignment(SwingConstants.RIGHT);
    txtHTTP_C.setBounds(131, 131, 103, 21);
    m_frame.getContentPane().add(txtHTTP_C);
    txtHTTP_C.setColumns(10);

    chkSOAP_C = new JCheckBox("soap.c");
    chkSOAP_C.setSelected(true);
    chkSOAP_C.setBounds(43, 161, 76, 23);
    m_frame.getContentPane().add(chkSOAP_C);

    txtSOAP_C = new JTextField();
    txtSOAP_C.setText("20131231");
    txtSOAP_C.setHorizontalAlignment(SwingConstants.RIGHT);
    txtSOAP_C.setColumns(10);
    txtSOAP_C.setBounds(131, 162, 103, 21);
    m_frame.getContentPane().add(txtSOAP_C);

    chkTCP_C = new JCheckBox("tcp.c");
    chkTCP_C.setSelected(true);
    chkTCP_C.setBounds(43, 192, 76, 23);
    m_frame.getContentPane().add(chkTCP_C);

    txtTCP_C = new JTextField();
    txtTCP_C.setText("20131231");
    txtTCP_C.setHorizontalAlignment(SwingConstants.RIGHT);
    txtTCP_C.setColumns(10);
    txtTCP_C.setBounds(131, 193, 103, 21);
    m_frame.getContentPane().add(txtTCP_C);

    chkUDP_C = new JCheckBox("udp.c");
    chkUDP_C.setSelected(true);
    chkUDP_C.setBounds(43, 223, 76, 23);
    m_frame.getContentPane().add(chkUDP_C);

    txtUDP_C = new JTextField();
    txtUDP_C.setText("20131231");
    txtUDP_C.setHorizontalAlignment(SwingConstants.RIGHT);
    txtUDP_C.setColumns(10);
    txtUDP_C.setBounds(131, 224, 103, 21);
    m_frame.getContentPane().add(txtUDP_C);

    chkTUXEDO_C = new JCheckBox("tuxedo.c");
    chkTUXEDO_C.setSelected(true);
    chkTUXEDO_C.setBounds(43, 254, 76, 23);
    m_frame.getContentPane().add(chkTUXEDO_C);

    txtTUXEDO_C = new JTextField();
    txtTUXEDO_C.setText("20131231");
    txtTUXEDO_C.setHorizontalAlignment(SwingConstants.RIGHT);
    txtTUXEDO_C.setColumns(10);
    txtTUXEDO_C.setBounds(131, 255, 103, 21);
    m_frame.getContentPane().add(txtTUXEDO_C);

    chkMQ_C = new JCheckBox("mq.c");
    chkMQ_C.setSelected(true);
    chkMQ_C.setBounds(43, 286, 76, 23);
    m_frame.getContentPane().add(chkMQ_C);

    txtMQ_C = new JTextField();
    txtMQ_C.setText("20131231");
    txtMQ_C.setHorizontalAlignment(SwingConstants.RIGHT);
    txtMQ_C.setColumns(10);
    txtMQ_C.setBounds(131, 287, 103, 21);
    m_frame.getContentPane().add(txtMQ_C);

    chkHTTP_S = new JCheckBox("http.s");
    chkHTTP_S.setSelected(true);
    chkHTTP_S.setBounds(283, 130, 76, 23);
    m_frame.getContentPane().add(chkHTTP_S);

    txtHTTP_S = new JTextField();
    txtHTTP_S.setText("20131231");
    txtHTTP_S.setHorizontalAlignment(SwingConstants.RIGHT);
    txtHTTP_S.setColumns(10);
    txtHTTP_S.setBounds(368, 130, 103, 21);
    m_frame.getContentPane().add(txtHTTP_S);

    chkSOAP_S = new JCheckBox("soap.s");
    chkSOAP_S.setSelected(true);
    chkSOAP_S.setBounds(283, 161, 76, 23);
    m_frame.getContentPane().add(chkSOAP_S);

    txtSOAP_S = new JTextField();
    txtSOAP_S.setText("20131231");
    txtSOAP_S.setHorizontalAlignment(SwingConstants.RIGHT);
    txtSOAP_S.setColumns(10);
    txtSOAP_S.setBounds(368, 161, 103, 21);
    m_frame.getContentPane().add(txtSOAP_S);

    chkTCP_S = new JCheckBox("tcp.s");
    chkTCP_S.setSelected(true);
    chkTCP_S.setBounds(283, 192, 76, 23);
    m_frame.getContentPane().add(chkTCP_S);

    txtTCP_S = new JTextField();
    txtTCP_S.setText("20131231");
    txtTCP_S.setHorizontalAlignment(SwingConstants.RIGHT);
    txtTCP_S.setColumns(10);
    txtTCP_S.setBounds(368, 192, 103, 21);
    m_frame.getContentPane().add(txtTCP_S);

    chkUDP_S = new JCheckBox("udp.s");
    chkUDP_S.setSelected(true);
    chkUDP_S.setBounds(283, 223, 76, 23);
    m_frame.getContentPane().add(chkUDP_S);

    txtUDP_S = new JTextField();
    txtUDP_S.setText("20131231");
    txtUDP_S.setHorizontalAlignment(SwingConstants.RIGHT);
    txtUDP_S.setColumns(10);
    txtUDP_S.setBounds(368, 223, 103, 21);
    m_frame.getContentPane().add(txtUDP_S);

    chkTUXEDO_S = new JCheckBox("tuxedo.s");
    chkTUXEDO_S.setSelected(true);
    chkTUXEDO_S.setBounds(283, 254, 76, 23);
    m_frame.getContentPane().add(chkTUXEDO_S);

    txtTUXEDO_S = new JTextField();
    txtTUXEDO_S.setText("20131231");
    txtTUXEDO_S.setHorizontalAlignment(SwingConstants.RIGHT);
    txtTUXEDO_S.setColumns(10);
    txtTUXEDO_S.setBounds(368, 254, 103, 21);
    m_frame.getContentPane().add(txtTUXEDO_S);

    chkMQ_S = new JCheckBox("mq.s");
    chkMQ_S.setSelected(true);
    chkMQ_S.setBounds(283, 286, 76, 23);
    m_frame.getContentPane().add(chkMQ_S);

    txtMQ_S = new JTextField();
    txtMQ_S.setText("20131231");
    txtMQ_S.setHorizontalAlignment(SwingConstants.RIGHT);
    txtMQ_S.setColumns(10);
    txtMQ_S.setBounds(368, 286, 103, 21);
    m_frame.getContentPane().add(txtMQ_S);

    JLabel lblAdapterType1 = new JLabel("???");
    lblAdapterType1.setBounds(43, 105, 115, 15);
    m_frame.getContentPane().add(lblAdapterType1);

    JLabel lblAdapterType2 = new JLabel("??");
    lblAdapterType2.setBounds(283, 105, 103, 15);
    m_frame.getContentPane().add(lblAdapterType2);

    JLabel lblAdapterDate1 = new JLabel("?");
    lblAdapterDate1.setHorizontalAlignment(SwingConstants.RIGHT);
    lblAdapterDate1.setBounds(168, 106, 66, 15);
    m_frame.getContentPane().add(lblAdapterDate1);

    JLabel lblAdapterDate2 = new JLabel("?");
    lblAdapterDate2.setHorizontalAlignment(SwingConstants.RIGHT);
    lblAdapterDate2.setBounds(405, 105, 66, 15);
    m_frame.getContentPane().add(lblAdapterDate2);

    JButton cmdLicense = new JButton("?license");
    cmdLicense.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            cmdLicense_click(e);
        }
    });
    cmdLicense.setBounds(302, 332, 169, 23);
    m_frame.getContentPane().add(cmdLicense);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(6, 367, 478, 82);
    m_frame.getContentPane().add(scrollPane);

    txtLicense = new JTextArea();
    txtLicense.setEditable(false);
    scrollPane.setViewportView(txtLicense);
}

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

/**
 * Creates the window//w  w w  . j  a  va2 s. c o  m
 */
@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);
}

From source file:com.diversityarrays.kdxplore.field.OriginDirectionTraversalChoicePanel.java

public OriginDirectionTraversalChoicePanel(Closure<Void> onChange) {

    this.onChange = onChange;

    Border lineBorder = new LineBorder(Color.BLACK);
    JComponent topsep, leftsep, rightsep, botsep;

    topsep = new JSeparator(JSeparator.VERTICAL);
    botsep = new JSeparator(JSeparator.VERTICAL);

    topsep.setBorder(lineBorder);//w ww  .  ja  va 2s .co  m
    botsep.setBorder(lineBorder);

    leftsep = new JSeparator(JSeparator.HORIZONTAL);
    rightsep = new JSeparator(JSeparator.HORIZONTAL);

    GBH gbh = new GBH(this);
    int y = 0;

    gbh.add(0, y, 1, 1, GBH.NONE, 1, 1, GBH.CENTER, corner_ul);
    gbh.add(1, y, 1, 1, GBH.NONE, 1, 1, GBH.WEST, crb_ul_right);
    //      gbh.add(2,y, 1,2, GBH.VERT, 1,1, GBH.CENTER, topsep);
    gbh.add(3, y, 1, 1, GBH.NONE, 1, 1, GBH.EAST, crb_ur_left);
    gbh.add(4, y, 1, 1, GBH.NONE, 1, 1, GBH.CENTER, corner_ur);
    ++y;

    gbh.add(0, y, 1, 1, GBH.NONE, 1, 1, GBH.CENTER, withInsets(crb_ul_down, new Insets(10, 0, 0, 0)));
    //         gbh.add(1,y, 1,1, GBH.NONE, 1,1, GBH.CENTER, xxx);
    //         gbh.add(2,y, 1,1, GBH.NONE, 1,1, GBH.CENTER, xxx);
    gbh.add(4, y, 1, 1, GBH.NONE, 1, 1, GBH.CENTER, withInsets(crb_ur_down, new Insets(10, 0, 0, 0)));
    ++y;

    gbh.add(0, y, 1, 1, GBH.HORZ, 1, 1, GBH.CENTER, leftsep);
    JLabel label = gbh.add(1, y, 3, 1, GBH.HORZ, 1, 1, GBH.CENTER, "Origin & Direction");
    gbh.add(4, y, 1, 1, GBH.HORZ, 1, 1, GBH.CENTER, rightsep);
    ++y;
    label.setHorizontalAlignment(JLabel.CENTER);
    label.setBorder(lineBorder);

    gbh.add(0, y, 1, 1, GBH.NONE, 1, 1, GBH.CENTER, withInsets(crb_ll_up, new Insets(0, 0, 10, 0)));
    //         gbh.add(1,y, 1,1, GBH.NONE, 1,1, GBH.CENTER, xxx);
    //      gbh.add(2,y, 1,2, GBH.VERT, 1,1, GBH.CENTER, botsep);
    //         gbh.add(2,y, 1,1, GBH.NONE, 1,1, GBH.CENTER, xxx);
    gbh.add(4, y, 1, 1, GBH.NONE, 1, 1, GBH.CENTER, withInsets(crb_lr_up, new Insets(0, 0, 10, 0)));
    ++y;

    gbh.add(0, y, 1, 1, GBH.NONE, 1, 1, GBH.CENTER, corner_ll);
    gbh.add(1, y, 1, 1, GBH.NONE, 1, 1, GBH.WEST, crb_ll_right);
    gbh.add(3, y, 1, 1, GBH.NONE, 1, 1, GBH.EAST, crb_lr_left);
    gbh.add(4, y, 1, 1, GBH.NONE, 1, 1, GBH.CENTER, corner_lr);
    ++y;

    gbh.add(0, y, 5, 1, GBH.HORZ, 1, 1, GBH.CENTER, new JSeparator(JSeparator.HORIZONTAL));
    ++y;

    gbh.add(0, y, 1, 1, GBH.NONE, 1, 1, GBH.EAST, "Traversal:");
    gbh.add(1, y, 1, 1, GBH.HORZ, 2, 1, GBH.CENTER, rbPanel);
    ++y;
}

From source file:edu.harvard.i2b2.query.QueryTopPanel.java

public void addPanel() {
    int rightmostPosition = dataModel.lastLabelPosition();
    JLabel label = new JLabel();
    label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    label.setText("and");
    label.setToolTipText("Click to change the relationship");
    label.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    label.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jAndOrLabelMouseClicked(evt);
        }//w  w  w.  j a v a2 s.  c o m
    });

    //jPanel1.add(label);
    //label.setBounds(rightmostPosition, 90, 30, 18);

    QueryConceptTreePanel panel = new QueryConceptTreePanel("Group " + (dataModel.getCurrentPanelCount() + 1),
            this);
    jPanel1.add(panel);
    panel.setBounds(rightmostPosition + 5, 0, 180, getParent().getHeight() - 100);
    jPanel1.setPreferredSize(new Dimension(rightmostPosition + 5 + 181, 150));
    jScrollPane4.setViewportView(jPanel1);

    dataModel.addPanel(panel, null, rightmostPosition + 5 + 180);

    jScrollPane4.getHorizontalScrollBar().setValue(jScrollPane4.getHorizontalScrollBar().getMaximum());
    jScrollPane4.getHorizontalScrollBar().setUnitIncrement(40);
}

From source file:dk.dma.epd.common.prototype.gui.voct.VOCTAdditionalInfoPanel.java

/**
 * Updates the chat message panel in the Swing event thread
 *///from   w  ww . j a v  a 2 s .c  o  m
public void updateChatMessagePanel() {
    // Ensure that we operate in the Swing event thread
    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                updateChatMessagePanel();
            }
        });
        return;
    }

    // Only enable send-function when there is chat data, and hence a target
    addBtn.setEnabled(true);
    messageText.setEditable(true);

    // Remove all components from the messages panel
    messagesPanel.removeAll();

    Insets insets = new Insets(0, 2, 2, 2);
    Insets insets2 = new Insets(6, 2, 0, 2);

    // if (chatData != null && chatData.getMessageCount() > 0) {

    // First, add a filler component
    int y = 0;
    messagesPanel.add(new JLabel(""),
            new GridBagConstraints(0, y++, 1, 1, 0.0, 1.0, NORTH, VERTICAL, insets, 0, 0));

    // Add the messages
    long lastMessageTime = 0;

    long ownMMSI = MaritimeCloudUtils.toMmsi(EPD.getInstance().getMaritimeId());

    for (VOCTSARInfoMessage message : EPD.getInstance().getVoctHandler().getAdditionalInformationMsgs()) {

        boolean ownMessage = false;

        if (message.getSender() == ownMMSI) {
            ownMessage = true;
        }

        // EPD.getInstance().getIdentityHandler().getActor(mmsi)

        // Check if we need to add a time label
        if (message.getDate() - lastMessageTime > PRINT_DATE_INTERVAL) {

            JLabel dateLabel = new JLabel(String.format(ownMessage ? "Added %s" : "Received %s",
                    Formatter.formatShortDateTimeNoTz(new Date(message.getDate()))));
            dateLabel.setFont(dateLabel.getFont().deriveFont(9.0f).deriveFont(Font.PLAIN));
            dateLabel.setHorizontalAlignment(SwingConstants.CENTER);
            dateLabel.setForeground(Color.LIGHT_GRAY);
            messagesPanel.add(dateLabel,
                    new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, NORTH, HORIZONTAL, insets2, 0, 0));
        }

        // Add a chat message field
        JPanel msg = new JPanel();
        msg.setBorder(new ChatMessageBorder(message, ownMessage));
        JLabel msgLabel = new ChatMessageLabel(message.getMessage(), ownMessage);
        msg.add(msgLabel);
        messagesPanel.add(msg, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, NORTH, HORIZONTAL, insets, 0, 0));

        lastMessageTime = message.getDate();
    }

    // Scroll to the bottom
    validate();
    scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum());
    messagesPanel.repaint();

    // } else if (chatData == null && noDataComponent != null) {
    // // The noDataComponent may e.g. be a message
    // messagesPanel.add(noDataComponent, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));
    // }
}