java.awt.FlowLayout Java Examples

The following examples show how to use java.awt.FlowLayout. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GameInfoDialog.java    From FancyBing with GNU General Public License v3.0 7 votes vote down vote up
private JTextField createEntry(String labelText, int cols, String text,
                               String toolTipText, JComponent labels,
                               JComponent values)
{
    Box boxLabel = Box.createHorizontalBox();
    boxLabel.add(Box.createHorizontalGlue());
    JLabel label = new JLabel(i18n(labelText));
    label.setAlignmentY(Component.CENTER_ALIGNMENT);
    boxLabel.add(label);
    labels.add(boxLabel);
    JPanel fieldPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    JTextField field = new JTextField(cols);
    field.setHorizontalAlignment(JTextField.CENTER);
    field.setToolTipText(i18n(toolTipText));
    field.setText(text);
    fieldPanel.add(field);
    values.add(fieldPanel);
    return field;
}
 
Example #2
Source File: SelectionVisible.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void init() {
    tf = new TextField(20);
    tf.setText("0123456789");
    tf.select(0, 6);

    final TextArea ta = new TextArea("INSTRUCTIONS:\n"
                                     + "The text 012345 should be selected in the TextField.\n"
                                     + "If this is what you observe, then the test passes.\n"
                                     + "Otherwise, the test fails.", 40, 5,
                                     TextArea.SCROLLBARS_NONE);
    ta.setEditable(false);
    ta.setPreferredSize(new Dimension(300, 70));
    final Panel panel = new Panel();
    panel.setLayout(new FlowLayout());
    panel.add(tf);
    setLayout(new BorderLayout());
    add(ta, BorderLayout.CENTER);
    add(panel, BorderLayout.PAGE_END);
}
 
Example #3
Source File: GenericDialogPlus.java    From ij-ridgedetection with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds the directory field.
 *
 * @param label
 *            the label
 * @param defaultPath
 *            the default path
 * @param columns
 *            the columns
 */
public void addDirectoryField(String label, String defaultPath, int columns) {
	addStringField(label, defaultPath, columns);
	if (isHeadless())
		return;

	TextField text = (TextField) stringField.lastElement();
	GridBagLayout layout = (GridBagLayout) getLayout();
	GridBagConstraints constraints = layout.getConstraints(text);

	Button button = new Button("Browse...");
	DirectoryListener listener = new DirectoryListener("Browse for " + label, text);
	button.addActionListener(listener);
	button.addKeyListener(this);

	Panel panel = new Panel();
	panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
	panel.add(text);
	panel.add(button);

	layout.setConstraints(panel, constraints);
	add(panel);
}
 
Example #4
Source File: TextFlipSelectOnEscape.java    From radiance with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Creates the main frame for <code>this</code> sample.
 */
public TextFlipSelectOnEscape() {
    super("Text flip select on ESC");

    this.setLayout(new BorderLayout());

    final JTextField jtf = new JTextField("sample text");
    jtf.setColumns(20);

    JPanel main = new JPanel(new FlowLayout(FlowLayout.CENTER));
    this.add(main, BorderLayout.CENTER);
    main.add(jtf);

    JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    final JCheckBox hasSelectOnFocus = new JCheckBox("Has \"flip select on ESC\" behaviour");
    hasSelectOnFocus.addActionListener((ActionEvent e) -> SubstanceCortex.ComponentScope
            .setFlipTextSelectionOnEscape(jtf, hasSelectOnFocus.isSelected()));

    controls.add(hasSelectOnFocus);
    this.add(controls, BorderLayout.SOUTH);

    this.setSize(400, 200);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
 
Example #5
Source File: JRadioButtonExample.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
   JFrame frame = new JFrame("JRadioButton Example");
   check = new JRadioButton("Check here ");
   check2 = new JRadioButton("Or check here");
   ButtonGroup bg = new ButtonGroup();
   bg.add(check);
   bg.add(check2);
   
   frame.getContentPane().add(check);
   frame.getContentPane().setLayout(new FlowLayout());
   frame.getContentPane().add(check2);
   frame.pack();
   frame.setLocationRelativeTo(null);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setVisible(true);
   
   Thread.sleep(2000);
   bg.clearSelection();
}
 
