Example usage for java.awt Component LEFT_ALIGNMENT

List of usage examples for java.awt Component LEFT_ALIGNMENT

Introduction

In this page you can find the example usage for java.awt Component LEFT_ALIGNMENT.

Prototype

float LEFT_ALIGNMENT

To view the source code for java.awt Component LEFT_ALIGNMENT.

Click Source Link

Document

Ease-of-use constant for getAlignmentX .

Usage

From source file:CoordinatesDemo.java

private void buildUI(Container container) {
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));

    CoordinateArea coordinateArea = new CoordinateArea(this);
    container.add(coordinateArea);/* w ww. j  ava 2s.c  om*/

    label = new JLabel();
    resetLabel();
    container.add(label);

    coordinateArea.setAlignmentX(Component.LEFT_ALIGNMENT);
    label.setAlignmentX(Component.LEFT_ALIGNMENT); // redundant
}

From source file:gdt.jgui.console.JItemPanel.java

/**
 * The constructor.//from  w  w  w  .j ava2s  . c  om
 * @param console the main console.
 * @param locator$ the item's locator.
 */
public JItemPanel(JMainConsole console, String locator$) {
    this.console = console;
    this.locator$ = locator$;
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    setAlignmentX(Component.LEFT_ALIGNMENT);
    try {
        this.console = console;
        this.locator$ = locator$;
        Properties locator = Locator.toProperties(locator$);
        if (Locator.LOCATOR_TRUE.equals(locator.getProperty(Locator.LOCATOR_CHECKABLE))) {
            checkbox = new JCheckBox();
            add(checkbox);
            if (Locator.LOCATOR_TRUE.equals(locator.getProperty(Locator.LOCATOR_CHECKED)))
                if (checkbox != null)
                    checkbox.setSelected(true);
        }
        title$ = locator.getProperty(Locator.LOCATOR_TITLE);
        if (title$ != null) {
            title = new JLabel(title$, JLabel.LEFT);
            title.setText(title$);
            title.setOpaque(true);
            title.addMouseListener(new MousePopupListener());
            title.setAlignmentX(Component.LEFT_ALIGNMENT);
            add(title, BorderLayout.WEST);
            icon$ = locator.getProperty(Locator.LOCATOR_ICON);
            if (icon$ != null) {
                byte[] ba = Base64.decodeBase64(icon$);
                ImageIcon icon = new ImageIcon(ba);
                Image image = icon.getImage().getScaledInstance(24, 24, 0);
                icon.setImage(image);
                title.setIcon(icon);
            }
        } else
            LOGGER.info("title is null");

    } catch (Exception e) {
        LOGGER.severe(e.toString());

    }
}

From source file:com.adito.agent.client.gui.awt.AbstractAWTGUI.java

/**
 * Constructor./*from  w w w . ja  va2  s  .c o m*/
 */
public AbstractAWTGUI() {
    OptionDialog.INFORMATION_ICON = "/images/dialog-information.gif"; //$NON-NLS-1$
    OptionDialog.WARNING_ICON = "/images/dialog-warning.gif"; //$NON-NLS-1$
    OptionDialog.QUESTION_ICON = "/images/dialog-question.gif"; //$NON-NLS-1$
    OptionDialog.ERROR_ICON = "/images/dialog-error.gif"; //$NON-NLS-1$
    popup = new Toaster(Toaster.BOTTOM_RIGHT, new Dimension(300, 100));
    popup.setTextAlign(Component.LEFT_ALIGNMENT);
    Font norm = new Font("Arial", Font.PLAIN, 10); //$NON-NLS-1$
    Font title = new Font("Arial Bold", Font.BOLD, 11); //$NON-NLS-1$
    popup.setTextFont(norm);
    popup.setTitleFont(title);
    popupImage = UIUtil.loadImage(AbstractAWTGUI.class, "/images/agent.gif");

}

From source file:SelectionDemo.java

