Example usage for java.awt FlowLayout FlowLayout

List of usage examples for java.awt FlowLayout FlowLayout

Introduction

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

Prototype

public FlowLayout(int align) 

Source Link

Document

Constructs a new FlowLayout with the specified alignment and a default 5-unit horizontal and vertical gap.

Usage

From source file:ioheater.ui.IOHeaterUI.java

/**
 * Creates new form IOheater/*from   w  w  w.  j a  va 2s.  co m*/
 */
public IOHeaterUI() {
    logger.info("Entering IOheater");
    initComponents();

    jPanel3.removeAll();
    jPanel3.setLayout(new FlowLayout(FlowLayout.LEFT));
    jPanel3.add(chart());
    this.setLocationRelativeTo(null);
    this.sdf = new SimpleDateFormat("dd/MM/yy h:mm:ss");

    setTitle("IO heater");
    addWindowListener(new java.awt.event.WindowAdapter() {
        @Override
        public void windowClosed(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }

        @Override
        public void windowOpened(java.awt.event.WindowEvent evt) {
            formWindowOpened(evt);
        }
    });

    this.ioHeaterManager = new IOHeaterManager(this, this, this);

    logger.info("Exiting IOheater");
}

From source file:de.huxhorn.lilith.swing.LicenseAgreementDialog.java

private void initUI() {
    JPanel content = new JPanel();
    content.setLayout(new BorderLayout());
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));

    JTextPane licenseTextPane = new JTextPane();
    HTMLEditorKit htmlEditorKit = new HTMLEditorKit();

    String licenseText = null;//from w  w  w  . java 2 s .  c  o  m
    InputStream licenseStream = LicenseAgreementDialog.class.getResourceAsStream("/licenses/license.html");
    if (licenseStream != null) {
        try {
            licenseText = IOUtils.toString(licenseStream, StandardCharsets.UTF_8);
        } catch (IOException ex) {
            if (logger.isErrorEnabled())
                logger.error("Exception while loading license!", ex);
            IOUtilities.interruptIfNecessary(ex);
        } finally {
            IOUtilities.closeQuietly(licenseStream);
        }
    }
    if (licenseText == null) {
        if (logger.isErrorEnabled())
            logger.error("Couldn't find license text! Exiting!");
        System.exit(-1);
    }

    licenseTextPane.setEditorKit(htmlEditorKit);
    licenseTextPane.setEditable(false);
    licenseTextPane.setText(licenseText);
    JScrollPane licenseScrollPane = new JScrollPane(licenseTextPane);
    licenseScrollPane.setPreferredSize(new Dimension(640, 480));

    content.add(licenseScrollPane, BorderLayout.CENTER);
    content.add(buttonPanel, BorderLayout.SOUTH);

    AcceptAction acceptAction = new AcceptAction();
    DeclineAction declineAction = new DeclineAction();

    JButton acceptButton = new JButton(acceptAction);
    JButton declineButton = new JButton(declineAction);

    buttonPanel.add(acceptButton);
    buttonPanel.add(declineButton);
    setContentPane(content);
    licenseTextPane.setCaretPosition(0);
    declineButton.requestFocusInWindow();
}

From source file:SourceInDemo.java

public SourceInDemo() {
    super("Source In");

    add(new ImageViewer(), BorderLayout.CENTER);
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEADING));
    panel.add(shadow = new JCheckBox("Drop Shadow"));
    shadow.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent changeEvent) {
            repaint();/*ww  w .  j av  a2s.co m*/
        }
    });
    add(panel, BorderLayout.SOUTH);

    setSize(350, 250);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:com.emental.mindraider.ui.dialogs.AddLinkToConceptJDialog.java

/**
 * Constructor./*from   www. j  av a2 s  . com*/
 */