Example #6
Source File: GenericDialogPlus.java    From ij-ridgedetection with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds the file field.
 *
 * @param label
 *            the label
 * @param defaultPath
 *            the default path
 * @param columns
 *            the columns
 */
public void addFileField(String label, String defaultPath, int columns) {
	addStringField(label, defaultPath, columns);
	if (isHeadless())
		return;

	TextField text = (TextField) stringField.lastElement();
	GridBagLayout layout = (GridBagLayout) getLayout();
	GridBagConstraints constraints = layout.getConstraints(text);

	Button button = new Button("Browse...");
	FileListener listener = new FileListener("Browse for " + label, text);
	button.addActionListener(listener);
	button.addKeyListener(this);

	Panel panel = new Panel();
	panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
	panel.add(text);
	panel.add(button);

	layout.setConstraints(panel, constraints);
	add(panel);
}
 
Example #7
Source File: SchemaTreeTraverser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Simple constructor.
 */
public SchemaTreeCellRenderer() {
    FlowLayout fl = new FlowLayout(FlowLayout.LEFT, 1, 1);
    this.setLayout(fl);
    this.iconLabel = new JLabel();
    this.iconLabel.setOpaque(false);
    this.iconLabel.setBorder(null);
    this.add(this.iconLabel);

    // add some space
    this.add(Box.createHorizontalStrut(5));

    this.nameLabel = new JLabel();
    this.nameLabel.setOpaque(false);
    this.nameLabel.setBorder(null);
    this.nameLabel.setFont(nameFont);
    this.add(this.nameLabel);

    this.isSelected = false;

    this.setOpaque(false);
    this.setBorder(null);
}
 
Example #8
Source File: GuiUtils.java    From sc2gears with Apache License 2.0 6 votes vote down vote up
/**
 * Adds a link-style edit list label to the bottom of the popup of the specified combo box.<br>
 * When the link is activated (clicked), the editTask will be run.
 * @param comboBox combo box to add the edit link to
 * @param editTask edit task to be performed when the link is activated
 */
public static void addEditListLinkToComboBoxPopup( final JComboBox< ? > comboBox, final Runnable editTask ) {
	final Object child = comboBox.getUI().getAccessibleChild( comboBox, 0 );
	if ( child instanceof JPopupMenu ) {
		final JPanel editPanel = new JPanel( new FlowLayout( FlowLayout.RIGHT, 3, 1 ) );
		final JLabel editLinkLabel = GeneralUtils.createLinkStyledLabel( Language.getText( "general.editList" ) );
		editLinkLabel.addMouseListener( new MouseAdapter() {
			public void mousePressed( final MouseEvent event ) {
				comboBox.hidePopup();
				editTask.run();
			};
		} );
		editPanel.add( editLinkLabel );
		( (JPopupMenu) child ).add( editPanel );
	}
}
 
Example #9
Source File: AttributeEditorPanel.java    From ramus with GNU General Public License v3.0 6 votes vote down vote up
public AttributeEditorPanel() {
    super(new BorderLayout());
    okc = new JPanel(new GridLayout(1, 3, 5, 0));

    JButton ok = new JButton(okAction);

    cancel = new JButton(cancelAction);

    apply = new JButton(applyAction);

    addOk(ok, okc);
    okc.add(apply);
    okc.add(cancel);
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 5));
    panel.add(okc);
    this.add(panel, BorderLayout.SOUTH);
    setAttributeEditor(null, null, null, null, false, null);
}
 