private void buildUI(Container container, ImageIcon image) {
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));

    SelectionArea area = new SelectionArea(image, this);
    container.add(area);/*from   ww  w.  j ava 2 s.co  m*/

    label = new JLabel("Drag within the image.");
    label.setLabelFor(area);
    container.add(label);

    //Align the left edges of the components.
    area.setAlignmentX(Component.LEFT_ALIGNMENT);
    label.setAlignmentX(Component.LEFT_ALIGNMENT); //redundant
}

From source file:SimpleDateFormatDemo.java

public SimpleDateFormatDemo() {

    today = new Date();
    availableLocales = new LocaleGroup();

    String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z",
            "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" };

    currentPattern = patternExamples[0];

    // Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Enter the pattern string or");
    JLabel patternLabel2 = new JLabel("select one from the list:");
    patternLabel1.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternLabel2.setAlignmentX(Component.LEFT_ALIGNMENT);

    JComboBox patternList = new JComboBox(patternExamples);
    patternList.setSelectedIndex(0);//from   ww  w. j a v  a  2s .  co  m
    patternList.setEditable(true);
    patternList.setAlignmentX(Component.LEFT_ALIGNMENT);
    PatternListener patternListener = new PatternListener();
    patternList.addActionListener(patternListener);

    // Set up the UI for selecting a locale.
    JLabel localeLabel = new JLabel("Select a Locale from the list:");
    localeLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

    JComboBox localeList = new JComboBox(availableLocales.getStrings());
    localeList.setSelectedIndex(0);
    localeList.setAlignmentX(Component.LEFT_ALIGNMENT);
    LocaleListener localeListener = new LocaleListener();
    localeList.addActionListener(localeListener);

    // Create the UI for displaying result
    JLabel resultLabel = new JLabel("Current Date and Time", JLabel.LEFT);
    resultLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    result = new JLabel(" ");
    result.setForeground(Color.black);
    result.setAlignmentX(Component.LEFT_ALIGNMENT);
    result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Lay out everything
    JPanel patternPanel = new JPanel();
    patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.Y_AXIS));
    patternPanel.add(patternLabel1);
    patternPanel.add(patternLabel2);
    patternPanel.add(patternList);

    JPanel localePanel = new JPanel();
    localePanel.setLayout(new BoxLayout(localePanel, BoxLayout.Y_AXIS));
    localePanel.add(localeLabel);
    localePanel.add(localeList);

    JPanel resultPanel = new JPanel();
    resultPanel.setLayout(new GridLayout(0, 1));
    resultPanel.add(resultLabel);
    resultPanel.add(result);

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    patternPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    localePanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    resultPanel.setAlignmentX(Component.CENTER_ALIGNMENT);

    add(patternPanel);
    add(Box.createVerticalStrut(10));
    add(localePanel);
    add(Box.createVerticalStrut(10));
    add(resultPanel);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    reformat();

}

From source file:CoordinatesDemo.java

private void buildUI(Container container) {
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));

    CoordinateArea coordinateArea = new CoordinateArea(this);
    container.add(coordinateArea);/*from w w  w.j a  v a 2 s.  c  o  m*/

    label = new JLabel();
    resetLabel();
    container.add(label);

    //Align the left edges of the components.
    coordinateArea.setAlignmentX(Component.LEFT_ALIGNMENT);
    label.setAlignmentX(Component.LEFT_ALIGNMENT); //redundant
}

From source file:DecimalFormatDemo.java