public AddLinkToConceptJDialog() {
    super("Add Link To Note");

    JPanel framePanel = new JPanel();
    framePanel.setLayout(new GridLayout(3, 1));

    JPanel p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.RIGHT));
    p.add(new JLabel(" Predicate: "));

    predicateNs = new JTextField(38);
    predicateNs.setText("http://" + MindRaider.profile.getHostname() + "/e-mentality/conceptLink/custom#");
    predicateNs.selectAll();
    p.add(predicateNs);
    p.add(new JLabel("#"));
    predicateLocalName = new JTextField(15);
    p.add(predicateLocalName);
    framePanel.add(p);

    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.LEFT));
    p.add(new JLabel(" Note: "));

    objectNs = new JTextField(38);
    objectNs.setText("");
    objectNs.selectAll();
    p.add(objectNs);

    findConceptButton = new JButton("Find Note");
    findConceptButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            OpenNoteJDialog.NoteToOpen conceptToOpen = new OpenNoteJDialog.NoteToOpen();
            new OpenNoteJDialog("OpenNoteJDialog.titleLink", "OpenNoteJDialog.selectConceptToLink",
                    "OpenNoteJDialog.link", null, conceptToOpen);
            if (conceptToOpen.conceptLabel != null) {
                objectNs.setText(conceptToOpen.conceptUri);
            }
        }

    });
    p.add(findConceptButton);
    framePanel.add(p);

    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.CENTER));
    JButton addButton = new JButton("Add");
    p.add(addButton);
    addButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            createTriplet();
        }
    });

    JButton cancelButton = new JButton("Cancel");
    p.add(cancelButton);
    cancelButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            AddLinkToConceptJDialog.this.dispose();
        }
    });
    framePanel.add(p);

    getContentPane().add(framePanel, BorderLayout.CENTER);

    // show
    pack();
    Gfx.centerAndShowWindow(this);
}

From source file:be.fedict.eid.tsl.tool.SignSelectPkcs11FinishablePanel.java

@Override
public Component getComponent() {
    LOG.debug("get component");
    if (null == this.component) {
        /*//from   w  w w  .  j a  va2  s.  c  om
         * We need to return the same component each time, else the
         * validate() logic doesn't work as expected.
         */
        JPanel panel = new JPanel();
        BoxLayout boxLayout = new BoxLayout(panel, BoxLayout.PAGE_AXIS);
        panel.setLayout(boxLayout);
        JPanel infoPanel = new JPanel();
        infoPanel.add(new JLabel("Please select a PKCS#11 library."));
        panel.add(infoPanel);

        JPanel browsePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        panel.add(browsePanel);
        browsePanel.add(new JLabel("PKCS#11 library:"));
        this.pkcs11TextField = new JTextField(30);
        browsePanel.add(this.pkcs11TextField);
        JButton browseButton = new JButton("Browse...");
        browseButton.addActionListener(this);
        browsePanel.add(browseButton);

        JPanel slotIdxPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        panel.add(slotIdxPanel);
        slotIdxPanel.add(new JLabel("Slot index:"));
        SpinnerModel spinnerModel = new SpinnerNumberModel(0, 0, 10, 1);
        this.slotIdxSpinner = new JSpinner(spinnerModel);
        slotIdxPanel.add(this.slotIdxSpinner);

        this.component = panel;
    }
    return this.component;
}

From source file:com.emental.mindraider.ui.dialogs.NewRdfModelJDialog.java

/**
 * Constructor.//from  ww  w . j  av  a  2  s.  c om
 */