Example #10
Source File: ContainerFocusAutoTransferTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public TestFrame() {
    super("TestFrame");

    // The change of the orientation and the reverse order of
    // adding the buttons to the panel is because in Container.removeNotify()
    // the child components are removed in the reverse order.
    // We want that the focus owner (b0) would be removed first and
    // that the next traversable component would be b1.
    panel0.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    panel0.add(b2);
    panel0.add(b1);
    panel0.add(b0);

    panel1.add(b3);
    panel1.add(b4);

    setLayout(new FlowLayout());
    add(panel0);
    add(panel1);
    pack();

    panel0.setBackground(Color.red);
    panel1.setBackground(Color.blue);
}
 
Example #11
Source File: AnimGifExport.java    From Pixelitor with GNU General Public License v3.0 6 votes vote down vote up
public ExportPanel(int nrLayers) {
    setBorder(createEmptyBorder(10, 10, 10, 10));
    setLayout(new VerticalLayout(10));

    add(new JLabel(" Animation frames are based on the layers of the image. "));

    var settingsPanel = new JPanel();
    settingsPanel.setLayout(new FlowLayout(LEFT, 10, 10));
    settingsPanel.add(new JLabel("Delay Between Frames (Milliseconds):"));
    delayTF = new JTextField("200", 4);
    settingsPanel.add(delayTF);

    add(settingsPanel);

    if (nrLayers > 2) {
        pingPongCB = new JCheckBox("Ping Pong Animation");
    } else {
        pingPongCB = new JCheckBox("Ping Pong Animation (min 3 layers needed)");
        pingPongCB.setEnabled(false);
    }
    add(pingPongCB);
}
 
Example #12
Source File: AddDocumentDialogFactory.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private JPanel center() {
  JPanel panel = new JPanel(new BorderLayout());
  panel.setOpaque(false);
  panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

  JPanel tableHeader = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 5));
  tableHeader.setOpaque(false);
  tableHeader.add(new JLabel(MessageUtils.getLocalizedMessage("add_document.label.fields")));
  panel.add(tableHeader, BorderLayout.PAGE_START);

  JScrollPane scrollPane = new JScrollPane(fieldsTable());
  scrollPane.setOpaque(false);
  scrollPane.getViewport().setOpaque(false);
  panel.add(scrollPane, BorderLayout.CENTER);

  JPanel tableFooter = new JPanel(new FlowLayout(FlowLayout.TRAILING, 10, 5));
  tableFooter.setOpaque(false);
  addBtn.setEnabled(true);
  tableFooter.add(addBtn);
  tableFooter.add(closeBtn);
  panel.add(tableFooter, BorderLayout.PAGE_END);

  return panel;
}
 
Example #13
Source File: SeaGlassRootPaneUITest.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * DOCUMENT ME!
 */
@Test
@Ignore // Needs an update
public void testSimpleFrameSize() {
    JFrame frame = new JFrame();
    JPanel content = new JPanel();
    content.setLayout(new FlowLayout(FlowLayout.CENTER));
    content.setBackground(new Color(250, 250, 250));
    content.setPreferredSize(new Dimension(400,400));
    frame.add(BorderLayout.CENTER, content);
    frame.pack();
    Dimension frameSize = frame.getSize();
    Dimension contentSize = content.getSize();
    int titleHeight = PlatformUtils.isMac() ? 22 : 25;
    assertEquals("Window height must correspond to content width + title height", 400 + titleHeight, frameSize.height);
    assertEquals("Window width must correspond to content width", 400, frameSize.width);
    assertEquals("Content height must be 400", 400, contentSize.height);
    assertEquals("Content width must be 400", 400, contentSize.width);
}
 
Example #14
Source File: InfoComponentFactory.java    From JglTF with MIT License 6 votes vote down vote up
/**
 * Create an info component with the given text
 * 
 * @param title The title for the component
 * @param text The text
 * @return The component
 */
