use of java.awt.Label in project yyl_example by Relucent.
the class SoundBeep method main.
public static void main(String[] args) {
JFrame jFrame = new JFrame("单击按钮事件");
jFrame.setSize(new Dimension(200, 180));
JPanel jPanel = new JPanel();
// 将面板P添加到窗口f中
jFrame.add(jPanel);
jPanel.add(new Label("按一下按钮可听到响声!", Label.CENTER));
Button button = new Button("按钮");
jPanel.add(button);
// 创建事件监听器对象
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Toolkit.getDefaultToolkit().beep();
}
});
// 注册事件监听器对象
jFrame.setVisible(true);
}
use of java.awt.Label in project lwjgl by LWJGL.
the class DemoBox method initialize.
/**
* @return
*/
public boolean initialize() {
setTitle("LWJGL - Demo Box");
setSize(640, 480);
setLayout(new GridBagLayout());
// Setup selection panel
// =================================
selectionPanel = new Panel();
selectionPanel.setLayout(new BorderLayout());
selectionPanel.add(new Label("Demo", Label.CENTER), BorderLayout.NORTH);
Button fullScreen = new Button("Fullscreen");
fullScreen.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
toggleFullscreen();
}
});
selectionPanel.add(fullScreen, BorderLayout.SOUTH);
final List demos = new List();
for (Enumeration e = selectableDemos.keys(); e.hasMoreElements(); ) {
demos.add(e.nextElement().toString());
}
selectionPanel.add(demos, BorderLayout.CENTER);
demos.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent event) {
demoSelected(event.getItemSelectable().getSelectedObjects()[0].toString());
}
});
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.weightx = 0.05;
gbc.weighty = 1.0;
add(selectionPanel, gbc);
// =================================
try {
demoCanvas = new DemoBoxGLCanvas(this);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.weightx = 0.95;
gbc.weighty = 1.0;
add(demoCanvas, gbc);
} catch (LWJGLException le) {
le.printStackTrace();
return false;
}
// ---------------------------------
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
demoCanvas.destroyCanvas();
dispose();
System.exit(0);
}
});
// demoSelected(demos.getSelectedItem());
return true;
}
use of java.awt.Label in project jadx by skylot.
the class ExcludePkgDialog method initUI.
private void initUI() {
setTitle(NLS.str("exclude_dialog.title"));
tree = new JTree();
tree.setRowHeight(-1);
treeRoot = new DefaultMutableTreeNode("Packages");
DefaultTreeModel treeModel = new DefaultTreeModel(treeRoot);
tree.setModel(treeModel);
tree.setCellRenderer(new PkgListCellRenderer());
JScrollPane listPanel = new JScrollPane(tree);
listPanel.setBorder(BorderFactory.createLineBorder(Color.black));
tree.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
TreePath path = tree.getPathForLocation(e.getX(), e.getY());
if (path != null) {
PkgNode node = (PkgNode) path.getLastPathComponent();
node.toggle();
repaint();
}
}
});
JPanel actionPanel = new JPanel();
BoxLayout boxLayout = new BoxLayout(actionPanel, BoxLayout.LINE_AXIS);
actionPanel.setLayout(boxLayout);
actionPanel.add(new Label(" "));
JButton btnOk = new JButton(NLS.str("exclude_dialog.ok"));
JButton btnAll = new JButton(NLS.str("exclude_dialog.select_all"));
JButton btnInvert = new JButton(NLS.str("exclude_dialog.invert"));
JButton btnDeselect = new JButton(NLS.str("exclude_dialog.deselect"));
actionPanel.add(btnDeselect);
actionPanel.add(btnInvert);
actionPanel.add(btnAll);
actionPanel.add(new Label(" "));
actionPanel.add(btnOk);
JPanel mainPane = new JPanel(new BorderLayout(5, 5));
mainPane.add(listPanel, BorderLayout.CENTER);
mainPane.add(actionPanel, BorderLayout.SOUTH);
mainPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
getContentPane().add(mainPane);
pack();
setSize(600, 700);
setLocationRelativeTo(null);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setModalityType(ModalityType.MODELESS);
btnOk.addActionListener(e -> {
mainWindow.getWrapper().setExcludedPackages(getExcludes());
mainWindow.reOpenFile();
dispose();
});
btnAll.addActionListener(e -> {
roots.forEach(p -> p.setSelected(true));
tree.updateUI();
});
btnDeselect.addActionListener(e -> {
roots.forEach(p -> p.setSelected(false));
tree.updateUI();
});
btnInvert.addActionListener(e -> {
roots.forEach(PkgNode::toggle);
tree.updateUI();
});
}
use of java.awt.Label in project jadx by skylot.
the class JDebuggerPanel method initToolBar.
private JToolBar initToolBar() {
AbstractAction stepOver = new AbstractAction(NLS.str("debugger.step_over"), ICON_STEP_OVER) {
private static final long serialVersionUID = -1111111202103170726L;
@Override
public void actionPerformed(ActionEvent e) {
controller.stepOver();
}
};
stepOver.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.step_over"));
AbstractAction stepInto = new AbstractAction(NLS.str("debugger.step_into"), ICON_STEP_INTO) {
private static final long serialVersionUID = -1111111202103170727L;
@Override
public void actionPerformed(ActionEvent e) {
controller.stepInto();
}
};
stepInto.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.step_into"));
AbstractAction stepOut = new AbstractAction(NLS.str("debugger.step_out"), ICON_STEP_OUT) {
private static final long serialVersionUID = -1111111202103170728L;
@Override
public void actionPerformed(ActionEvent e) {
controller.stepOut();
}
};
stepOut.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.step_out"));
AbstractAction stop = new AbstractAction(NLS.str("debugger.stop"), ICON_STOP_GRAY) {
private static final long serialVersionUID = -1111111202103170728L;
@Override
public void actionPerformed(ActionEvent e) {
controller.stop();
}
};
stop.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.stop"));
AbstractAction run = new AbstractAction(NLS.str("debugger.run"), ICON_RUN) {
private static final long serialVersionUID = -1111111202103170728L;
@Override
public void actionPerformed(ActionEvent e) {
if (controller.isDebugging()) {
if (controller.isSuspended()) {
controller.run();
} else {
controller.pause();
}
}
}
};
run.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.run"));
AbstractAction rerun = new AbstractAction(NLS.str("debugger.rerun"), ICON_RERUN) {
private static final long serialVersionUID = -1111111202103210433L;
@Override
public void actionPerformed(ActionEvent e) {
if (controller.isDebugging()) {
controller.stop();
}
String pkgName = controller.getProcessName();
if (pkgName.isEmpty() || !ADBDialog.launchForDebugging(mainWindow, pkgName, true)) {
(new ADBDialog(mainWindow)).setVisible(true);
}
}
};
rerun.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.rerun"));
controller.setStateListener(new DebugController.StateListener() {
boolean isGray = true;
@Override
public void onStateChanged(boolean suspended, boolean stopped) {
if (!stopped) {
if (isGray) {
stop.putValue(Action.SMALL_ICON, ICON_STOP);
}
} else {
stop.putValue(Action.SMALL_ICON, ICON_STOP_GRAY);
run.putValue(Action.SMALL_ICON, ICON_RUN);
run.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.run"));
isGray = true;
return;
}
if (suspended) {
run.putValue(Action.SMALL_ICON, ICON_RUN);
run.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.run"));
} else {
run.putValue(Action.SMALL_ICON, ICON_PAUSE);
run.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.pause"));
}
}
});
JToolBar toolBar = new JToolBar();
toolBar.add(new Label());
toolBar.add(Box.createHorizontalGlue());
toolBar.add(rerun);
toolBar.add(Box.createRigidArea(new Dimension(5, 0)));
toolBar.add(stop);
toolBar.add(Box.createRigidArea(new Dimension(5, 0)));
toolBar.add(run);
toolBar.add(Box.createRigidArea(new Dimension(5, 0)));
toolBar.add(stepOver);
toolBar.add(Box.createRigidArea(new Dimension(5, 0)));
toolBar.add(stepInto);
toolBar.add(Box.createRigidArea(new Dimension(5, 0)));
toolBar.add(stepOut);
toolBar.add(Box.createHorizontalGlue());
toolBar.add(new Label());
regShortcuts();
return toolBar;
}
use of java.awt.Label in project GDSC-SMLM by aherbert.
the class SpotAnalysis method createFrame.
@SuppressWarnings({ "rawtypes", "unchecked" })
private void createFrame() {
final 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, "", ""));
final JPanel buttonPanel = new JPanel();
final 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);
final JScrollPane scrollPane = new JScrollPane(onFramesList);
mainPanel.add(scrollPane);
final GridBagLayout mainGrid = new GridBagLayout();
int y = 0;
final 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 (final Component comp : mainPanel.getComponents()) {
c.gridy = y++;
mainGrid.setConstraints(comp, c);
}
mainPanel.setLayout(mainGrid);
}
Aggregations