当前位置: 首页>>代码示例>>Java>>正文


Java JOptionPane.getFrameForComponent方法代码示例

本文整理汇总了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);
}
 
开发者ID:skarna1,项目名称:javaportfolio,代码行数:44,代码来源:NewPortfolioDialog.java

示例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);
	
}
 
开发者ID:skarna1,项目名称:javaportfolio,代码行数:53,代码来源:BaseDialog.java

示例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);
}
 
开发者ID:skarna1,项目名称:javaportfolio,代码行数:45,代码来源:OpenPortfolioDialog.java


注:本文中的javax.swing.JOptionPane.getFrameForComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。