JComponent createTextInfoPanel(String title, String text)
{
    JPanel textInfoPanel = new JPanel(new BorderLayout());
    
    JPanel controlPanel = new JPanel(new FlowLayout());
    controlPanel.add(new JLabel(title));
    
    JButton saveButton = new JButton("Save as...");
    saveButton.addActionListener(
        e -> saveTextAs(textInfoPanel, text));
    controlPanel.add(saveButton);
    
    textInfoPanel.add(controlPanel, BorderLayout.NORTH);
    JTextArea textArea = new JTextArea(text);
    textArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
    textInfoPanel.add(new JScrollPane(textArea), BorderLayout.CENTER);
    return textInfoPanel;
}
 
Example #15
Source File: SetRootPaneSkin.java    From radiance with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Opens a sample frame under the specified skin.
 * 
 * @param skin
 *            Skin.
 */
private void openSampleFrame(SubstanceSkin skin) {
    JFrame sampleFrame = new JFrame(skin.getDisplayName());
    sampleFrame.setLayout(new FlowLayout());
    JButton defaultButton = new JButton("active");
    JButton button = new JButton("default");
    JButton disabledButton = new JButton("disabled");
    disabledButton.setEnabled(false);
    sampleFrame.getRootPane().setDefaultButton(defaultButton);

    sampleFrame.add(defaultButton);
    sampleFrame.add(button);
    sampleFrame.add(disabledButton);

    sampleFrame.setVisible(true);
    sampleFrame.pack();
    sampleFrame.setLocationRelativeTo(null);
    sampleFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    sampleFrame.setIconImage(new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR));

    SubstanceCortex.RootPaneScope.setSkin(sampleFrame.getRootPane(), skin);
    SwingUtilities.updateComponentTreeUI(sampleFrame);
    sampleFrame.repaint();
}
 
Example #16
Source File: AnalyzeDialog.java    From FancyBing with GNU General Public License v3.0 6 votes vote down vote up
private JPanel createButtons()
{
    JPanel innerPanel = new JPanel(new GridLayout(1, 0, GuiUtil.PAD, 0));
    m_runButton = new JButton(i18n("LB_RUN"));
    m_runButton.setToolTipText(i18n("TT_ANALYZE_RUN"));
    m_runButton.setActionCommand("run");
    m_runButton.addActionListener(this);
    m_runButton.setMnemonic(KeyEvent.VK_R);
    m_runButton.setEnabled(false);
    GuiUtil.setMacBevelButton(m_runButton);
    innerPanel.add(m_runButton);
    m_clearButton = new JButton(i18n("LB_ANALYZE_CLEAR"));
    m_clearButton.setToolTipText(i18n("TT_ANALYZE_CLEAR"));
    m_clearButton.setActionCommand("clear");
    m_clearButton.addActionListener(this);
    m_clearButton.setMnemonic(KeyEvent.VK_C);
    GuiUtil.setMacBevelButton(m_clearButton);
    innerPanel.add(m_clearButton);
    JPanel outerPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    outerPanel.add(innerPanel);
    return outerPanel;
}
 
Example #17
Source File: ContainerFocusAutoTransferTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public TestFrame() {
    super("TestFrame");

    // The change of the orientation and the reverse order of
    // adding the buttons to the panel is because in Container.removeNotify()
    // the child components are removed in the reverse order.
    // We want that the focus owner (b0) would be removed first and
    // that the next traversable component would be b1.
    panel0.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    panel0.add(b2);
    panel0.add(b1);
    panel0.add(b0);

    panel1.add(b3);
    panel1.add(b4);

    setLayout(new FlowLayout());
    add(panel0);
    add(panel1);
    pack();

    panel0.setBackground(Color.red);
    panel1.setBackground(Color.blue);
}
 
Example #18
Source File: MapBoxTool.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/** Creates the ui. */
private void createUI() {
    groupPanel = new JPanel();
    FlowLayout flowLayout = (FlowLayout) groupPanel.getLayout();
    flowLayout.setVgap(0);
    flowLayout.setHgap(0);
    TitledBorder titledBorder =
            BorderFactory.createTitledBorder(
                    Localisation.getString(MapBoxTool.class, "MapBoxTool.groupTitle"));
    groupPanel.setBorder(titledBorder);

    // Export to SLD
    exportToSLDButton =
            new ToolButton(
                    Localisation.getString(MapBoxTool.class, "MapBoxTool.exportToSLD"),
                    "tool/exporttosld.png");
    exportToSLDButton.setEnabled(false);
    exportToSLDButton.addActionListener(
            new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    exportToSLD();
                }
            });
    groupPanel.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
    groupPanel.add(exportToSLDButton);
}
 