public DecimalFormatDemo() {

    availableLocales = new LocaleGroup();
    inputFormatter = NumberFormat.getNumberInstance();

    String[] patternExamples = { "##.##", "###,###.##", "##,##,##.##", "#", "000,000.0000", "##.0000",
            "'hello'###.##" };

    currentPattern = patternExamples[0];

    // Set up the UI for entering a number.
    JLabel numberLabel = new JLabel("Enter the number to format:");
    numberLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

    JTextField numberField = new JTextField();
    numberField.setEditable(true);//from   w  w  w .j a  va 2s.co m
    numberField.setAlignmentX(Component.LEFT_ALIGNMENT);
    NumberListener numberListener = new NumberListener();
    numberField.addActionListener(numberListener);

    // Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Enter the pattern string or");
    JLabel patternLabel2 = new JLabel("select one from the list:");
    patternLabel1.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternLabel2.setAlignmentX(Component.LEFT_ALIGNMENT);

    JComboBox patternList = new JComboBox(patternExamples);
    patternList.setSelectedIndex(0);
    patternList.setEditable(true);
    patternList.setAlignmentX(Component.LEFT_ALIGNMENT);
    PatternListener patternListener = new PatternListener();
    patternList.addActionListener(patternListener);

    // Set up the UI for selecting a locale.
    JLabel localeLabel = new JLabel("Select a Locale from the list:");
    localeLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

    JComboBox localeList = new JComboBox(availableLocales.getStrings());
    localeList.setSelectedIndex(0);
    localeList.setAlignmentX(Component.LEFT_ALIGNMENT);
    LocaleListener localeListener = new LocaleListener();
    localeList.addActionListener(localeListener);

    // Create the UI for displaying result.
    JLabel resultLabel = new JLabel("Result", JLabel.LEFT);
    resultLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    result = new JLabel(" ");
    result.setForeground(Color.black);
    result.setAlignmentX(Component.LEFT_ALIGNMENT);
    result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Lay out everything
    JPanel numberPanel = new JPanel();
    numberPanel.setLayout(new GridLayout(0, 1));
    numberPanel.add(numberLabel);
    numberPanel.add(numberField);

    JPanel patternPanel = new JPanel();
    patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.Y_AXIS));
    patternPanel.add(patternLabel1);
    patternPanel.add(patternLabel2);
    patternPanel.add(patternList);

    JPanel localePanel = new JPanel();
    localePanel.setLayout(new BoxLayout(localePanel, BoxLayout.Y_AXIS));
    localePanel.add(localeLabel);
    localePanel.add(localeList);

    JPanel resultPanel = new JPanel();
    resultPanel.setLayout(new GridLayout(0, 1));
    resultPanel.add(resultLabel);
    resultPanel.add(result);

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    patternPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    numberPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    localePanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    resultPanel.setAlignmentX(Component.CENTER_ALIGNMENT);

    add(numberPanel);
    add(Box.createVerticalStrut(10));
    add(patternPanel);
    add(Box.createVerticalStrut(10));
    add(localePanel);
    add(Box.createVerticalStrut(10));
    add(resultPanel);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    reformat();
    numberField.setText(result.getText());

}

From source file:net.pandoragames.far.ui.swing.component.ButtonPanel.java

/**
 * Initialises the BUTTON panel.//from   ww  w. java2s .com
 * @param config configuration properties
 * @param componentRepository repository for shared components
 */
