Search in sources :

Example 56 with FlowLayout

use of java.awt.FlowLayout in project jdk8u_jdk by JetBrains.

the class InputContextMemoryLeakTest method init.

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();
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JFrame(javax.swing.JFrame) WeakReference(java.lang.ref.WeakReference) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) Robot(java.awt.Robot)

Example 57 with FlowLayout

use of java.awt.FlowLayout in project jdk8u_jdk by JetBrains.

the class TexturePaintPrintingTest method doTest.

private static void doTest(Runnable action) {
    String description = " A TexturePaint graphics will be shown on console.\n" + " The same graphics is sent to printer.\n" + " Please verify if TexturePaint shading is printed.\n" + " If none is printed, press FAIL else press PASS";
    final JDialog dialog = new JDialog();
    dialog.setTitle("printSelectionTest");
    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);
    final JButton testButton = new JButton("Start Test");
    final JButton passButton = new JButton("PASS");
    passButton.setEnabled(false);
    passButton.addActionListener((e) -> {
        f.dispose();
        dialog.dispose();
        pass();
    });
    final JButton failButton = new JButton("FAIL");
    failButton.setEnabled(false);
    failButton.addActionListener((e) -> {
        f.dispose();
        dialog.dispose();
        fail();
    });
    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        action.run();
        passButton.setEnabled(true);
        failButton.setEnabled(true);
    });
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(textArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(testButton);
    buttonPanel.add(passButton);
    buttonPanel.add(failButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.add(mainPanel);
    dialog.pack();
    dialog.setVisible(true);
    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            System.out.println("main dialog closing");
            testGeneratedInterrupt = false;
            mainThread.interrupt();
        }
    });
}
Also used : JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) WindowEvent(java.awt.event.WindowEvent) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) JDialog(javax.swing.JDialog)

Example 58 with FlowLayout

use of java.awt.FlowLayout in project jdk8u_jdk by JetBrains.

the class SelectionVisible method init.

@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);
}
Also used : Panel(java.awt.Panel) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) TextArea(java.awt.TextArea) TextField(java.awt.TextField) Dimension(java.awt.Dimension)

Example 59 with FlowLayout

use of java.awt.FlowLayout in project GDSC-SMLM by aherbert.

the class MultiDialog method buildButtonPanel.

protected Panel buildButtonPanel() {
    Panel buttons = new Panel();
    buttons.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 0));
    all = new Button("All");
    all.addActionListener(this);
    all.addKeyListener(this);
    buttons.add(all);
    none = new Button("None");
    none.addActionListener(this);
    none.addKeyListener(this);
    buttons.add(none);
    okay = new Button("OK");
    okay.addActionListener(this);
    okay.addKeyListener(this);
    buttons.add(okay);
    cancel = new Button("Cancel");
    cancel.addActionListener(this);
    cancel.addKeyListener(this);
    buttons.add(cancel);
    return buttons;
}
Also used : Panel(java.awt.Panel) FlowLayout(java.awt.FlowLayout) Button(java.awt.Button)

Example 60 with FlowLayout

use of java.awt.FlowLayout in project GDSC-SMLM by aherbert.

the class SpotAnalysis method createFrame.

@SuppressWarnings({ "rawtypes", "unchecked" })
private void createFrame() {
    Panel mainPanel = new Panel();
    add(mainPanel);
    inputChoice = new Choice();
    mainPanel.add(createChoicePanel(inputChoice, ""));
    widthTextField = new TextField();
    mainPanel.add(createTextPanel(widthTextField, "PSF width", "1.2"));
    blurTextField = new TextField();
    mainPanel.add(createTextPanel(blurTextField, "Blur (relative to width)", "1"));
    gainTextField = new TextField();
    mainPanel.add(createTextPanel(gainTextField, "Gain", "37.7"));
    exposureTextField = new TextField();
    mainPanel.add(createTextPanel(exposureTextField, "ms/Frame", "20"));
    smoothingTextField = new TextField();
    mainPanel.add(createTextPanel(smoothingTextField, "Smoothing", "0.25"));
    profileButton = new Button("Profile");
    profileButton.addActionListener(this);
    addButton = new Button("Add");
    addButton.addActionListener(this);
    deleteButton = new Button("Remove");
    deleteButton.addActionListener(this);
    saveButton = new Button("Save");
    saveButton.addActionListener(this);
    saveTracesButton = new Button("Save Traces");
    saveTracesButton.addActionListener(this);
    currentLabel = new Label();
    mainPanel.add(createLabelPanel(currentLabel, "", ""));
    rawFittedLabel = new Label();
    mainPanel.add(createLabelPanel(rawFittedLabel, "", ""));
    blurFittedLabel = new Label();
    mainPanel.add(createLabelPanel(blurFittedLabel, "", ""));
    JPanel buttonPanel = new JPanel();
    FlowLayout l = new FlowLayout();
    l.setVgap(0);
    buttonPanel.setLayout(l);
    buttonPanel.add(profileButton, BorderLayout.CENTER);
    buttonPanel.add(addButton, BorderLayout.CENTER);
    buttonPanel.add(deleteButton, BorderLayout.CENTER);
    buttonPanel.add(saveButton, BorderLayout.CENTER);
    buttonPanel.add(saveTracesButton, BorderLayout.CENTER);
    mainPanel.add(buttonPanel);
    listModel = new DefaultListModel();
    onFramesList = new JList(listModel);
    onFramesList.setVisibleRowCount(15);
    onFramesList.addListSelectionListener(this);
    //mainPanel.add(onFramesList);
    JScrollPane scrollPane = new JScrollPane(onFramesList);
    scrollPane.getVerticalScrollBarPolicy();
    mainPanel.add(scrollPane);
    GridBagLayout mainGrid = new GridBagLayout();
    int y = 0;
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = 1;
    c.insets = new Insets(2, 2, 2, 2);
    for (Component comp : mainPanel.getComponents()) {
        c.gridy = y++;
        mainGrid.setConstraints(comp, c);
    }
    mainPanel.setLayout(mainGrid);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Choice(java.awt.Choice) FlowLayout(java.awt.FlowLayout) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Label(java.awt.Label) DefaultListModel(javax.swing.DefaultListModel) Point(java.awt.Point) Panel(java.awt.Panel) JPanel(javax.swing.JPanel) Button(java.awt.Button) TextField(java.awt.TextField) Component(java.awt.Component) JList(javax.swing.JList)

Aggregations

FlowLayout (java.awt.FlowLayout)400 JPanel (javax.swing.JPanel)338 JLabel (javax.swing.JLabel)189 JButton (javax.swing.JButton)161 ActionEvent (java.awt.event.ActionEvent)134 BoxLayout (javax.swing.BoxLayout)129 BorderLayout (java.awt.BorderLayout)118 ActionListener (java.awt.event.ActionListener)113 Dimension (java.awt.Dimension)95 JScrollPane (javax.swing.JScrollPane)94 Container (java.awt.Container)49 GridBagLayout (java.awt.GridBagLayout)42 JTextField (javax.swing.JTextField)41 Insets (java.awt.Insets)39 GridBagConstraints (java.awt.GridBagConstraints)38 ButtonGroup (javax.swing.ButtonGroup)38 JCheckBox (javax.swing.JCheckBox)35 JTable (javax.swing.JTable)32 JmriJFrame (jmri.util.JmriJFrame)30 JSeparator (javax.swing.JSeparator)24