Example #19
Source File: TurnsPanel.java    From MtgDesktopCompanion with GNU General Public License v3.0 6 votes vote down vote up
public TurnsPanel() {
	FlowLayout flowLayout = (FlowLayout) getLayout();
	flowLayout.setVgap(1);
	flowLayout.setHgap(1);
	flowLayout.setAlignment(FlowLayout.LEFT);
	lblTurnNumber = new JLabel("Turn " + GameManager.getInstance().getTurns().size());
	add(lblTurnNumber);

	add(new JButton(new UntapPhase()));
	add(new JButton(new UpkeepPhase()));
	add(new JButton(new DrawPhase()));
	add(new JButton(new MainPhase(1)));
	add(new JButton(new CombatPhase()));
	add(new JButton(new AttackPhase()));
	add(new JButton(new BlockPhase()));
	add(new JButton(new DamagePhase()));
	add(new JButton(new EndCombatPhase()));
	add(new JButton(new MainPhase(2)));
	add(new JButton(new EndPhase()));
	add(new JButton(new CleanUpPhase()));
	add(new JButton(new EndTurnPhase()));
}
 
Example #20
Source File: DisambiguationWindow.java    From wpcleaner with Apache License 2.0 6 votes vote down vote up
/**
 * @return Page components.
 */
private Component createPageComponents() {
  JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
  addTextPageName(panel);
  JToolBar toolbar = new JToolBar(SwingConstants.HORIZONTAL);
  toolbar.setFloatable(false);
  toolbar.setBorderPainted(false);
  addButtonReload(toolbar, true);
  buttonView = ActionExternalViewer.addButton(
      toolbar, getWikipedia(), getPageName(), false, true, false);
  buttonViewHistory = ActionExternalViewer.addButton(
      toolbar, getWikipedia(), getPageName(), ActionExternalViewer.ACTION_HISTORY, true, true);
  addButtonSend(toolbar, true);
  buttonWatch = ActionWatchPage.addButton(
      getParentComponent(), toolbar, getWikipedia(), getPageName(), true, true);
  addButtonFullAnalysis(toolbar, true);
  panel.add(toolbar);
  return panel;
}
 
Example #21
Source File: SelectionVisible.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void init() {
    tf = new TextField(20);
    tf.setText("0123456789");
    tf.select(0, 6);

    final TextArea ta = new TextArea("INSTRUCTIONS:\n"
                                     + "The text 012345 should be selected in the TextField.\n"
                                     + "If this is what you observe, then the test passes.\n"
                                     + "Otherwise, the test fails.", 40, 5,
                                     TextArea.SCROLLBARS_NONE);
    ta.setEditable(false);
    ta.setPreferredSize(new Dimension(300, 70));
    final Panel panel = new Panel();
    panel.setLayout(new FlowLayout());
    panel.add(tf);
    setLayout(new BorderLayout());
    add(ta, BorderLayout.CENTER);
    add(panel, BorderLayout.PAGE_END);
}
 
Example #22
Source File: OptionPanel.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This method initializes jStatusPanel
 * 
 * @return javax.swing.JPanel
 */
