本文整理匯總了Java中javax.swing.JPasswordField.setPreferredSize方法的典型用法代碼示例。如果您正苦於以下問題:Java JPasswordField.setPreferredSize方法的具體用法?Java JPasswordField.setPreferredSize怎麽用?Java JPasswordField.setPreferredSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JPasswordField
的用法示例。
在下文中一共展示了JPasswordField.setPreferredSize方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: DBMSConnectionWindow
import javax.swing.JPasswordField; //導入方法依賴的package包/類
public DBMSConnectionWindow(JFrame owner) {
super(owner);
dbmsList = new JComboBox<String>(DBMS_LIST);
hostname = new JTextField();
port = new JTextField();
username = new JTextField();
password = new JPasswordField();
nextButton = new JButton("✔ Next");
hostname.setText(DEFAULT_HOSTNAME);
port.setText(DEFAULT_PORT);
username.setText(DEFAULT_USERNAME);
password.setText(DEFAULT_PASSWORD);
dbmsList.setPreferredSize(new Dimension(TEXTFIELD_WIDTH, TEXTFIELD_HEIGHT));
hostname.setPreferredSize(new Dimension(TEXTFIELD_WIDTH, TEXTFIELD_HEIGHT));
port.setPreferredSize(new Dimension(TEXTFIELD_WIDTH, TEXTFIELD_HEIGHT));
username.setPreferredSize(new Dimension(TEXTFIELD_WIDTH, TEXTFIELD_HEIGHT));
password.setPreferredSize(new Dimension(TEXTFIELD_WIDTH, TEXTFIELD_HEIGHT));
JPanel mainContainer = new JPanel();
mainContainer.setLayout(new BoxLayout(mainContainer, BoxLayout.Y_AXIS));
mainContainer.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
JPanel dbmsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
dbmsPanel.add(new JLabel("DBMS: "));
dbmsPanel.add(dbmsList);
JPanel hostnamePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
hostnamePanel.add(new JLabel("Hostname: "));
hostnamePanel.add(hostname);
JPanel portPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
portPanel.add(new JLabel("Port: "));
portPanel.add(port);
JPanel usernamePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
usernamePanel.add(new JLabel("Username: "));
usernamePanel.add(username);
JPanel passwordPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
passwordPanel.add(new JLabel("Password: "));
passwordPanel.add(password);
JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
buttonsPanel.add(nextButton);
mainContainer.add(dbmsPanel);
mainContainer.add(hostnamePanel);
mainContainer.add(portPanel);
mainContainer.add(usernamePanel);
mainContainer.add(passwordPanel);
mainContainer.add(buttonsPanel);
add(mainContainer);
buildWindow();
pack();
}