use of java.awt.Panel in project JSettlers2 by jdmonin.
the class SOCConnectOrPracticePanel method initInterface_conn.
/**
* panel_conn setup
*/
private Panel initInterface_conn() {
Panel pconn = new Panel();
Label L;
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
pconn.setLayout(gbl);
gbc.fill = GridBagConstraints.BOTH;
// heading row
// "Connect to Server"
L = new Label(strings.get("pcli.cpp.connecttoserv"));
L.setAlignment(Label.CENTER);
L.setBackground(HEADER_LABEL_BG);
L.setForeground(HEADER_LABEL_FG);
gbc.gridwidth = 4;
gbl.setConstraints(L, gbc);
pconn.add(L);
// Spacing for rest of form's rows
L = new Label(" ");
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbl.setConstraints(L, gbc);
pconn.add(L);
// blank row
L = new Label();
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbl.setConstraints(L, gbc);
pconn.add(L);
L = new Label(strings.get("pcli.cpp.server"));
gbc.gridwidth = 1;
gbl.setConstraints(L, gbc);
pconn.add(L);
conn_servhost = new TextField(20);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbl.setConstraints(conn_servhost, gbc);
// for ESC/ENTER
conn_servhost.addKeyListener(this);
pconn.add(conn_servhost);
L = new Label(strings.get("pcli.cpp.port"));
gbc.gridwidth = 1;
gbl.setConstraints(L, gbc);
pconn.add(L);
conn_servport = new TextField(20);
{
String svp = Integer.toString(clientNetwork.getPort());
conn_servport.setText(svp);
conn_servport.setSelectionStart(0);
conn_servport.setSelectionEnd(svp.length());
}
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbl.setConstraints(conn_servport, gbc);
// for ESC/ENTER
conn_servport.addKeyListener(this);
pconn.add(conn_servport);
L = new Label(strings.get("pcli.cpp.nickname"));
gbc.gridwidth = 1;
gbl.setConstraints(L, gbc);
pconn.add(L);
conn_user = new TextField(20);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbl.setConstraints(conn_user, gbc);
conn_user.addKeyListener(this);
pconn.add(conn_user);
L = new Label(strings.get("pcli.cpp.password"));
gbc.gridwidth = 1;
gbl.setConstraints(L, gbc);
pconn.add(L);
conn_pass = new TextField(20);
if (SOCPlayerClient.isJavaOnOSX)
// round bullet (option-8)
conn_pass.setEchoChar('\u2022');
else
conn_pass.setEchoChar('*');
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbl.setConstraints(conn_pass, gbc);
conn_pass.addKeyListener(this);
pconn.add(conn_pass);
L = new Label(" ");
gbc.gridwidth = 1;
gbl.setConstraints(L, gbc);
pconn.add(L);
conn_connect = new Button(strings.get("pcli.cpp.connect"));
conn_connect.addActionListener(this);
// for win32 keyboard-focus
conn_connect.addKeyListener(this);
gbl.setConstraints(conn_connect, gbc);
pconn.add(conn_connect);
conn_cancel = new Button(strings.get("base.cancel"));
conn_cancel.addActionListener(this);
conn_cancel.addKeyListener(this);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbl.setConstraints(conn_cancel, gbc);
pconn.add(conn_cancel);
return pconn;
}
use of java.awt.Panel in project GDSC-SMLM by aherbert.
the class SpotAnalysis method createTextPanel.
private static Panel createTextPanel(TextField textField, String label, String value) {
final Panel panel = new Panel();
panel.setLayout(new BorderLayout());
final Label listLabel = new Label(label, 0);
textField.setText(value);
panel.add(listLabel, BorderLayout.WEST);
panel.add(textField, BorderLayout.CENTER);
return panel;
}
use of java.awt.Panel in project GDSC-SMLM by aherbert.
the class ResultsManager method addInputSourceToDialog.
/**
* Add a list of input sources to the generic dialog. The choice field will be named inputName. If
* the file input option is true then a field will be added name 'Input_file'.
*
* @param gd the dialog
* @param inputName the input name
* @param inputOption The option to select by default
* @param source the source
* @param filename the filename
*/
private static void addInputSourceToDialog(final ExtendedGenericDialog gd, String inputName, String inputOption, Set<String> source, String filename) {
final String[] options = source.toArray(new String[0]);
// Find the option
inputOption = removeFormatting(inputOption);
int optionIndex = 0;
for (int i = 0; i < options.length; i++) {
final String name = removeFormatting(options[i]);
if (name.equals(inputOption)) {
optionIndex = i;
break;
}
}
final Choice choice = gd.addAndGetChoice(inputName, options, options[optionIndex]);
if (filename != null) {
gd.addFilenameField("Input_file", filename);
// This could be a user configured option in a global GDSC settings class.
if (ImageJUtils.isShowGenericDialog()) {
final Label l = gd.getLastLabel();
final Panel p = gd.getLastPanel();
final ItemListener listener = event -> {
final boolean enable = INPUT_FILE.equals(choice.getSelectedItem());
if (enable != l.isVisible()) {
l.setVisible(enable);
p.setVisible(enable);
gd.pack();
}
};
// Run once to set up
listener.itemStateChanged(null);
choice.addItemListener(listener);
}
}
}
use of java.awt.Panel in project GDSC-SMLM by aherbert.
the class PeakFit method addRelativeParameterOptions.
/**
* Adds the relative parameter options.
*
* @param gd the dialog
* @param rp the relative parameter
*/
static void addRelativeParameterOptions(final ExtendedGenericDialog gd, final RelativeParameterProvider rp) {
final String label = rp.getDialogName();
gd.addSlider(label, rp.getMin(), rp.getMax(), rp.getValue(), new OptionListener<Double>() {
@Override
public boolean collectOptions(Double value) {
// Nothing depends on the input double value so just collect the options
return collectOptions(false);
}
@Override
public boolean collectOptions() {
return collectOptions(true);
}
private boolean collectOptions(boolean silent) {
final ExtendedGenericDialog egd = new ExtendedGenericDialog(rp.name + " Options", null);
final boolean oldValue = rp.isAbsolute();
egd.addCheckbox(rp.getDialogName() + "_absolute", oldValue);
egd.setSilent(silent);
egd.showDialog(true, gd);
if (egd.wasCanceled()) {
return false;
}
final boolean newValue = egd.getNextBoolean();
rp.setAbsolute(newValue);
return oldValue != newValue;
}
});
// Add a label after the button.
// The button is added in a panel with a GridBagLayout.
final Panel p = gd.getLastPanel();
final GridBagConstraints pc = new GridBagConstraints();
pc.gridy = 0;
pc.gridx = 3;
pc.insets = new Insets(5, 5, 0, 0);
pc.anchor = GridBagConstraints.EAST;
final Label flagLabel = new Label();
updateFlag(flagLabel, rp.isAbsolute());
p.add(flagLabel, pc);
gd.addOptionCollectedListener(event -> {
if (label.equals(event.getLabel())) {
updateFlag(flagLabel, rp.isAbsolute());
}
});
}
use of java.awt.Panel in project GT by Tencent.
the class PMAPView method createChartPanel.
/**
* 生成饼图
* @param parent
* @param data
*/
private void createChartPanel(Composite parent, Map<String, Integer> data) {
Composite composite = new Composite(parent, SWT.NO_BACKGROUND | SWT.EMBEDDED);
Frame frame = SWT_AWT.new_Frame(composite);
// 据说加入这个Panel可以无闪烁
Panel panel = new Panel(new BorderLayout()) {
private static final long serialVersionUID = 1L;
public void update(java.awt.Graphics g) {
/* Do not erase the background */
paint(g);
}
};
frame.add(panel);
JRootPane root = new JRootPane();
panel.add(root);
java.awt.Container contentPane = root.getContentPane();
PieChart chart = new PieChart();
int showItemNum = 0;
try {
showItemNum = Integer.parseInt(showDataItemCountText.getText());
} catch (NumberFormatException e) {
e.printStackTrace();
showItemNum = 10;
}
chart.setDataset(getPieChartDataFromMap(data, showItemNum));
contentPane.add(chart);
}
Aggregations