private JPanel getJStatusPanel() {
    if (jStatusPanel == null) {
        jStatusPanel = JPlagCreator.createPanel(null, 690, 140, 7, 20,
                FlowLayout.CENTER, -1);
        jStatusPanel.setName("ScanStatus"); //$NON-NLS-1$
        jStatusPanel.add(JPlagCreator.createLabel(Messages.getString(
                "OptionPanel.Status") + ":", //$NON-NLS-1$ //$NON-NLS-2$
                330, 20), null);
        jStatusPanel.add(getStatusTextField(), null);
        jStatusPanel.add(JPlagCreator.createLabel(Messages.getString(
                "OptionPanel.Number_of_programs") + ":", //$NON-NLS-1$ //$NON-NLS-2$
                330, 20), null);
        jStatusPanel.add(getJNumValidProgramsField(), null);
        jStatusPanel.add(JPlagCreator.createLabel(Messages.getString(
                "OptionPanel.Total_number_of_files") + ":", //$NON-NLS-1$ //$NON-NLS-2$
                330, 20), null);
        jStatusPanel.add(getJNumFilesField(), null);
        jStatusPanel.add(JPlagCreator.createLabel(Messages.getString(
                "OptionPanel.Total_size_of_submission") + ":", //$NON-NLS-1$ //$NON-NLS-2$
                330, 20), null);
        jStatusPanel.add(getJSubmissionSizeField(), null);
        jStatusPanel.add(getPreviewButton(), null);
        jStatusPanel.add(getSubmitButton(), null);
    }
    return jStatusPanel;
}
 
Example #23
Source File: StartupProgressDialog.java    From zencash-swing-wallet-ui with MIT License 5 votes vote down vote up
public StartupProgressDialog(ZCashClientCaller clientCaller) 
  {
      this.clientCaller = clientCaller;
      
      URL iconUrl = this.getClass().getClassLoader().getResource("images/ZEN-yellow.orange-logo.png");
      imageIcon = new ImageIcon(iconUrl);
      imageLabel.setIcon(imageIcon);
      imageLabel.setBorder(BorderFactory.createEmptyBorder(16, 40, 8, 40));
      Container contentPane = getContentPane();
      contentPane.setLayout(borderLayout1);
      southPanel.setLayout(southPanelLayout);
      southPanel.setBorder(BorderFactory.createEmptyBorder(0, 16, 16, 16));
      contentPane.add(imageLabel, BorderLayout.NORTH);
JLabel zcashWalletLabel = new JLabel(LanguageUtil.instance().getString("startup.progress.dialog.label"));
zcashWalletLabel.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16));
// todo - place in a panel with flow center
JPanel tempPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 1, 1));
tempPanel.add(zcashWalletLabel);
contentPane.add(tempPanel, BorderLayout.CENTER);
      contentPane.add(southPanel, BorderLayout.SOUTH);
      progressBar.setIndeterminate(true);
      southPanel.add(progressBar, BorderLayout.NORTH);
      progressLabel.setText(LanguageUtil.instance().getString("startup.progress.dialog.progressbar.label"));
      southPanel.add(progressLabel, BorderLayout.SOUTH);
      pack();
      setLocationRelativeTo(null);
      
      this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  }
 
Example #24
Source File: TestDispose.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testDispose() throws InvocationTargetException,
        InterruptedException {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame("Test");

            textArea = new TextArea("editable textArea");
            textArea.setEditable(true);
            // textArea.setEditable(false); // this testcase passes if textArea is non-editable

            frame.setLayout(new FlowLayout());
            frame.add(textArea);

            frame.pack();
            frame.setVisible(true);
        }
    });
    toolkit.realSync();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame.dispose();
        }
    });
    toolkit.realSync();
}
 
Example #25
Source File: Regression_123931_swing.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
ControlPanel( Regression_123931_swing siv )
{
	this.siv = siv;

	setLayout( new GridLayout( 0, 1, 0, 0 ) );

	JPanel jp = new JPanel( );
	jp.setLayout( new FlowLayout( FlowLayout.LEFT, 3, 3 ) );

	add( jp );
}
 