private JPanel initButtonPannel(SwingConfig config, ComponentRepository componentRepository) {

    JPanel buttonPannel = new JPanel();
    buttonPannel.setAlignmentX(Component.LEFT_ALIGNMENT);
    buttonPannel.setLayout(new FlowLayout(FlowLayout.TRAILING));
    // FIND
    if (operationType == OperationType.FIND) {
        JButton findButton = new JButton(localizer.localize("button.find"));
        componentRepository.getOperationCallBackListener().addComponentStartDisabled(findButton,
                OperationType.FIND);
        componentRepository.getOperationCallBackListener().addComponentTerminationEnabled(findButton,
                OperationType.FIND);
        findButton.addActionListener(componentRepository.getFindCommand());
        findButton.addActionListener(new ReorderFilePatternListListener(componentRepository.getFindForm(),
                config.getFileNamePatternListModel()));
        buttonPannel.add(findButton);
    }
    // REPLACE
    if (operationType == OperationType.REPLACE) {
        JButton replaceButton = new JButton(localizer.localize("button.replace"));
        replaceButton.setEnabled(false);
        componentRepository.getOperationCallBackListener().addComponentTerminationEnabled(replaceButton,
                OperationType.FIND);
        componentRepository.getResetDispatcher().addToBeDisabled(replaceButton);
        componentRepository.getSearchBaseListener().addToBeDisabled(replaceButton);
        ConfirmReplaceListener replaceListener = new ConfirmReplaceListener(componentRepository.getRootWindow(),
                config, componentRepository.getReplaceForm());
        replaceListener.addActionListener(componentRepository.getReplaceCommand());
        replaceButton.addActionListener(replaceListener);
        buttonPannel.add(replaceButton);
    }
    // RENAME
    if (operationType == OperationType.RENAME) {
        JButton renameButton = new JButton(componentRepository.getRenameCommand());
        renameButton.setEnabled(false);
        componentRepository.getResetDispatcher().addToBeDisabled(renameButton);
        buttonPannel.add(renameButton);
    }
    // CANCEL
    JButton cancelButton = new JButton(localizer.localize("button.cancel"));
    cancelButton.setEnabled(false);
    componentRepository.getOperationCallBackListener().addComponentStartEnabled(cancelButton,
            OperationType.ANY);
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            backend.abort();
        }
    });
    buttonPannel.add(cancelButton);
    componentRepository.getResetDispatcher().addToBeDisabled(cancelButton);
    // UNDO
    if (operationType == OperationType.REPLACE) {
        JButton undoButton = new JButton(localizer.localize("button.undo"));
        undoButton.setEnabled(false);
        componentRepository.getOperationCallBackListener().addComponentTerminationEnabled(undoButton,
                OperationType.REPLACE);
        componentRepository.getOperationCallBackListener().addComponentStartDisabled(undoButton,
                OperationType.FIND);
        undoButton.addActionListener(componentRepository.getUndoListener());
        undoButton.addActionListener(new OnClickDisable(undoButton));
        buttonPannel.add(undoButton);
    }
    // RESET
    JButton clearButton = new JButton(localizer.localize("button.reset"));
    clearButton.addActionListener(componentRepository.getResetDispatcher());
    buttonPannel.add(clearButton);
    // this.add( buttonPannel );
    return buttonPannel;
}

From source file:components.ComboBoxDemo2.java

public ComboBoxDemo2() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z",
            "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" };

    currentPattern = patternExamples[0];

    //Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Enter the pattern string or");
    JLabel patternLabel2 = new JLabel("select one from the list:");

    JComboBox patternList = new JComboBox(patternExamples);
    patternList.setEditable(true);//from  w  ww  . ja  va 2s.  c o m
    patternList.addActionListener(this);

    //Create the UI for displaying result.
    JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); //== LEFT
    result = new JLabel(" ");
    result.setForeground(Color.black);
    result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    //Lay out everything.
    JPanel patternPanel = new JPanel();
    patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS));
    patternPanel.add(patternLabel1);
    patternPanel.add(patternLabel2);
    patternList.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternPanel.add(patternList);

    JPanel resultPanel = new JPanel(new GridLayout(0, 1));
    resultPanel.add(resultLabel);
    resultPanel.add(result);

    patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    add(patternPanel);
    add(Box.createRigidArea(new Dimension(0, 10)));
    add(resultPanel);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    reformat();
}

From source file:ComboBoxDemo2.java

public ComboBoxDemo2() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z",
            "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" };

    currentPattern = patternExamples[0];

    // Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Enter the pattern string or");
    JLabel patternLabel2 = new JLabel("select one from the list:");

    JComboBox patternList = new JComboBox(patternExamples);
    patternList.setEditable(true);// w w  w .  j  a va2s .  com
    patternList.addActionListener(this);

    // Create the UI for displaying result.
    JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); // ==
                                                                          // LEFT
    result = new JLabel(" ");
    result.setForeground(Color.black);
    result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Lay out everything.
    JPanel patternPanel = new JPanel();
    patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS));
    patternPanel.add(patternLabel1);
    patternPanel.add(patternLabel2);
    patternList.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternPanel.add(patternList);

    JPanel resultPanel = new JPanel(new GridLayout(0, 1));
    resultPanel.add(resultLabel);
    resultPanel.add(result);

    patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    add(patternPanel);
    add(Box.createRigidArea(new Dimension(0, 10)));
    add(resultPanel);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    reformat();
}