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:zxmax.tools.timerreview.gui.StartTimerWindow.java

private Component getPnlNewTimer() {
    setTitle(I18N.getLabel(getClass(), "window.title"));
    JPanel pnlNewTimer = new JPanel();
    LayoutManager layout = new MigLayout("flowy", "[328.00][grow,fill]", "[][][][][]");
    taFocusOn = new JTextArea();
    taFocusOn.setWrapStyleWord(true);/*w ww  .j a  va2 s . c  om*/
    JScrollPane spFocusOn = new JScrollPane();
    tfTitle = new JTextField(30);
    JButton btnStart = new JButton();

    pnlNewTimer.setLayout(layout);
    btnStart.setText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_BTN_START_LABEL));
    taFocusOn.setColumns(20);
    taFocusOn.setForeground(new Color(0, 153, 0));
    taFocusOn.setRows(5);
    taFocusOn.setTabSize(2);
    taFocusOn.setText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_FOCUS_ON_TEXT_AREA_TEXT));
    taFocusOn.setToolTipText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_FOCUS_ON_TEXT_AREA_TOOL_TIP));
    spFocusOn.setViewportView(taFocusOn);
    taFocusOn.getAccessibleContext().setAccessibleName("taFocusOn");

    btnStart.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent evt) {
            storeDataAndStartTimer();
        }
    });
    btnStart.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            logger.debug(evt.getKeyCode() + ", " + evt.getKeyChar());
            if (KeyEvent.VK_ENTER == evt.getKeyCode()) {
                storeDataAndStartTimer();
            }
        }
    });

    JLabel lblTitle = new JLabel(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_TITLE_LABEL));

    pnlNewTimer.add(lblTitle, "cell 0 0");
    pnlNewTimer.add(tfTitle, "cell 0 1 2 1,growx");
    JLabel lblFocusOn = new JLabel(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_FOCUS_ON_LABEL));
    pnlNewTimer.add(lblFocusOn, "cell 0 2");
    pnlNewTimer.add(spFocusOn, "cell 0 3 2 1,growx");
    pnlNewTimer.add(btnStart, "cell 0 4 2 1,growx");

    Box horizontalBox = Box.createHorizontalBox();
    pnlNewTimer.add(horizontalBox, "flowx,cell 1 0");

    JLabel lblDurata = new JLabel(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_DURATA_LABEL));
    lblDurata.setHorizontalAlignment(SwingConstants.RIGHT);
    pnlNewTimer.add(lblDurata, "cell 1 0,alignx right");
    lblDurata.setLabelFor(txtDurata);

    txtDurata = new JTextField("20");
    txtDurata.setToolTipText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_DURATA_TOOL_TIP));
    pnlNewTimer.add(txtDurata, "cell 1 0,alignx center");
    txtDurata.setColumns(2);

    return pnlNewTimer;
}