Example usage for java.awt FlowLayout TRAILING

List of usage examples for java.awt FlowLayout TRAILING

Introduction

In this page you can find the example usage for java.awt FlowLayout TRAILING.

Prototype

int TRAILING

To view the source code for java.awt FlowLayout TRAILING.

Click Source Link

Document

This value indicates that each row of components should be justified to the trailing edge of the container's orientation, for example, to the right in left-to-right orientations.

Usage

From source file:Main.java

public Main() {
    super(new FlowLayout(FlowLayout.TRAILING, 10, 3));
    add(new JButton("w w w.j a v a 2 s . c o m"));
    add(new JButton("w w w.j a v a 2 s . com"));
    add(new JButton("w w w.java2s.com"));
    add(new JButton("www.j ava 2 s . c o m"));
}

From source file:Main.java

public Main() {
    JLabel label = new JLabel("Text Field");
    JTextField textField = new JTextField(20);
    JRadioButton rb1 = new JRadioButton("Radio 1");
    JRadioButton rb2 = new JRadioButton("Radio 2");
    JButton button = new JButton("Button");

    JPanel panel1 = new JPanel();
    panel1.add(label);// w w  w .j  a va 2 s.c  o  m
    panel1.add(textField);

    JPanel panel2 = new JPanel();
    panel2.add(rb1);
    panel2.add(rb2);

    JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.TRAILING));
    panel3.add(button);

    JPanel panel4 = new JPanel(new GridLayout(3, 1));
    panel4.add(panel1);
    panel4.add(panel2);
    panel4.add(panel3);

    setLayout(new GridBagLayout());
    add(panel4);
}

From source file:layout.FlowLayoutDemo.java

public void addComponentsToPane(final Container pane) {
    final JPanel compsToExperiment = new JPanel();
    compsToExperiment.setLayout(experimentLayout);
    experimentLayout.setAlignment(FlowLayout.TRAILING);
    JPanel controls = new JPanel();
    controls.setLayout(new FlowLayout());

    LtoRbutton = new JRadioButton(LtoR);
    LtoRbutton.setActionCommand(LtoR);//from  w  w w .j a  v a2 s .c  o  m
    LtoRbutton.setSelected(true);
    RtoLbutton = new JRadioButton(RtoL);
    RtoLbutton.setActionCommand(RtoL);

    //Add buttons to the experiment layout
    compsToExperiment.add(new JButton("Button 1"));
    compsToExperiment.add(new JButton("Button 2"));
    compsToExperiment.add(new JButton("Button 3"));
    compsToExperiment.add(new JButton("Long-Named Button 4"));
    compsToExperiment.add(new JButton("5"));
    //Left to right component orientation is selected by default
    compsToExperiment.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

    //Add controls to set up the component orientation in the experiment layout
    final ButtonGroup group = new ButtonGroup();
    group.add(LtoRbutton);
    group.add(RtoLbutton);
    controls.add(LtoRbutton);
    controls.add(RtoLbutton);
    controls.add(applyButton);

    //Process the Apply component orientation button press
    applyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String command = group.getSelection().getActionCommand();
            //Check the selection
            if (command.equals("Left to right")) {
                compsToExperiment.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
            } else {
                compsToExperiment.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
            }
            //update the experiment layout
            compsToExperiment.validate();
            compsToExperiment.repaint();
        }
    });
    pane.add(compsToExperiment, BorderLayout.CENTER);
    pane.add(controls, BorderLayout.SOUTH);
    ;
}

From source file:components.PasswordDemo.java

public PasswordDemo(JFrame f) {
    //Use the default FlowLayout.
    controllingFrame = f;//w  ww  . j  av  a  2s  . c o m

    //Create everything.
    passwordField = new JPasswordField(10);
    passwordField.setActionCommand(OK);
    passwordField.addActionListener(this);

    JLabel label = new JLabel("Enter the password: ");
    label.setLabelFor(passwordField);

    JComponent buttonPane = createButtonPanel();

    //Lay out everything.
    JPanel textPane = new JPanel(new FlowLayout(FlowLayout.TRAILING));
    textPane.add(label);
    textPane.add(passwordField);

    add(textPane);
    add(buttonPane);
}

From source file:trendgraph.XYLineChart_AWT.java

