use of javax.swing.border.EtchedBorder in project keystore-explorer by kaikramer.
the class DDateTimeChooser method initComponents.
private void initComponents(Date date) {
jcbMonth = new JComboBox<Object>(MONTH_NAMES);
jcbMonth.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent evt) {
update();
}
});
jsYear = new JSpinner(new SpinnerListModel(YEARS));
jsYear.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent evt) {
update();
}
});
jlDaysOfMonth = new JLabel[7][7];
for (int i = 0; i < 7; i++) {
jlDaysOfMonth[0][i] = new JLabel(DAY_NAMES[i], SwingConstants.RIGHT);
jlDaysOfMonth[0][i].setOpaque(true);
jlDaysOfMonth[0][i].setForeground(WEEK_DAY_FOREGROUND);
jlDaysOfMonth[0][i].setBackground(WEEK_DAY_BACKGROUND);
jlDaysOfMonth[0][i].setBorder(new EmptyBorder(0, 0, 0, 3));
}
for (int i = 1; i < 7; i++) {
for (int j = 0; j < 7; j++) {
jlDaysOfMonth[i][j] = new JLabel(EMPTY_DAY, SwingConstants.RIGHT);
jlDaysOfMonth[i][j].setOpaque(true);
jlDaysOfMonth[i][j].setForeground(DAY_FOREGROUND);
jlDaysOfMonth[i][j].setBackground(DAY_BACKGROUND);
jlDaysOfMonth[i][j].addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent evt) {
selectDay((JLabel) evt.getSource());
}
});
jlDaysOfMonth[i][j].setBorder(new CompoundBorder(new MatteBorder(2, 0, 0, 0, Color.WHITE), new EmptyBorder(0, 0, 0, 3)));
}
}
jpMonthYear = new JPanel();
jpMonthYear.add(jcbMonth);
jpMonthYear.add(jsYear);
jpDaysOfMonth = new JPanel(new DayOfMonthGridLayout(7, 7));
jpDaysOfMonth.setBackground(DAY_BACKGROUND);
jpDaysOfMonth.setBorder(new CompoundBorder(BorderFactory.createLoweredBevelBorder(), new EmptyBorder(2, 2, 2, 2)));
jpDaysOfMonth.setFocusable(true);
jpDaysOfMonth.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent evt) {
setSelectedDay(jlSelectedDayOfMonth);
}
@Override
public void focusLost(FocusEvent evt) {
setSelectedDay(jlSelectedDayOfMonth);
}
});
jpDaysOfMonth.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent evt) {
calendarKeyboardNavigation(evt);
}
});
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 7; j++) {
jpDaysOfMonth.add(jlDaysOfMonth[i][j]);
}
}
jsHour = new JSpinner(new SpinnerListModel(HOURS));
jlTimeSeparator1 = new JLabel(":");
jsMinute = new JSpinner(new SpinnerListModel(MINUTES));
jlTimeSeparator2 = new JLabel(":");
jsSecond = new JSpinner(new SpinnerListModel(SECONDS));
jpTime = new JPanel(new FlowLayout(FlowLayout.CENTER));
jpTime.add(jsHour);
jpTime.add(jlTimeSeparator1);
jpTime.add(jsMinute);
jpTime.add(jlTimeSeparator2);
jpTime.add(jsSecond);
JPanel jpDateTime = new JPanel(new BorderLayout(0, 0));
jpDateTime.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5))));
jpDateTime.add(BorderLayout.NORTH, jpMonthYear);
jpDateTime.add(BorderLayout.CENTER, jpDaysOfMonth);
jpDateTime.add(BorderLayout.SOUTH, jpTime);
jbOK = new JButton(res.getString("DDateTimeChooser.jbOK.text"));
jbOK.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
okPressed();
}
});
jbCancel = new JButton(res.getString("DDateTimeChooser.jbCancel.text"));
jbCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
cancelPressed();
}
});
jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY);
jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent evt) {
cancelPressed();
}
});
jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel, false);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(BorderLayout.CENTER, jpDateTime);
getContentPane().add(BorderLayout.SOUTH, jpButtons);
if (date == null) {
date = new Date();
}
populate(date);
setResizable(false);
getRootPane().setDefaultButton(jbOK);
pack();
}
use of javax.swing.border.EtchedBorder in project keystore-explorer by kaikramer.
the class DCryptoStrength method initComponents.
private void initComponents() throws CryptoException {
getContentPane().setLayout(new BorderLayout());
GridBagConstraints gbcLabel = new GridBagConstraints();
gbcLabel.gridx = 0;
gbcLabel.gridwidth = 3;
gbcLabel.gridheight = 1;
gbcLabel.insets = new Insets(5, 5, 5, 5);
gbcLabel.anchor = GridBagConstraints.EAST;
GridBagConstraints gbcTextField = new GridBagConstraints();
gbcTextField.gridx = 3;
gbcTextField.gridwidth = 3;
gbcTextField.gridheight = 1;
gbcTextField.insets = new Insets(5, 5, 5, 5);
gbcTextField.anchor = GridBagConstraints.WEST;
GridBagConstraints gbcButton = new GridBagConstraints();
gbcButton.gridx = 6;
gbcButton.gridwidth = 3;
gbcButton.gridheight = 1;
gbcButton.insets = new Insets(5, 5, 5, 5);
gbcButton.anchor = GridBagConstraints.WEST;
jpCryptoStrength = new JPanel(new GridBagLayout());
jpCryptoStrength.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new EtchedBorder()));
jlLocalStrength = new JLabel(res.getString("DCryptoStrength.jlLocalStrength.text"), SwingConstants.RIGHT);
GridBagConstraints gbc_jlLocalStrength = (GridBagConstraints) gbcLabel.clone();
gbc_jlLocalStrength.gridy = 0;
jpCryptoStrength.add(jlLocalStrength, gbc_jlLocalStrength);
jtfLocalStrength = new JTextField(JcePolicyUtil.getCryptoStrength(JcePolicy.LOCAL_POLICY).friendly(), TEXT_FIELD_WIDTH);
jtfLocalStrength.setToolTipText(res.getString("DCryptoStrength.jtfLocalStrength.tooltip"));
jtfLocalStrength.setEditable(false);
jtfLocalStrength.setCaretPosition(0);
GridBagConstraints gbc_jtfLocalStrength = (GridBagConstraints) gbcTextField.clone();
gbc_jtfLocalStrength.gridy = 0;
jpCryptoStrength.add(jtfLocalStrength, gbc_jtfLocalStrength);
jbLocalStrengthDetails = new JButton(res.getString("DCryptoStrength.jbLocalStrengthDetails.text"));
PlatformUtil.setMnemonic(jbLocalStrengthDetails, res.getString("DCryptoStrength.jbLocalStrengthDetails.mnemonic").charAt(0));
jbLocalStrengthDetails.setToolTipText(res.getString("DCryptoStrength.jbLocalStrengthDetails.tooltip"));
jbLocalStrengthDetails.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(DCryptoStrength.this);
displayPolicyDetails(JcePolicy.LOCAL_POLICY);
} finally {
CursorUtil.setCursorFree(DCryptoStrength.this);
}
}
});
GridBagConstraints gbc_jbLocalStrengthDetails = (GridBagConstraints) gbcButton.clone();
gbc_jbLocalStrengthDetails.gridy = 0;
jpCryptoStrength.add(jbLocalStrengthDetails, gbc_jbLocalStrengthDetails);
jlUsExportStrength = new JLabel(res.getString("DCryptoStrength.jlUsExportStrength.text"), SwingConstants.RIGHT);
GridBagConstraints gbc_jlUsExportStrength = (GridBagConstraints) gbcLabel.clone();
gbc_jlUsExportStrength.gridy = 1;
jpCryptoStrength.add(jlUsExportStrength, gbc_jlUsExportStrength);
jtfUsExportStrength = new JTextField(JcePolicyUtil.getCryptoStrength(JcePolicy.US_EXPORT_POLICY).friendly(), TEXT_FIELD_WIDTH);
jtfUsExportStrength.setToolTipText(res.getString("DCryptoStrength.jtfUsExportStrength.tooltip"));
jtfUsExportStrength.setEditable(false);
jtfUsExportStrength.setCaretPosition(0);
GridBagConstraints gbc_jtfUsExportStrength = (GridBagConstraints) gbcTextField.clone();
gbc_jtfUsExportStrength.gridy = 1;
jpCryptoStrength.add(jtfUsExportStrength, gbc_jtfUsExportStrength);
jbUsExportStrengthDetails = new JButton(res.getString("DCryptoStrength.jbUsExportStrengthDetails.text"));
PlatformUtil.setMnemonic(jbUsExportStrengthDetails, res.getString("DCryptoStrength.jbUsExportStrengthDetails.mnemonic").charAt(0));
jbUsExportStrengthDetails.setToolTipText(res.getString("DCryptoStrength.jbUsExportStrengthDetails.tooltip"));
jbUsExportStrengthDetails.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(DCryptoStrength.this);
displayPolicyDetails(JcePolicy.US_EXPORT_POLICY);
} finally {
CursorUtil.setCursorFree(DCryptoStrength.this);
}
}
});
GridBagConstraints gbc_jbUsExportStrengthDetails = (GridBagConstraints) gbcButton.clone();
gbc_jbUsExportStrengthDetails.gridy = 1;
jpCryptoStrength.add(jbUsExportStrengthDetails, gbc_jbUsExportStrengthDetails);
jbOK = new JButton(res.getString("DCryptoStrength.jbOK.text"));
jbOK.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
okPressed();
}
});
jpOK = PlatformUtil.createDialogButtonPanel(jbOK, false);
getContentPane().add(jpCryptoStrength, BorderLayout.CENTER);
getContentPane().add(jpOK, BorderLayout.SOUTH);
setResizable(false);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
closeDialog();
}
});
getRootPane().setDefaultButton(jbOK);
pack();
}
use of javax.swing.border.EtchedBorder in project keystore-explorer by kaikramer.
the class DChangePassword method initComponents.
private void initComponents() {
getContentPane().setLayout(new BorderLayout());
jlOld = new JLabel(res.getString("DChangePassword.jlOld.text"));
GridBagConstraints gbc_jlOld = new GridBagConstraints();
gbc_jlOld.gridx = 0;
gbc_jlOld.gridy = 0;
gbc_jlOld.anchor = GridBagConstraints.EAST;
gbc_jlOld.insets = new Insets(5, 5, 5, 5);
if (oldPassword != null) {
jpfOld = new JPasswordField("1234567890", 15);
jpfOld.setEnabled(false);
} else {
jpfOld = new JPasswordField(15);
}
GridBagConstraints gbc_jpfOld = new GridBagConstraints();
gbc_jpfOld.gridx = 1;
gbc_jpfOld.gridy = 0;
gbc_jpfOld.anchor = GridBagConstraints.WEST;
gbc_jpfOld.insets = new Insets(5, 5, 5, 5);
jlFirst = new JLabel(res.getString("DChangePassword.jlFirst.text"));
GridBagConstraints gbc_jlFirst = new GridBagConstraints();
gbc_jlFirst.gridx = 0;
gbc_jlFirst.gridy = 1;
gbc_jlFirst.anchor = GridBagConstraints.EAST;
gbc_jlFirst.insets = new Insets(5, 5, 5, 5);
if (passwordQualityConfig.getEnabled()) {
if (passwordQualityConfig.getEnforced()) {
jpfFirst = new JPasswordQualityField(15, passwordQualityConfig.getMinimumQuality());
} else {
jpfFirst = new JPasswordQualityField(15);
}
} else {
jpfFirst = new JPasswordField(15);
}
GridBagConstraints gbc_jpqfFirst = new GridBagConstraints();
gbc_jpqfFirst.gridx = 1;
gbc_jpqfFirst.gridy = 1;
gbc_jpqfFirst.anchor = GridBagConstraints.WEST;
gbc_jpqfFirst.insets = new Insets(5, 5, 5, 5);
jlConfirm = new JLabel(res.getString("DChangePassword.jlConfirm.text"));
GridBagConstraints gbc_jlConfirm = new GridBagConstraints();
gbc_jlConfirm.gridx = 0;
gbc_jlConfirm.gridy = 2;
gbc_jlConfirm.anchor = GridBagConstraints.EAST;
gbc_jlConfirm.insets = new Insets(5, 5, 5, 5);
jpfConfirm = new JPasswordField(15);
GridBagConstraints gbc_jpfConfirm = new GridBagConstraints();
gbc_jpfConfirm.gridx = 1;
gbc_jpfConfirm.gridy = 2;
gbc_jpfConfirm.anchor = GridBagConstraints.WEST;
gbc_jpfConfirm.insets = new Insets(5, 5, 5, 5);
jpPassword = new JPanel(new GridBagLayout());
jpPassword.add(jlOld, gbc_jlOld);
jpPassword.add(jpfOld, gbc_jpfOld);
jpPassword.add(jlFirst, gbc_jlFirst);
jpPassword.add(jpfFirst, gbc_jpqfFirst);
jpPassword.add(jlConfirm, gbc_jlConfirm);
jpPassword.add(jpfConfirm, gbc_jpfConfirm);
jpPassword.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5))));
jbOK = new JButton(res.getString("DChangePassword.jbOK.text"));
jbOK.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
okPressed();
}
});
jbCancel = new JButton(res.getString("DChangePassword.jbCancel.text"));
jbCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
cancelPressed();
}
});
jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY);
jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent evt) {
cancelPressed();
}
});
jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel, false);
getContentPane().add(jpPassword, BorderLayout.CENTER);
getContentPane().add(jpButtons, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
closeDialog();
}
});
setResizable(false);
getRootPane().setDefaultButton(jbOK);
pack();
}
use of javax.swing.border.EtchedBorder in project keystore-explorer by kaikramer.
the class DGetPassword method initComponents.
private void initComponents() {
getContentPane().setLayout(new BorderLayout());
jlPassword = new JLabel(res.getString("DGetPassword.jlPassword.text"));
jpfPassword = new JPasswordField(15);
jbOK = new JButton(res.getString("DGetPassword.jbOK.text"));
jbOK.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
okPressed();
}
});
jbCancel = new JButton(res.getString("DGetNewPassword.jbCancel.text"));
jbCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
cancelPressed();
}
});
jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY);
jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent evt) {
cancelPressed();
}
});
jpPassword = new JPanel(new FlowLayout(FlowLayout.CENTER));
jpPassword.add(jlPassword);
jpPassword.add(jpfPassword);
jpPassword.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5))));
jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel, false);
getContentPane().add(jpPassword, BorderLayout.CENTER);
getContentPane().add(jpButtons, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
closeDialog();
}
});
setResizable(false);
getRootPane().setDefaultButton(jbOK);
pack();
}
use of javax.swing.border.EtchedBorder in project tetrad by cmu-phil.
the class SetupLoggingAction method buildSetupLoggingComponent.
/**
* The component used to config logging.
*/
private static JComponent buildSetupLoggingComponent() {
// build yes/no combo box.
JComboBox activateCombo = new JComboBox(new String[] { "No", "Yes" });
activateCombo.setMaximumSize(activateCombo.getPreferredSize());
activateCombo.setSelectedItem(TetradLogger.getInstance().isLogging() ? "Yes" : "No");
activateCombo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JComboBox combo = (JComboBox) e.getSource();
TetradLogger.getInstance().setLogging("Yes".equals(combo.getSelectedItem()));
}
});
String saveLocation = TetradLogger.getInstance().getLoggingDirectory();
final JTextField saveField = new JTextField(saveLocation);
saveField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JTextField field = (JTextField) e.getSource();
try {
TetradLogger.getInstance().setLoggingDirectory(field.getText());
} catch (IllegalArgumentException ex) {
JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), ex.getMessage());
}
}
});
JButton chooseButton = new JButton(" ... ");
chooseButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String saveLocation = TetradLogger.getInstance().getLoggingDirectory();
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setCurrentDirectory(new File(saveLocation));
int ret = chooser.showOpenDialog(JOptionUtils.centeringComp());
if (ret == JFileChooser.APPROVE_OPTION) {
File selectedFile = chooser.getSelectedFile();
Preferences.userRoot().put("loggingDirectory", selectedFile.getAbsolutePath());
saveField.setText(selectedFile.getAbsolutePath());
}
}
});
chooseButton.setBorder(new EtchedBorder());
JTextField prefixField = new JTextField(TetradLogger.getInstance().getLoggingFilePrefix());
prefixField.addCaretListener(new CaretListener() {
public void caretUpdate(CaretEvent e) {
JTextField field = (JTextField) e.getSource();
String text = field.getText();
if (!text.matches("[a-zA-Z_]*")) {
JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "Spaces, numbers, and special characters (" + "except underlines) in filenames will be " + "ignored. You might want to delete them.", "Friendly Detail Message", JOptionPane.WARNING_MESSAGE);
}
TetradLogger.getInstance().setLoggingFilePrefix(text);
}
});
// JCheckBox automatic = new JCheckBox("Automatically display log output.");
// Boolean b = TetradLogger.getInstance().isAutomaticLogDisplayEnabled();
// automatic.setSelected(b != null && b);
// automatic.setHorizontalTextPosition(AbstractButton.LEFT);
// automatic.addActionListener(new ActionListener(){
// public void actionPerformed(ActionEvent e) {
// JCheckBox box = (JCheckBox)e.getSource();
// TetradLogger.getInstance().setAutomaticLogDisplayEnabled(box.isSelected());
// }
// });
// Box automaticBox = Box.createHorizontalBox();
// automaticBox.add(automatic);
// automaticBox.add(Box.createHorizontalGlue());
// Do Layout.
Box b1 = Box.createVerticalBox();
// Box b2 = Box.createHorizontalBox();
// b2.add(new JLabel("Activate Logging: "));
// b2.add(Box.createHorizontalStrut(5));
// b2.add(activateCombo);
// b2.add(Box.createHorizontalGlue());
//
// b1.add(b2);
// b1.add(Box.createVerticalStrut(5));
b1.add(createLogToBox());
b1.add(Box.createVerticalStrut(5));
// b1.add(automaticBox);
// b1.add(Box.createVerticalStrut(10));
Box b4 = Box.createHorizontalBox();
b4.add(new JLabel("Output Directory:"));
b4.add(Box.createHorizontalGlue());
b1.add(b4);
Box b5 = Box.createHorizontalBox();
b5.add(saveField);
b5.add(chooseButton);
b1.add(b5);
b1.add(Box.createVerticalStrut(5));
Box b6 = Box.createHorizontalBox();
b6.add(new JLabel("File Prefix:"));
b6.add(Box.createHorizontalGlue());
b1.add(b6);
Box b7 = Box.createHorizontalBox();
b7.add(prefixField);
b1.add(b7);
b1.add(Box.createVerticalStrut(5));
Box b8 = Box.createHorizontalBox();
b8.add(new JLabel("<html>" + "Output will be written to sequentially numbered files, using the<br>" + "given file prefix, in the given directory, with one output file<br>" + "generated per search." + "</html>"));
b1.add(b8);
return b1;
}
Aggregations