Tabnine Logo
FlowLayout
Code IndexAdd Tabnine to your IDE (free)

How to use
FlowLayout
in
java.awt

Best Java code snippets using java.awt.FlowLayout (Showing top 20 results out of 5,544)

Refine searchRefine arrow

  • Container
  • JFrame
  • JPanel
  • Window
  • JButton
  • JLabel
origin: apache/ignite

/**
 * @param components Components.
 * @return Panel.
 */
private JPanel createPanel(JComponent... components) {
  JPanel panel = new JPanel();
  panel.setLayout(new FlowLayout());
  for (JComponent component : components)
    panel.add(component);
  return panel;
}
origin: cmusphinx/sphinx4

JPanel buttonPanel = new JPanel();
FlowLayout layout = new FlowLayout();
layout.setAlignment(FlowLayout.LEFT);
buttonPanel.setLayout(layout);
playButton = new JButton("Play");
playButton.setEnabled(true);
playButton.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    player.play(audioPanel.getSelectionStart(),
buttonPanel.add(recordButton);
buttonPanel.add(playButton);
buttonPanel.add(zoomInButton);
origin: stanfordnlp/CoreNLP

JPanel buttonPanel = new JPanel();
buttonPanel.setBackground(Color.WHITE);
buttonPanel.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
FlowLayout fl = new FlowLayout();
fl.setAlignment(FlowLayout.RIGHT);
buttonPanel.setLayout(fl);
tagButton.setText("Tag sentence!");
tagButton.setBackground(Color.WHITE);
buttonPanel.add(tagButton);
tagButton.addActionListener(e -> performTagAction(e));
origin: libgdx/libgdx

  JPanel fontPanel = new JPanel();
    fontPanel.add(new JLabel("Size:"), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST,
      GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
      GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
      bitmapPanel.add(new JLabel("Gamma:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST,
        GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
    browseButton = new JButton("...");
    browseButton.setMargin(new Insets(0, 0, 0, 0));
    fontPanel.add(new JLabel("Rendering:"), new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST,
      GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
    sampleNeheButton = new JButton();
getContentPane().add(rightSidePanel, new GridBagConstraints(1, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER,
  GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    FlowLayout advancePanelLayout = new FlowLayout();
origin: pmd/pmd

private void init() {
  JTextArea errorArea = new JTextArea();
  errorArea.setEditable(false);
  errorArea.setText(exc.getMessage() + "\n");
  getContentPane().setLayout(new BorderLayout());
  JPanel messagePanel = new JPanel(new BorderLayout());
  messagePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory
      .createTitledBorder(BorderFactory.createEtchedBorder(), NLS.nls("COMPILE_ERROR.PANEL.TITLE"))));
  messagePanel.add(new JScrollPane(errorArea), BorderLayout.CENTER);
  getContentPane().add(messagePanel, BorderLayout.CENTER);
  JPanel btnPane = new JPanel(new FlowLayout(FlowLayout.RIGHT));
  okBtn = new JButton(NLS.nls("COMPILE_ERROR.OK_BUTTON.CAPTION"));
  okBtn.addActionListener(this);
  btnPane.add(okBtn);
  getRootPane().setDefaultButton(okBtn);
  getContentPane().add(btnPane, BorderLayout.SOUTH);
  pack();
  setLocationRelativeTo(getParent());
  setVisible(true);
}
origin: apache/shiro

public void afterPropertiesSet() throws Exception {
  ClassPathResource resource = new ClassPathResource("logo.png");
  ImageIcon icon = new ImageIcon(resource.getURL());
  JLabel logo = new JLabel(icon);
  saveButton = new JButton("Save Value");
  saveButton.addActionListener(this);
  refreshButton = new JButton("Refresh Value");
  refreshButton.addActionListener(this);
  JPanel valuePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
  valuePanel.add(valueField);
  valuePanel.add(saveButton);
  valuePanel.add(refreshButton);
  secureMethod3Button.addActionListener(this);
  JPanel methodPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
  methodPanel.add(secureMethod1Button);
  methodPanel.add(secureMethod2Button);
  methodPanel.add(secureMethod3Button);
  frame = new JFrame("Apache Shiro Sample Application");
  frame.setSize(500, 200);
origin: libgdx/libgdx

@Override
public void run () {
  JPanel panel = new JPanel(new FlowLayout());
  JPanel textPanel = new JPanel() {
    public boolean isOptimizedDrawingEnabled () {
      return false;
  };
  textPanel.setLayout(new OverlayLayout(textPanel));
  panel.add(textPanel);
  textPanel.add(textField);
  final JLabel placeholderLabel = new JLabel(hint);
  placeholderLabel.setForeground(Color.GRAY);
  placeholderLabel.setAlignmentX(0.0f);
  textPanel.add(placeholderLabel, 0);
origin: RipMeApp/ripme

private void setupHandlers() {
  ripButton.addActionListener(new RipButtonHandler());
  ripTextfield.addActionListener(new RipButtonHandler());
  ripTextfield.getDocument().addDocumentListener(new DocumentListener() {
    logPanel.setVisible(!logPanel.isVisible());
    emptyPanel.setVisible(!logPanel.isVisible());
      checkChoise.setLayout(new FlowLayout());
      JFrame.setDefaultLookAndFeelDecorated(true);
      JFrame frame = new JFrame("Are you sure?");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    changeLocale();
  });
  configSaveDirLabel.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
      return;
    configSaveDirLabel.setText(Utils.shortenPath(chosenPath));
    Utils.setConfigString("rips.directory", chosenPath);
  });
origin: log4j/log4j

public LogFactor5ErrorDialog(JFrame jframe, String message) {
 super(jframe, "Error", true);
 JButton ok = new JButton("Ok");
 ok.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
   hide();
  }
 });
 JPanel bottom = new JPanel();
 bottom.setLayout(new FlowLayout());
 bottom.add(ok);
 JPanel main = new JPanel();
 main.setLayout(new GridBagLayout());
 wrapStringOnPanel(message, main);
 getContentPane().add(main, BorderLayout.CENTER);
 getContentPane().add(bottom, BorderLayout.SOUTH);
 show();
}
//--------------------------------------------------------------------------
origin: skylot/jadx

String name = node.makeLongString();
final JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 3, 0));
panel.setOpaque(false);
final JLabel label = new JLabel(name);
label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
label.setIcon(node.getIcon());
final JButton button = new JButton();
button.setIcon(ICON_CLOSE_INACTIVE);
button.setRolloverIcon(ICON_CLOSE);
button.setRolloverEnabled(true);
button.setOpaque(false);
button.addActionListener(e -> closeCodePanel(contentPanel));
panel.addMouseListener(new MouseAdapter() {
  @Override
  public void mouseClicked(MouseEvent e) {
origin: chewiebug/GCViewer

Panel logoPanel = new Panel();
ImageIcon logoIcon = ImageHelper.loadImageIcon(LocalisationHelper.getString("about_dialog_image"));
JLabel la_icon = new JLabel(logoIcon);
la_icon.setBorder(new SoftBevelBorder(SoftBevelBorder.LOWERED));
logoPanel.add(la_icon);
JPanel versionPanel = new JPanel();
versionPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
versionPanel.setLayout(new GridBagLayout());
JLabel copyright = new JLabel("\u00A9" + " 2011-2018: Joerg Wuethrich and contributors", JLabel.CENTER);
JLabel contributorsLabel = new JLabel("contributors (alphabetically ordered):", JLabel.CENTER);
buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
if (UrlDisplayHelper.displayUrlIsSupported()) {
  JButton homePageButton = new JButton("Homepage");
  homePageButton.setActionCommand(ACTION_HOMEPAGE);
  homePageButton.addActionListener(this);
  buttonPanel.add(homePageButton);
okButton.addActionListener(this);
buttonPanel.add(okButton);
getContentPane().add("North", logoPanel);
getContentPane().add("Center", versionPanel);
getContentPane().add("South", buttonPanel);
pack();
setResizable(false);
origin: wiztools/rest-client

jb_add.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent e) {
jb_addAndClose.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent e) {
jb_cancel.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent e) {
c.setLayout(new BorderLayout());
  JPanel jp = new JPanel(new BorderLayout());
  c.add(jp, BorderLayout.NORTH);
  c.add(jsp, BorderLayout.CENTER);
  JPanel jp = new JPanel();
  jp.setLayout(new FlowLayout(FlowLayout.RIGHT));
  jp.add(jb_cancel);
  jp.add(jb_add);
origin: pmd/pmd

ASTPanel astPanel = new ASTPanel(model);
xPathPanel = new XPathPanel(model);
getContentPane().setLayout(new BorderLayout());
JSplitPane editingPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sourcePanel, astPanel);
editingPane.setResizeWeight(0.5d);
JPanel interactionsPane = new JPanel(new BorderLayout());
interactionsPane.add(xPathPanel, BorderLayout.SOUTH);
interactionsPane.add(editingPane, BorderLayout.CENTER);
getContentPane().add(interactionsPane, BorderLayout.CENTER);
JButton compileBtn = new JButton(NLS.nls("MAIN.FRAME.COMPILE_BUTTON.TITLE"));
compileBtn.setActionCommand(ActionCommands.COMPILE_ACTION);
compileBtn.addActionListener(this);
evalBtn = new JButton(NLS.nls("MAIN.FRAME.EVALUATE_BUTTON.TITLE"));
evalBtn.setActionCommand(ActionCommands.EVALUATE_ACTION);
evalBtn.addActionListener(this);
evalBtn.setEnabled(false);
statusLbl = new JLabel();
statusLbl.setHorizontalAlignment(SwingConstants.RIGHT);
JPanel btnPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
btnPane.add(compileBtn);
btnPane.add(evalBtn);
btnPane.add(statusLbl);
getContentPane().add(btnPane, BorderLayout.SOUTH);
origin: skylot/jadx

  private void initUI() {
    JLabel lbl = new JLabel(NLS.str("usage_dialog.label"));
    JLabel nodeLabel = new JLabel(this.node.makeLongString(), this.node.getIcon(), SwingConstants.LEFT);
    lbl.setLabelFor(nodeLabel);

    JPanel searchPane = new JPanel();
    searchPane.setLayout(new FlowLayout(FlowLayout.LEFT));
    searchPane.add(lbl);
    searchPane.add(nodeLabel);
    searchPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    initCommon();
    JPanel resultsPanel = initResultsTable();
    JPanel buttonPane = initButtonsPanel();

    Container contentPane = getContentPane();
    contentPane.add(searchPane, BorderLayout.PAGE_START);
    contentPane.add(resultsPanel, BorderLayout.CENTER);
    contentPane.add(buttonPane, BorderLayout.PAGE_END);

    setTitle(NLS.str("usage_dialog.title"));
    pack();
    setSize(800, 500);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setModalityType(ModalityType.MODELESS);
  }
}
origin: wildfly/wildfly

cache.addChangeListener(model);
add(new JScrollPane(table));
JPanel key=new JPanel(new FlowLayout(FlowLayout.LEFT));
key.add(new JLabel("Key  "));
key.add(key_field);
add(key);
JPanel value=new JPanel(new FlowLayout(FlowLayout.LEFT));
value.add(new JLabel("Value"));
JPanel repl_count=new JPanel(new FlowLayout(FlowLayout.LEFT));
repl_count.add(new JLabel("Replication count"));
JPanel timeout=new JPanel(new FlowLayout(FlowLayout.LEFT));
JPanel prefix=new JPanel(new FlowLayout(FlowLayout.LEFT));
JPanel keys=new JPanel(new FlowLayout(FlowLayout.LEFT));
JPanel size=new JPanel(new FlowLayout(FlowLayout.LEFT));
JPanel perf_repl_count=new JPanel(new FlowLayout(FlowLayout.LEFT));
JPanel perf_timeout=new JPanel(new FlowLayout(FlowLayout.LEFT));
JPanel perf_buttons=new JPanel(new FlowLayout(FlowLayout.LEFT));
origin: log4j/log4j

protected JPanel createStatusArea() {
 JPanel statusArea = new JPanel();
 JLabel status =
   new JLabel("No log records to display.");
 _statusLabel = status;
 status.setHorizontalAlignment(JLabel.LEFT);
 statusArea.setBorder(BorderFactory.createEtchedBorder());
 statusArea.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
 statusArea.add(status);
 return (statusArea);
}
origin: chewiebug/GCViewer

/**
 * @param gcResource resource to be tracked
 */
public GCModelLoaderView(GCResource gcResource) {
  super(new BorderLayout());
  setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  JPanel parserInfo = new JPanel(new FlowLayout(FlowLayout.LEFT));
  progressBar = new JProgressBar(0, 100);
  progressBar.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  progressBar.setVisible(true);
  progressBar.setValue(0);
  progressBar.setStringPainted(true);
  cancelButton = new JButton(new SquareIcon());
  cancelButton.setActionCommand(CMD_CANCEL);
  cancelButton.addActionListener(this);
  messageLabel = new JLabel();
  messageLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  messageLabel.setVisible(false);
  parserInfo.add(progressBar);
  parserInfo.add(cancelButton);
  parserInfo.add(messageLabel);
  add(parserInfo, BorderLayout.NORTH);
  JTextArea textArea = textAreaLogHandler.getTextArea();
  textArea.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
  JScrollPane textAreaScrollPane = new JScrollPane(textArea);
  textAreaScrollPane.setPreferredSize(new Dimension(700, 500));
  add(textAreaScrollPane, BorderLayout.CENTER);
  setGCResource(gcResource);
}
origin: stackoverflow.com

JFrame frame = new JFrame();
frame.setTitle("Welcome!");
frame.setSize(520, 480);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel heroShotPanel = new JPanel();
JLabel heroShot = new JLabel(heroShotImage);
heroShotPanel.add(heroShot);
JPanel submitPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
JButton start = new JButton("Start");
start.setToolTipText("Click to use library");
submitPanel.add(start);
frame.getContentPane().add(heroShotPanel, BorderLayout.NORTH);
frame.getContentPane().add(submitPanel, BorderLayout.SOUTH);
frame.setVisible(true);
frame.getRootPane().setDefaultButton(start);
start.requestFocus();
origin: stackoverflow.com

final JFrame frame = new JFrame("Nested Layout Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JPanel gui = new JPanel(new BorderLayout(5,5));
gui.setBorder( new TitledBorder("BorderLayout(5,5)") );
JPanel plafComponents = new JPanel(
  new FlowLayout(FlowLayout.RIGHT, 3,3));
plafComponents.setBorder(
  new TitledBorder("FlowLayout(FlowLayout.RIGHT, 3,3)") );
plafComponents.add(plafChooser);
plafComponents.add(pack);
gui.add(plafComponents, BorderLayout.NORTH);
  new TitledBorder("GridLayout(0,2,3,3)") );
JButton addNew = new JButton("Add Another Label");
    labels.add( new JLabel("Label " + ++labelCount) );
frame.setContentPane(gui);
frame.pack();
origin: wiztools/rest-client

private void initComponents() {
  JPanel jp = new JPanel();
  jp.setLayout(new BorderLayout());
  jta_error = new JTextArea(10, 40);
  jta_error.setEditable(false);
  JScrollPane jsp = new JScrollPane(jta_error);
  jp.add(jsp, BorderLayout.CENTER);
  
  JPanel jp_south = new JPanel();
  jp_south.setLayout(new FlowLayout(FlowLayout.CENTER));
  
  jb_ok = new JButton("Ok");
  jb_ok.setMnemonic('o');
  getRootPane().setDefaultButton(jb_ok);
  jb_ok.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent event) {
      jb_okActionPerformed(event);
    }
  });
  jp_south.add(jb_ok);
  
  jp.add(jp_south, BorderLayout.SOUTH);
  this.setContentPane(jp);
  pack();
}

java.awtFlowLayout

Javadoc

A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. Flow layouts are typically used to arrange buttons in a panel. It will arrange buttons left to right until no more buttons fit on the same line. Each line is centered.

For example, the following picture shows an applet using the flow layout manager (its default layout manager) to position three buttons:

Here is the code for this applet:

Note: The following code example includes classes that do not appear in this specification. Their inclusion is purely to serve as a demonstration.


  
import java.awt.*;  
import java.applet.Applet; 
public class myButtons extends Applet { 
Button button1, button2, button3; 
public void init() { 
button1 = new Button("Ok"); 
button2 = new Button("Open"); 
button3 = new Button("Close"); 
add(button1); 
add(button2); 
add(button3); 
} 
} 

A flow layout lets each component assume its natural (preferred) size.

Most used methods

  • <init>
    Creates a new flow layout manager with the indicated alignment and the indicated horizontal and vert
  • setAlignment
    Sets the alignment for this layout. Possible values are * FlowLayout.LEFT * FlowLayout.RIGHT * Flo
  • setVgap
    Sets the vertical gap between components.
  • setHgap
    Sets the horizontal gap between components.
  • layoutContainer
    Lays out the container. This method lets each component take its preferred size by reshaping the com
  • setAlignOnBaseline
  • getVgap
    Gets the vertical gap between components.
  • getHgap
    Gets the horizontal gap between components.
  • addView
  • getAlignment
    Gets the alignment for this layout. Possible values are FlowLayout.LEFT, FlowLayout.RIGHT, FlowLayou

Popular in Java

  • Creating JSON documents from java classes using gson
  • setContentView (Activity)
  • getApplicationContext (Context)
  • compareTo (BigDecimal)
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • JCheckBox (javax.swing)
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now