本文整理匯總了Java中javax.swing.JOptionPane.getFrameForComponent方法的典型用法代碼示例。如果您正苦於以下問題:Java JOptionPane.getFrameForComponent方法的具體用法?Java JOptionPane.getFrameForComponent怎麽用?Java JOptionPane.getFrameForComponent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JOptionPane
的用法示例。
在下文中一共展示了JOptionPane.getFrameForComponent方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: NewPortfolioDialog
import javax.swing.JOptionPane; //導入方法依賴的package包/類
public NewPortfolioDialog(Component frameComp, Component locationComp,
String title) {
super(JOptionPane.getFrameForComponent(frameComp), title, true);
// Create and initialize the buttons.
cancelButton = new JButton(BUTTON_CANCEL);
cancelButton.addActionListener(this);
cancelButton.setActionCommand(BUTTON_CANCEL);
okButton = new JButton(BUTTON_OK);
okButton.setActionCommand(BUTTON_OK);
okButton.addActionListener(this);
getRootPane().setDefaultButton(okButton);
nameFieldLabel = new JLabel("Salkun nimi: ");
nameFieldLabel.setLabelFor(nameField);
JPanel textControlsPane = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.anchor = GridBagConstraints.EAST;
c.insets = new Insets(5, 5, 5, 5); // this statement added.
textControlsPane.add(nameFieldLabel,c);
textControlsPane.add(nameField,c);
// Lay out the buttons from left to right.
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
buttonPane.add(Box.createHorizontalGlue());
buttonPane.add(cancelButton);
buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
buttonPane.add(okButton);
// Put everything together, using the content pane's BorderLayout.
Container contentPane = getContentPane();
contentPane.add(textControlsPane, BorderLayout.CENTER);
contentPane.add(buttonPane, BorderLayout.PAGE_END);
pack();
setLocationRelativeTo(locationComp);
setVisible(true);
}
示例2: BaseDialog
import javax.swing.JOptionPane; //導入方法依賴的package包/類
/**
* Set up and show the dialog. The first Component argument determines which
* frame the dialog depends on; it should be a component in the dialog's
* controlling frame. The second Component argument should be null if you
* want the dialog to come up with its left corner in the center of the
* screen; otherwise, it should be the component on top of which the dialog
* should appear.
*/
public BaseDialog(Component frameComp, Component locationComp,
String title, I_TickerManager tickerManager) {
super(JOptionPane.getFrameForComponent(frameComp), title, true);
this.frameComp = frameComp;
dateChooser = new JDateChooser(Calendar.getInstance().getTime());
dateChooser.setLocale(new Locale("fi", "FI"));
this.tickerManager = tickerManager;
// Create and initialize the buttons.
cancelButton = new JButton(BUTTON_CANCEL);
cancelButton.addActionListener(this);
cancelButton.setActionCommand(BUTTON_CANCEL);
okButton = new JButton(BUTTON_OK);
okButton.setActionCommand(BUTTON_OK);
okButton.addActionListener(this);
getRootPane().setDefaultButton(okButton);
okButton.setEnabled(false);
rateField = new JTextField(FIELD_LEN);
rateField.setVisible(true);
rateField.setText("1.0000");
rateFieldLabel = new JLabel("Valuuttakurssi: ");
rateFieldLabel.setLabelFor(rateField);
rateFieldLabel.setVisible(true);
localCurrencyButton = new JRadioButton(localCurrencyString);
foreignCurrencyButton = new JRadioButton(foreignCurrencyString);
currencyGroup = new ButtonGroup();
localCurrencyButton.setActionCommand(localCurrencyString);
foreignCurrencyButton.setActionCommand(foreignCurrencyString);
localCurrencyButton.setSelected(true);
currencyGroup.add(localCurrencyButton);
currencyGroup.add(foreignCurrencyButton);
updateRateFieldCcy("EUR", false);
localCurrencyButton.addActionListener(this);
foreignCurrencyButton.addActionListener(this);
foreignCurrencyButton.setEnabled(false);
}
示例3: OpenPortfolioDialog
import javax.swing.JOptionPane; //導入方法依賴的package包/類
public OpenPortfolioDialog(Component frameComp, Component locationComp,
String title, Object[] portfolios) {
super(JOptionPane.getFrameForComponent(frameComp), title, true);
// Create and initialize the buttons.
cancelButton = new JButton(BUTTON_CANCEL);
cancelButton.addActionListener(this);
cancelButton.setActionCommand(BUTTON_CANCEL);
okButton = new JButton(BUTTON_OK);
okButton.setActionCommand(BUTTON_OK);
okButton.addActionListener(this);
getRootPane().setDefaultButton(okButton);
portfolioList = new JComboBox(portfolios);
portfolioFieldLabel = new JLabel("Salkun nimi: ");
portfolioFieldLabel.setLabelFor(portfolioList);
JPanel textControlsPane = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.anchor = GridBagConstraints.EAST;
c.insets = new Insets(10, 10, 10, 10); // this statement added.
textControlsPane.add(portfolioFieldLabel,c);
textControlsPane.add(portfolioList, c);
// Lay out the buttons from left to right.
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
buttonPane.add(Box.createHorizontalGlue());
buttonPane.add(cancelButton);
buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
buttonPane.add(okButton);
// Put everything together, using the content pane's BorderLayout.
Container contentPane = getContentPane();
contentPane.add(textControlsPane, BorderLayout.CENTER);
contentPane.add(buttonPane, BorderLayout.PAGE_END);
pack();
setLocationRelativeTo(locationComp);
setVisible(true);
}