下面列出了javax.swing.JDialog#setLayout ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
protected JDialog initDialog(Window owner, Object constraints) {
JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
ret.setLayout(new BorderLayout());
ret.setResizable(false);
ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
ret.setTitle(Messages.get("encrypBackMany.action"));
ret.add(pnl, BorderLayout.CENTER);
ret.pack();
UiUtils.centerWindow(ret, owner);
{
// DIRTY-HACK: YES, FOLLOWING 2 LINES ARE REPEATED BY INTENTION,
// OTHERWISE JXlABEL IS NOT
// RETURNING CORRECT PREFERRED SIZE AND WHOLE LAYOUT IS SCREWED UP
// THE ONLY WAY TO FORCE IT IS TO CENTER WINDOW. SO ONCE WE DID
// FIRST TIME NOW WE CAN PACK AND CENTER AGAIN
ret.pack();
UiUtils.centerWindow(ret, owner);
}
return ret;
}
private void borderWizardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_borderWizardActionPerformed
ImageBorderWizardTabbedPane iw = new ImageBorderWizardTabbedPane(resources, themeName);
JDialog dlg = new JDialog(SwingUtilities.windowForComponent(this), "Border Wizard");
dlg.setLayout(new java.awt.BorderLayout());
dlg.add(java.awt.BorderLayout.CENTER, iw);
dlg.pack();
dlg.setLocationRelativeTo(this);
dlg.setModal(true);
dlg.setVisible(true);
themeHash = resources.getTheme(themeName);
initTableModel(theme, null);
initTableModel(selectedStyles, "sel#");
initTableModel(pressedStyles, "press#");
initTableModel(disabledStyles, "dis#");
refreshTheme(themeHash);
}
private void imageBorderWizardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_imageBorderWizardActionPerformed
deriveBorder.setSelected(false);
ImageBorderWizardTabbedPane iw = new ImageBorderWizardTabbedPane(resources, themeName);
String name = (String)componentName.getSelectedItem();
String uiid;
if(prefix == null || prefix.length() == 0) {
uiid = name + ".border";
} else {
uiid = name + "." + prefix + "border";
}
iw.addToAppliesToList(uiid);
JDialog dlg = new JDialog(SwingUtilities.windowForComponent(this));
dlg.setLayout(new java.awt.BorderLayout());
dlg.add(java.awt.BorderLayout.CENTER, iw);
dlg.pack();
dlg.setLocationRelativeTo(this);
dlg.setModal(true);
dlg.setVisible(true);
Border b = (Border)resources.getTheme(themeName).get(uiid);
if(b != null) {
currentBorder = b;
((CodenameOneComponentWrapper)borderLabel).getCodenameOneComponent().getStyle().setBorder(b);
borderLabel.repaint();
}
}
public static JDialog getCenterDialog(int width, int height,
JComponent panel, JButton okButton) {
JDialog dialog = new JDialog();
dialog.setLayout(new MigLayout("wrap 1", "[100%]"));
dialog.add(panel, "width 100%, height 90%, grow");
if ( okButton != null ) {
dialog.add(okButton, "align center");
}
dialog.setSize(width, height);
Point cpoint = WindowUtils.getPointForCentering(dialog);
dialog.setLocation(cpoint);
dialog.setModal(true);
return dialog;
}
@Override
protected JDialog initDialog(Window owner, Object constraints) {
JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
ret.setLayout(new BorderLayout());
ret.setResizable(true);
ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
ret.setTitle(Messages.get("action.importKey"));
ret.add(pnl, BorderLayout.CENTER);
ret.setMinimumSize(new Dimension(spacing(60), spacing(30)));
initWindowGeometryPersister(ret, "keyImprt");
return ret;
}
@Override
protected JDialog initDialog(Window owner, Object constraints) {
JDialog ret = new JDialog(owner, ModalityType.MODELESS);
ret.setLayout(new BorderLayout());
ret.setResizable(true);
ret.setMinimumSize(new Dimension(UiUtils.getFontRelativeSize(80), UiUtils.getFontRelativeSize(40)));
ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
ret.setTitle(Messages.get("action.encryptText"));
ret.add(pnl, BorderLayout.CENTER);
initWindowGeometryPersister(ret, "encrText");
return ret;
}
@Override
protected JDialog initDialog(Window owner, Object constraints) {
JDialog ret = new JDialog(owner, ModalityType.MODELESS);
ret.setLayout(new BorderLayout());
ret.setResizable(false);
ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
ret.setTitle(Messages.get("action.decrypt"));
ret.add(pnl, BorderLayout.CENTER);
ret.pack();
UiUtils.centerWindow(ret, owner);
return ret;
}
@Override
protected JDialog initDialog(Window owner, Object constraints) {
JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
ret.setLayout(new BorderLayout());
ret.setResizable(false);
ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
ret.setTitle(text("action.checkForUpdates"));
ret.add(pnl, BorderLayout.CENTER);
ret.pack();
UiUtils.centerWindow(ret, owner);
return ret;
}
@Override
protected JDialog initDialog(Window owner, Object constraints) {
JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
ret.setLayout(new BorderLayout());
ret.setResizable(false);
ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
ret.setTitle(Messages.get("term.aboutApp"));
ret.add(pnl, BorderLayout.CENTER);
ret.pack();
return ret;
}
@Override
protected JDialog initDialog(Window owner, Object constraints) {
JDialog ret = new JDialog(owner, ModalityType.DOCUMENT_MODAL);
ret.setLayout(new BorderLayout());
ret.setResizable(false);
ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
ret.setTitle(Messages.get("action.providePasswordForAKey"));
ret.add(pnl, BorderLayout.CENTER);
ret.pack();
UiUtils.centerWindow(ret, owner);
return ret;
}
@Override
protected JDialog initDialog(Window owner, Object constraints) {
JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
ret.setMinimumSize(new Dimension(spacing(50), spacing(25)));
ret.setLayout(new BorderLayout());
ret.setResizable(true);
ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
ret.setTitle(Messages.get("term.keysList"));
ret.add(panelRoot, BorderLayout.CENTER);
ret.setJMenuBar(menuBar);
initWindowGeometryPersister(ret, "keysList");
return ret;
}
@Override
protected JDialog initDialog(Window owner, Object constraints) {
JDialog ret = new JDialog(owner, ModalityType.MODELESS);
ret.setLayout(new BorderLayout());
ret.setResizable(true);
ret.setMinimumSize(new Dimension(UiUtils.getFontRelativeSize(80), UiUtils.getFontRelativeSize(40)));
ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
ret.setTitle(Messages.get("action.decryptText"));
ret.add(pnl, BorderLayout.CENTER);
initWindowGeometryPersister(ret, "decrText");
return ret;
}
@Override
protected JDialog initDialog(Window owner, Object constraints) {
JDialog ret = new JDialog(owner, ModalityType.MODELESS);
ret.setLayout(new BorderLayout());
ret.setResizable(true);
ret.setMinimumSize(new Dimension(UiUtils.getFontRelativeSize(50), UiUtils.getFontRelativeSize(40)));
ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
ret.setTitle(Messages.get("action.encrypt"));
ret.add(pnl, BorderLayout.CENTER);
initWindowGeometryPersister(ret, "encrOne");
return ret;
}
@Override
public void onSetupGUI() {
Component top = makeTopPanel();
Component center = makeCenterPanel();
Component bottom = makeBottomPanel();
d = new JDialog(getOwner());
d.setLayout(new BorderLayout());
d.add(top, BorderLayout.NORTH);
d.add(center, BorderLayout.CENTER);
d.add(bottom, BorderLayout.SOUTH);
ConfigManager preferencesManager = getUser().getPreferencesManager();
final int width = preferencesManager.getIntegerValue(KEY_POPUP_WIDTH, DEFAULT_POPUP_WIDTH);
final int height = preferencesManager.getIntegerValue(KEY_POPUP_HEIGHT, DEFAULT_POPUP_HEIGHT);
addListeners();
d.repaint();
d.pack();
d.setSize(width, height);
d.setLocationRelativeTo(null);
d.setResizable(false);
setDialog(d);
setupChooser();
}
@Override
public void onSetupGUI() {
d = new JDialog(getOwner(), getString(KEY_TITLE));
d.setTitle(getString(KEY_TITLE));
d.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1.0;
c.weighty = 0.0;
c.gridx = 1;
c.gridy = 1;
c.gridwidth = 1;
c.gridheight = 1;
d.add(makeUpperPanel(), c);
c.gridy += 1;
c.fill = GridBagConstraints.BOTH;
c.weighty = 1.0;
d.add(makeCenterPanel(), c);
c.gridy += 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.weighty = 0.0;
d.add(makeBottomPanel(), c);
ConfigManager preferencesManager = getUser().getPreferencesManager();
int defaultWidth = preferencesManager.getIntegerValue(KEY_POPUP_WIDTH, DEFAULT_POPUP_WIDTH);
int defaultHeight = preferencesManager.getIntegerValue(KEY_POPUP_HEIGHT, DEFAULT_POPUP_HEIGHT);
int width = preferencesManager.getIntegerValue(KEY_EDIT_ROSTER_WIDTH, defaultWidth);
int height = preferencesManager.getIntegerValue(KEY_EDIT_ROSTER_HEIGHT, defaultHeight);
d.repaint();
d.pack();
d.setMinimumSize(new Dimension(getMinimumWidth(), DEFAULT_POPUP_HEIGHT));
d.setSize(new Dimension(width, height));
d.setLocationRelativeTo(null);
d.setResizable(true);
addActionListeners();
setDialog(d);
getUser().addObserver(this);
}
private void showStatusMessage(ContactItem item)
{
Frame = new JDialog();
Frame.setTitle(item.getDisplayName() + " - Status");
JPanel pane = new JPanel();
JTextArea textArea = new JTextArea(5, 30);
JButton btn_close = new JButton(Res.getString("button.close"));
btn_close.addActionListener( e -> Frame.setVisible(false) );
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
pane.add(new JScrollPane(textArea));
Frame.setLayout(new BorderLayout());
Frame.add(pane, BorderLayout.CENTER);
Frame.add(btn_close, BorderLayout.SOUTH);
textArea.setEditable(false);
textArea.setText(item.getStatus());
Frame.setLocationRelativeTo(SparkManager.getMainWindow());
Frame.setBounds(Frame.getX() - 175, Frame.getY() - 75, 350, 150);
Frame.setSize(350, 150);
Frame.setResizable(false);
Frame.setVisible(true);
}
private void settingsDetailsButtonActionPerformed() {
final JDialog dialog = new JDialog(this, "Pro AI - Settings Details");
String message = "";
if (tabPaneMain.getSelectedIndex() == 0) { // Debugging
message =
"Debugging\r\n"
+ "\r\n"
+ "AI Logging: When this is checked, the AI's will output their logs, as they come "
+ "in, so you can see exactly what the AI is thinking.\r\n"
+ "Note that if you check this on, you still have to press OK then reopen the "
+ "settings window for the logs to actually start displaying.\r\n"
+ "\r\n"
+ "Log Depth: This setting lets you choose how deep you want the AI logging to be. "
+ "Fine only displays the high-level events, like the start of a phase, etc.\r\n"
+ "Finer displays medium-level events, such as attacks, reinforcements, etc.\r\n"
+ "Finest displays all the AI logging available. Can be used for detailed analysis, "
+ "but is a lot harder to read through it.\r\n"
+ "\r\n"
+ "Pause AI's: This checkbox pauses all the AI's while it's checked, so you can look "
+ "at the logs without the AI's outputting floods of information.\r\n"
+ "\r\n"
+ "Limit Log History To X Rounds: If this is checked, the AI log information will "
+ "be limited to X rounds of information.\r\n";
}
final JTextArea label = new JTextArea(message);
label.setFont(new Font("Segoe UI", Font.PLAIN, 12));
label.setEditable(false);
label.setAutoscrolls(true);
label.setLineWrap(false);
label.setFocusable(false);
label.setWrapStyleWord(true);
label.setLocation(0, 0);
dialog.setBackground(label.getBackground());
dialog.setLayout(new BorderLayout());
final JScrollPane pane = new JScrollPane();
pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
pane.setViewportView(label);
dialog.add(pane, BorderLayout.CENTER);
final JButton button = new JButton("Close");
button.setMinimumSize(new Dimension(100, 30));
button.addActionListener(e -> dialog.dispose());
dialog.add(button, BorderLayout.SOUTH);
dialog.setMinimumSize(new Dimension(500, 300));
dialog.setSize(new Dimension(800, 600));
dialog.setResizable(true);
dialog.setLocationRelativeTo(this);
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
}
private void setupHelp()
{
final String helpTitle = "Chat Game Fontificator Help";
help = new JDialog(this, true);
help.setTitle(helpTitle);
help.setSize(640, 480);
help.setLayout(new GridBagLayout());
JEditorPane helpPane = new JEditorPane();
helpPane.setContentType("text/html");
helpPane.setText(helpText);
helpPane.setEditable(false);
JScrollPane scrollHelp = new JScrollPane(helpPane, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
JButton ok = new JButton("Close");
ok.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
help.setVisible(false);
}
});
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.weighty = 0.0;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.NORTH;
help.add(new JLabel("The function of each option available in the Control Window tabs is explained below"), gbc);
gbc.fill = GridBagConstraints.BOTH;
gbc.anchor = GridBagConstraints.CENTER;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.gridy = 1;
help.add(scrollHelp, gbc);
gbc.gridy++;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.SOUTH;
gbc.weighty = 0.0;
help.add(ok, gbc);
help.setResizable(false);
}
@Override
public void onSetupGUI() {
d = new JDialog(getOwner(), getString(KEY_TITLE));
d.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1.0;
c.weighty = 0.0;
c.gridx = 1;
c.gridy = 1;
c.gridwidth = 2;
c.gridheight = 1;
d.add(makeUpperPanel(), c);
c.gridy += 1;
c.fill = GridBagConstraints.BOTH;
c.weighty = 1.0;
c.gridwidth = 1;
d.add(makeRosterPanel(), c);
c.gridx += 1;
c.weightx = 0.0;
d.add(makeTeamPanel(), c);
c.weightx = 1.0;
c.gridx = 1;
c.gridy += 1;
c.gridwidth = 2;
c.fill = GridBagConstraints.HORIZONTAL;
c.weighty = 0.0;
d.add(makeBottomPanel(), c);
ConfigManager preferencesManager = getUser().getPreferencesManager();
int defaultWidth = preferencesManager.getIntegerValue(KEY_POPUP_WIDTH, DEFAULT_POPUP_WIDTH);
int defaultHeight = preferencesManager.getIntegerValue(KEY_POPUP_HEIGHT, DEFAULT_POPUP_HEIGHT);
int width = preferencesManager.getIntegerValue(KEY_EDIT_TEAM_WIDTH, defaultWidth);
int height = preferencesManager.getIntegerValue(KEY_EDIT_TEAM_HEIGHT, defaultHeight);
d.repaint();
d.pack();
d.setMinimumSize(new Dimension(getMinimumWidth(), DEFAULT_POPUP_HEIGHT));
d.setSize(new Dimension(width, height));
d.setLocationRelativeTo(null);
d.setResizable(true);
addActionListeners();
setDialog(d);
}
@Override
public void onSetupGUI() {
d = new JDialog(getOwner());
d.setLayout(new GridBagLayout());
d.setTitle(getString(KEY_TITLE));
shuffleMenuBar = new ShuffleMenuBar(getUser(), getOwner());
d.setJMenuBar(shuffleMenuBar);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.CENTER;
c.weightx = 1.0;
c.weighty = 1.0;
c.gridy = 1;
// Display row
c.weighty = 1.0;
c.gridwidth = 4;
c.gridx = 1;
c.gridy++;
c.gridx++;
results = new ArrayList<SimulationResult>();
resultsMap = new HashMap<SimulationResult, Integer>();
model2 = new DefaultTableModel(getColumnNames(), 0) {
private static final long serialVersionUID = 5180830497930828902L;
@Override
public boolean isCellEditable(int row, int col) {
return false;
}
};
table = new JTable(model2);
loadOrderFor(table, getUser().getPreferencesManager().getStringValue(KEY_COLUMN_ORDER));
resizeColumnWidth(table);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
listener2 = new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
pushSelectionToUser2();
}
};
table.getSelectionModel().addListSelectionListener(listener2);
JScrollPane jsp = new JScrollPane(table);
d.add(jsp, c);
// Control row
c.weighty = 0.0;
c.gridwidth = 1;
c.gridx = 1;
c.gridy++;
c.gridx++;
metricLabel = new JLabel(getString(KEY_METRIC_LABEL));
metricLabel.setHorizontalAlignment(SwingConstants.CENTER);
metricLabel.setHorizontalTextPosition(SwingConstants.CENTER);
metricLabel.setToolTipText(getString(KEY_METRIC_TOOLTIP));
d.add(metricLabel, c);
c.gridx++;
ind = new GradingModeIndicator(getUser());
ind.setToolTipText(getString(KEY_METRIC_TOOLTIP));
d.add(ind, c);
c.gridx++;
doMoveButton = new JButton(new AbstractAction(getString(KEY_DO_NOW)) {
private static final long serialVersionUID = -8952138130413953491L;
@Override
public void actionPerformed(ActionEvent arg0) {
doMovePressed();
}
});
doMoveButton.setToolTipText(getString(KEY_DO_TOOLTIP));
d.add(doMoveButton, c);
setDefaultButton(doMoveButton);
c.gridx++;
closeButton = new JButton(new DisposeAction(getString(KEY_CLOSE), this));
closeButton.setToolTipText(getString(KEY_CLOSE_TOOLTIP));
d.add(closeButton, c);
d.pack();
ConfigManager preferencesManager = getUser().getPreferencesManager();
final int width = preferencesManager.getIntegerValue(KEY_CHOOSER_WIDTH, DEFAULT_CHOOSER_WIDTH);
final int height = preferencesManager.getIntegerValue(KEY_CHOOSER_HEIGHT, DEFAULT_CHOOSER_HEIGHT);
d.setSize(width, height);
d.repaint();
Integer x = preferencesManager.getIntegerValue(KEY_CHOOSER_X);
Integer y = preferencesManager.getIntegerValue(KEY_CHOOSER_Y);
if (x != null && y != null) {
d.setLocation(x, y);
} else {
d.setLocationRelativeTo(null);
}
d.setMinimumSize(MIN_SIZE);
d.setResizable(preferencesManager.getBooleanValue(KEY_CHOOSER_RESIZE, DEFAULT_RESIZE));
getUser().addObserver(this);
setDialog(d);
}