public NewRdfModelJDialog() {

    super(Messages.getString("NewRdfModelJDialog.title"));

    JPanel framePanel = new JPanel();
    framePanel.setLayout(new GridLayout(3, 1));

    JPanel p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.RIGHT));
    p.add(new JLabel(Messages.getString("NewRdfModelJDialog.subject")));

    subjectNs = new JTextField(30);
    subjectNs.setText(MindRaiderConstants.MR_RDF_PREDICATE_NS);
    p.add(subjectNs);
    p.add(new JLabel("#"));

    subjectLocalName = new JTextField(15);
    p.add(subjectLocalName);
    framePanel.add(p);

    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.RIGHT));
    final JCheckBox literalCheckBox = new JCheckBox("literal", false);
    p.add(literalCheckBox);
    framePanel.add(p);

    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.CENTER));
    JButton addButton = new JButton(Messages.getString("NewRdfModelJDialog.create"));
    p.add(addButton);
    addButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            createModel(literalCheckBox);
        }
    });

    JButton cancelButton = new JButton(Messages.getString("NewRdfModelJDialog.cancel"));
    p.add(cancelButton);
    cancelButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            NewRdfModelJDialog.this.dispose();
        }
    });
    framePanel.add(p);

    subjectLocalName.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent keyEvent) {
            if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) {
                createModel(literalCheckBox);
            }
        }

        public void keyReleased(KeyEvent keyEvent) {
        }

        public void keyTyped(KeyEvent keyEvent) {
        }
    });

    getContentPane().add(framePanel, BorderLayout.CENTER);

    // show
    pack();
    Gfx.centerAndShowWindow(this);

    addWindowListener(new WindowAdapter() {

        public void windowActivated(WindowEvent e) {
            subjectLocalName.requestFocusInWindow();
        }
    });
}

From source file:components.PasswordDemo.java

public PasswordDemo(JFrame f) {
    //Use the default FlowLayout.
    controllingFrame = f;//from   w w  w. ja va 2 s . 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:com.stam.batchmove.BatchMoveUtils.java

public static void showFilesFrame(Object[][] data, String[] columnNames, final JFrame callerFrame) {
    final FilesFrame filesFrame = new FilesFrame();

    DefaultTableModel model = new DefaultTableModel(data, columnNames) {

        private static final long serialVersionUID = 1L;

        @Override/*from  w  w w  . j  a v a  2s.c  o  m*/
        public Class<?> getColumnClass(int column) {
            return getValueAt(0, column).getClass();
        }

        @Override
        public boolean isCellEditable(int row, int column) {
            return column == 0;
        }
    };
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setHorizontalAlignment(JLabel.CENTER);
    final JTable table = new JTable(model);
    for (int i = 1; i < table.getColumnCount(); i++) {
        table.setDefaultRenderer(table.getColumnClass(i), renderer);
    }
    //            table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setRowHeight(30);
    table.getTableHeader().setFont(new Font("Serif", Font.BOLD, 14));
    table.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14));
    table.setRowSelectionAllowed(false);
    table.getColumnModel().getColumn(0).setMaxWidth(35);
    table.getColumnModel().getColumn(1).setPreferredWidth(350);
    table.getColumnModel().getColumn(2).setPreferredWidth(90);
    table.getColumnModel().getColumn(2).setMaxWidth(140);
    table.getColumnModel().getColumn(3).setMaxWidth(90);

    JPanel tblPanel = new JPanel();
    JPanel btnPanel = new JPanel();

    tblPanel.setLayout(new BorderLayout());
    if (table.getRowCount() > 15) {
        JScrollPane scrollPane = new JScrollPane(table);
        tblPanel.add(scrollPane, BorderLayout.CENTER);
    } else {
        tblPanel.add(table.getTableHeader(), BorderLayout.NORTH);
        tblPanel.add(table, BorderLayout.CENTER);
    }

    btnPanel.setLayout(new FlowLayout(FlowLayout.LEFT));

    filesFrame.setMinimumSize(new Dimension(800, 600));
    filesFrame.setLayout(new BorderLayout());
    filesFrame.add(tblPanel, BorderLayout.NORTH);
    filesFrame.add(btnPanel, BorderLayout.SOUTH);

    final JLabel resultsLabel = new JLabel();

    JButton cancelBtn = new JButton("Cancel");
    cancelBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            filesFrame.setVisible(false);
            callerFrame.setVisible(true);
        }
    });

    JButton moveBtn = new JButton("Copy");
    moveBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileChooser = new JFileChooser();
            fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            fileChooser.setDialogTitle("Choose target directory");
            int selVal = fileChooser.showOpenDialog(null);
            if (selVal == JFileChooser.APPROVE_OPTION) {
                File selection = fileChooser.getSelectedFile();
                String targetPath = selection.getAbsolutePath();

                DefaultTableModel dtm = (DefaultTableModel) table.getModel();
                int nRow = dtm.getRowCount();
                int copied = 0;
                for (int i = 0; i < nRow; i++) {
                    Boolean selected = (Boolean) dtm.getValueAt(i, 0);
                    String filePath = dtm.getValueAt(i, 1).toString();

                    if (selected) {
                        try {
                            FileUtils.copyFileToDirectory(new File(filePath), new File(targetPath));
                            dtm.setValueAt("Copied", i, 3);
                            copied++;
                        } catch (Exception ex) {
                            Logger.getLogger(SelectionFrame.class.getName()).log(Level.SEVERE, null, ex);
                            dtm.setValueAt("Failed", i, 3);
                        }
                    }
                }
                resultsLabel.setText(copied + " files copied. Finished!");
            }
        }
    });
    btnPanel.add(cancelBtn);
    btnPanel.add(moveBtn);
    btnPanel.add(resultsLabel);

    filesFrame.revalidate();
    filesFrame.setVisible(true);

    callerFrame.setVisible(false);
}

