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();
}
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();
}
});
}
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);
}
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;
}
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);
}
Aggregations