use of javax.swing.Timer in project jdk8u_jdk by JetBrains.
the class Test6559154 method run.
public void run() {
Timer timer = new Timer(1000, this);
timer.setRepeats(false);
timer.start();
JColorChooser chooser = new JColorChooser();
setEnabledRecursive(chooser, false);
this.dialog = new JDialog();
this.dialog.add(chooser);
this.dialog.setVisible(true);
}
use of javax.swing.Timer in project jmeter by apache.
the class StatVisualizer method init.
/**
* Main visualizer setup.
*/
private void init() {
// WARNING: called from ctor so must not be overridden (i.e. must be private or final)
this.setLayout(new BorderLayout());
// MAIN PANEL
JPanel mainPanel = new JPanel();
Border margin = new EmptyBorder(10, 10, 5, 10);
mainPanel.setBorder(margin);
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
mainPanel.add(makeTitlePanel());
myJTable = new JTable(model);
myJTable.setRowSorter(new ObjectTableSorter(model).fixLastRow());
JMeterUtils.applyHiDPI(myJTable);
HeaderAsPropertyRendererWrapper.setupDefaultRenderer(myJTable, StatGraphVisualizer.getColumnsMsgParameters());
myJTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
RendererUtils.applyRenderers(myJTable, StatGraphVisualizer.getRenderers());
myScrollPane = new JScrollPane(myJTable);
this.add(mainPanel, BorderLayout.NORTH);
this.add(myScrollPane, BorderLayout.CENTER);
saveTable.addActionListener(this);
JPanel opts = new JPanel();
opts.add(useGroupName, BorderLayout.WEST);
opts.add(saveTable, BorderLayout.CENTER);
opts.add(saveHeaders, BorderLayout.EAST);
this.add(opts, BorderLayout.SOUTH);
new Timer(REFRESH_PERIOD, e -> {
synchronized (lock) {
while (!newRows.isEmpty()) {
model.insertRow(newRows.pop(), model.getRowCount() - 1);
}
}
model.fireTableDataChanged();
}).start();
}
use of javax.swing.Timer in project jmeter by apache.
the class TableVisualizer method init.
private void init() {
// WARNING: called from ctor so must not be overridden (i.e. must be private or final)
this.setLayout(new BorderLayout());
// MAIN PANEL
JPanel mainPanel = new JPanel();
Border margin = new EmptyBorder(10, 10, 5, 10);
mainPanel.setBorder(margin);
mainPanel.setLayout(new VerticalLayout(5, VerticalLayout.BOTH));
// NAME
mainPanel.add(makeTitlePanel());
// Set up the table itself
table = new JTable(model);
table.setRowSorter(new ObjectTableSorter(model).setValueComparator(5, Comparator.nullsFirst((ImageIcon o1, ImageIcon o2) -> {
if (o1 == o2) {
return 0;
}
if (o1 == imageSuccess) {
return -1;
}
if (o1 == imageFailure) {
return 1;
}
throw new IllegalArgumentException("Only success and failure images can be compared");
})));
JMeterUtils.applyHiDPI(table);
HeaderAsPropertyRendererWrapper.setupDefaultRenderer(table);
RendererUtils.applyRenderers(table, RENDERERS);
tableScrollPanel = new JScrollPane(table);
tableScrollPanel.setViewportBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
//$NON-NLS-1$
autoscroll = new JCheckBox(JMeterUtils.getResString("view_results_autoscroll"));
//$NON-NLS-1$
childSamples = new JCheckBox(JMeterUtils.getResString("view_results_childsamples"));
// Set up footer of table which displays numerics of the graphs
JPanel dataPanel = new JPanel();
// $NON-NLS-1$
JLabel dataLabel = new JLabel(JMeterUtils.getResString("graph_results_latest_sample"));
dataLabel.setForeground(Color.black);
dataField = new JTextField(5);
dataField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
dataField.setEditable(false);
dataField.setForeground(Color.black);
dataField.setBackground(getBackground());
dataPanel.add(dataLabel);
dataPanel.add(dataField);
JPanel averagePanel = new JPanel();
// $NON-NLS-1$
JLabel averageLabel = new JLabel(JMeterUtils.getResString("graph_results_average"));
averageLabel.setForeground(Color.blue);
averageField = new JTextField(5);
averageField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
averageField.setEditable(false);
averageField.setForeground(Color.blue);
averageField.setBackground(getBackground());
averagePanel.add(averageLabel);
averagePanel.add(averageField);
JPanel deviationPanel = new JPanel();
// $NON-NLS-1$
JLabel deviationLabel = new JLabel(JMeterUtils.getResString("graph_results_deviation"));
deviationLabel.setForeground(Color.red);
deviationField = new JTextField(5);
deviationField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
deviationField.setEditable(false);
deviationField.setForeground(Color.red);
deviationField.setBackground(getBackground());
deviationPanel.add(deviationLabel);
deviationPanel.add(deviationField);
JPanel noSamplesPanel = new JPanel();
// $NON-NLS-1$
JLabel noSamplesLabel = new JLabel(JMeterUtils.getResString("graph_results_no_samples"));
noSamplesField = new JTextField(8);
noSamplesField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
noSamplesField.setEditable(false);
noSamplesField.setForeground(Color.black);
noSamplesField.setBackground(getBackground());
noSamplesPanel.add(noSamplesLabel);
noSamplesPanel.add(noSamplesField);
JPanel tableInfoPanel = new JPanel();
tableInfoPanel.setLayout(new FlowLayout());
tableInfoPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
tableInfoPanel.add(noSamplesPanel);
tableInfoPanel.add(dataPanel);
tableInfoPanel.add(averagePanel);
tableInfoPanel.add(deviationPanel);
JPanel tableControlsPanel = new JPanel(new BorderLayout());
tableControlsPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
JPanel jp = new HorizontalPanel();
jp.add(autoscroll);
jp.add(childSamples);
tableControlsPanel.add(jp, BorderLayout.WEST);
tableControlsPanel.add(tableInfoPanel, BorderLayout.CENTER);
// Set up the table with footer
JPanel tablePanel = new JPanel();
tablePanel.setLayout(new BorderLayout());
tablePanel.add(tableScrollPanel, BorderLayout.CENTER);
tablePanel.add(tableControlsPanel, BorderLayout.SOUTH);
// Add the main panel and the graph
this.add(mainPanel, BorderLayout.NORTH);
this.add(tablePanel, BorderLayout.CENTER);
new Timer(REFRESH_PERIOD, e -> collectNewSamples()).start();
}
use of javax.swing.Timer in project jabref by JabRef.
the class MainTableSelectionListener method updatePreview.
private void updatePreview(final BibEntry toShow, final boolean changedPreview, int repeats) {
if (workingOnPreview) {
if (repeats > 0) {
// We've already waited once. Give up on this selection.
return;
}
Timer t = new Timer(50, actionEvent -> updatePreview(toShow, changedPreview, 1));
t.setRepeats(false);
t.start();
return;
}
EventList<BibEntry> list = table.getSelected();
// Check if the entry to preview is still selected:
if ((list.size() != 1) || (list.get(0) != toShow)) {
return;
}
final BasePanelMode mode = panel.getMode();
workingOnPreview = true;
SwingUtilities.invokeLater(() -> {
preview.setEntry(toShow);
// If nothing was already shown, set the preview and move the separator:
if (changedPreview || (mode == BasePanelMode.SHOWING_NOTHING)) {
panel.showPreview(preview);
panel.adjustSplitter();
}
workingOnPreview = false;
});
}
use of javax.swing.Timer in project JMRI by JMRI.
the class Diesel3Sound method newTimer.
protected Timer newTimer(long time, boolean repeat, ActionListener al) {
// make sure the time is > zero
time = Math.max(1, time);
t = new Timer((int) time, al);
t.setInitialDelay((int) time);
t.setRepeats(repeat);
return (t);
}
Aggregations