From source file:ErroresPorTraza.TabbedForm.java

private void setChartCantidadErrores() {
    TiposErrorChart chartError = new TiposErrorChart();
    ChartPanel chartpanel1 = chartError.getChartPanel("Cantidad de errores", jTable1);
    jPanelChartError.removeAll();/*from   w w  w . j  av a  2s.c o m*/
    jPanelChartError.setLayout(new FlowLayout(FlowLayout.LEFT));
    jPanelChartError.add(chartpanel1);
    this.setLocationRelativeTo(null);
    int totales = chartError.getSumaCantidades();
    setChartPorcentaje(totales);
    tablaresult = chartError.getResultadosExcell();
}

From source file:com.emental.mindraider.ui.dialogs.AddTripletJDialog.java

/**
 * Constructor.// w w w . ja v  a 2  s. c  om
 */
public AddTripletJDialog() {
    super("Add Triplet");

    JPanel framePanel = new JPanel();
    framePanel.setLayout(new GridLayout(4, 1));

    JPanel p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.RIGHT));
    p.add(new JLabel(" Predicate: "));

    predicateNs = new JTextField(30);
    predicateNs.setText(MindRaiderConstants.MR_RDF_PREDICATE_NS);
    predicateNs.selectAll();
    p.add(predicateNs);
    p.add(new JLabel("#"));
    predicateLocalName = new JTextField(15);
    p.add(predicateLocalName);
    framePanel.add(p);

    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.RIGHT));
    p.add(new JLabel(" Object: "));

    objectNs = new JTextField(30);
    objectNs.setText(MindRaiderConstants.MR_RDF_PREDICATE_NS);
    objectNs.selectAll();
    p.add(objectNs);
    p.add(new JLabel("#"));
    objectLocalName = new JTextField(15);
    objectLocalName.grabFocus();
    objectLocalName.selectAll();
    objectLocalName.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent keyEvent) {
            if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) {
                createTriplet();
            }
        }

        public void keyReleased(KeyEvent keyEvent) {
        }

        public void keyTyped(KeyEvent keyEvent) {
        }
    });

    p.add(objectLocalName);
    framePanel.add(p);

    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.RIGHT));
    literalCheckBox = new JCheckBox("literal", false);
    p.add(literalCheckBox);
    framePanel.add(p);

    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.CENTER));
    JButton addButton = new JButton("Add");
    p.add(addButton);
    addButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            createTriplet();
        }
    });

    JButton cancelButton = new JButton("Cancel");
    p.add(cancelButton);
    cancelButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            AddTripletJDialog.this.dispose();
        }
    });
    framePanel.add(p);

    getContentPane().add(framePanel, BorderLayout.CENTER);

    // show
    pack();
    Gfx.centerAndShowWindow(this);

    addWindowListener(new WindowAdapter() {

        public void windowActivated(WindowEvent e) {
            getObjectLocalName().requestFocusInWindow();
        }
    });
}