Example #26
Source File: ScaleTool.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/** Creates the ui. */
private void createUI() {
    scaleGroupPanel = new JPanel();
    FlowLayout flowLayout = (FlowLayout) scaleGroupPanel.getLayout();
    flowLayout.setVgap(0);
    flowLayout.setHgap(0);
    scaleGroupPanel.setBorder(
            BorderFactory.createTitledBorder(
                    Localisation.getString(ScaleTool.class, "ScaleTool.scale")));

    scaleButton =
            new ToolButton(
                    Localisation.getString(ScaleTool.class, "ScaleTool.scale"),
                    "tool/scaletool.png");
    scaleGroupPanel.add(scaleButton);
    scaleButton.setEnabled(false);
    scaleButton.addActionListener(
            new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    ScaleToolPanel scalePanel = new ScaleToolPanel(application);

                    scalePanel.populate(sldDataList);
                    scalePanel.setVisible(true);
                }
            });
    scaleGroupPanel.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
}
 
Example #27
Source File: InputContextMemoryLeakTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void init() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame();
            frame.setLayout(new FlowLayout());
            JPanel p1 = new JPanel();
            button = new JButton("Test");
            p1.add(button);
            frame.add(p1);
            text = new WeakReference<JTextField>(new JTextField("Text"));
            p = new WeakReference<JPanel>(new JPanel(new FlowLayout()));
            p.get().add(text.get());
            frame.add(p.get());
            frame.setBounds(500, 400, 200, 200);
            frame.setVisible(true);
        }
    });

    Util.focusComponent(text.get(), 500);
    Util.clickOnComp(button, new Robot());
    //References to objects testes for memory leak are stored in Util.
    //Need to clean them
    Util.cleanUp();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame.remove(p.get());
        }
    });

    Util.waitForIdle(null);
    //After the next caret blink it automatically TextField references
    Thread.sleep(text.get().getCaret().getBlinkRate() * 2);
    Util.waitForIdle(null);
    assertGC();
}
 
Example #28
Source File: CycleThroughFrameTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void createAndShowInstructionFrame() {
    Button passButton = new Button("Pass");
    passButton.setEnabled(true);

    Button failButton = new Button("Fail");
    failButton.setEnabled(true);

    TextArea instructions = new TextArea(12, 70);
    instructions.setText(TEST_INSTRUCTIONS);

    instructionFrame = new Frame("Test Instructions");
    instructionFrame.add(passButton);
    instructionFrame.add(failButton);
    instructionFrame.add(instructions);
    instructionFrame.setSize(200,200);
    instructionFrame.setLayout(new FlowLayout());
    instructionFrame.pack();
    instructionFrame.setVisible(true);

    passButton.addActionListener(ae -> {
        dispose();
        testContinueFlag = false;
    });

    failButton.addActionListener(ae -> {
        dispose();
        testContinueFlag = false;
        throw new RuntimeException(FAIL_MESSAGE);
    });
}
 
Example #29
Source File: InitialFTP_AWT.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public AWTFrame(String title) {
    super(title);

    list.add("one");
    list.add("two");
    list.add("three");

    this.setLayout(new FlowLayout());
    this.add(button);
    this.add(text);
    this.add(list);
    this.pack();
}
 
Example #30
Source File: ButtonTabComponent.java    From binnavi with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new button tab component.
 * 
 * @param pane pane the button tab component belongs to.
 */
public ButtonTabComponent(final JTabbedPane pane) {
  // unset default FlowLayout' gaps
  super(new FlowLayout(FlowLayout.LEFT, 0, 0));

  m_pane = Preconditions.checkNotNull(pane, "IE01213: TabbedPane is null");
  setOpaque(false);

  // make JLabel read titles from JTabbedPane
  final JLabel label = new JLabel() {
    private static final long serialVersionUID = 8139543899934835869L;

    @Override
    public String getText() {
      final int index = pane.indexOfTabComponent(ButtonTabComponent.this);
      if (index != -1) {
        return pane.getTitleAt(index);
      }
      return null;
    }
  };

  add(label);
  // add more space between the label and the button
  label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
  // tab button
  final JButton button = new TabButton();
  add(button);
  // add more space to the top of the component
  setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
}