public XYLineChart_AWT(int yearStart, int yearEnd, String[] creditUnionName, String columnName)
        throws SQLException {
    super("Graph");
    super.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    this.yearStart = yearStart;
    this.yearEnd = yearEnd;
    this.creditUnionName = creditUnionName;
    this.columnName = columnName;
    saveGraphButton = new JButton("Save Graph");
    saveGraphButton.setBorderPainted(false);
    saveGraphButton.setFocusPainted(false);

    JFreeChart xylineChart = ChartFactory.createXYLineChart("CU Report", "Year (YYYY)", //X-axis
            columnName, //Y-axis (replace with columnName
            createDataset(), PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(1000, 800)); //(x, y)
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    renderer.setSeriesPaint(0, Color.RED); //can be GREEN, YELLOW, ETC.

    renderer.setSeriesStroke(0, new BasicStroke(3.0f)); //Font size

    renderer.setSeriesPaint(1, Color.BLUE); //can be GREEN, YELLOW, ETC.

    renderer.setSeriesStroke(1, new BasicStroke(3.0f)); //Font size

    renderer.setSeriesPaint(2, Color.GREEN); //can be GREEN, YELLOW, ETC.

    renderer.setSeriesStroke(2, new BasicStroke(3.0f)); //Font size

    renderer.setSeriesPaint(3, Color.yellow); //can be GREEN, YELLOW, ETC.

    renderer.setSeriesStroke(3, new BasicStroke(3.0f)); //Font size

    plot.setRenderer(renderer);//from   w w  w. ja  v a 2s.  c  o  m
    chartPanel.setLayout(new FlowLayout(FlowLayout.TRAILING));
    chartPanel.add(saveGraphButton);
    setContentPane(chartPanel);
    pack();
    RefineryUtilities.centerFrameOnScreen(this);
    setVisible(true);

    saveGraphButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Rectangle rect = chartPanel.getBounds();
            FileChooser chooser = new FileChooser();

            //get chosen path and save the variable
            String path = chooser.getPath();
            path = path.replace("\\", "/");

            String format = "png";
            String fileName = path + "." + format;
            BufferedImage captureImage = new BufferedImage(rect.width, rect.height,
                    BufferedImage.TYPE_INT_ARGB);
            chartPanel.paint(captureImage.getGraphics());

            File file = new File(fileName);

            try {
                ImageIO.write(captureImage, format, file);

                //write data to file
            } catch (IOException ex) {
                Logger.getLogger(XYLineChart_AWT.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
}

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

/**
 * Initialises the BUTTON panel.//w w  w.  j  av  a 2s.c o m
 * @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:TextInputDemo.java

protected JComponent createButtons() {
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.TRAILING));

    JButton button = new JButton("Set address");
    button.addActionListener(this);
    panel.add(button);//from  w  ww .j  ava2  s  .  c o  m

    button = new JButton("Clear address");
    button.addActionListener(this);
    button.setActionCommand("clear");
    panel.add(button);

    //Match the SpringLayout's gap, subtracting 5 to make
    //up for the default gap FlowLayout provides.
    panel.setBorder(BorderFactory.createEmptyBorder(0, 0, GAP - 5, GAP - 5));
    return panel;
}

From source file:org.pentaho.reporting.engine.classic.demo.ancient.demo.swingicons.SwingIconsDemoPanel.java

/**
 * Constructs the demo application./*from w ww.  j a va2  s .  c o m*/
 */
public SwingIconsDemoPanel() {
    data = new SwingIconsDemoTableModel();

    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    final JTable table = new JTable(data);
    table.setDefaultRenderer(Image.class, new ImageCellRenderer());
    table.setRowHeight(26);
    final JScrollPane scrollPane = new JScrollPane(table);
    add(scrollPane, BorderLayout.CENTER);

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.TRAILING));
    buttonPanel.add(new JButton(new SelectRepositoryFileAction()));
    add(buttonPanel, BorderLayout.SOUTH);

    loadData(findDataFile());
}

From source file:org.openmrs.module.muzimabiometrics.panels.ScanFingerprint.java

@Override
protected void initGUI() throws IOException, JSONException {
    panelMain = new JPanel();
    panelMain.setBackground(Color.white);
    panelMain.setLayout(new BoxLayout(panelMain, BoxLayout.PAGE_AXIS));

    panelMessage = new JPanel();
    panelMessage.setBackground(Color.white);
    panelMessage.add(lblProgressMessage);
    panelMessage.setLayout(new FlowLayout(FlowLayout.TRAILING));

    panelButtons = new JPanel();
    panelButtons.setBackground(Color.white);
    panelButtons.setLayout(new FlowLayout(FlowLayout.LEADING));

    btnTryAgain.setVisible(false);/* w  w  w.j  a va  2s  . c o m*/
    btnTryAgain.addActionListener(this);

    btnLaunchApplet.setVisible(true);
    btnLaunchApplet.addActionListener(this);

    panelButtons.add(btnTryAgain);
    panelButtons.add(btnLaunchApplet);

    panelMain.add(panelMessage);
    panelMain.add(panelButtons);

    add(panelMain);

    scannerList = new JList();
    scannerList.setModel(new DefaultListModel());
    scannerList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    scannerList.addListSelectionListener(new ScannerSelectionListener());
}

From source file:net.vanosten.dings.swing.SummaryView.java

protected void initializeButtonP() {
    buttonsP = new JPanel();
    buttonsP.setLayout(new FlowLayout(FlowLayout.TRAILING, 0, 0));
    buttonsP.add(redrawB);/*  ww  w  .  j a  va 2 s.  co  m*/
}