List of usage examples for com.jgoodies.forms.util DefaultUnitConverter dialogUnitYAsPixel
@Override public int dialogUnitYAsPixel(int dluY, Component c)
From source file:eu.lp0.cursus.ui.AboutDialog.java
License:Open Source License
private void initialise() { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle(Messages.getString("about.title", Constants.APP_DESC)); //$NON-NLS-1$ DefaultUnitConverter duc = DefaultUnitConverter.getInstance(); FormLayout layout = new FormLayout("2dlu, pref, fill:pref:grow, max(30dlu;pref), 2dlu", //$NON-NLS-1$ "2dlu, max(15dlu;pref), 2dlu, max(15dlu;pref), 2dlu, fill:max(100dlu;pref):grow, 2dlu, max(16dlu;pref), 2dlu"); //$NON-NLS-1$ getContentPane().setLayout(layout);// w w w.ja v a 2 s .com JLabel lblName = new JLabel(Constants.APP_NAME + ": " + Messages.getString("about.description")); //$NON-NLS-1$ //$NON-NLS-2$ getContentPane().add(lblName, "2, 2, 3, 1"); //$NON-NLS-1$ getContentPane().add(new LinkJButton(Constants.APP_URL), "2, 4"); //$NON-NLS-1$ JScrollPane scrCopying = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); getContentPane().add(scrCopying, "2, 6, 3, 1"); //$NON-NLS-1$ JTextArea txtCopying = new JTextArea(loadResources("COPYRIGHT", "LICENCE")); //$NON-NLS-1$ //$NON-NLS-2$ txtCopying.setFont(Font.decode(Font.MONOSPACED)); txtCopying.setEditable(false); scrCopying.setViewportView(txtCopying); scrCopying.setPreferredSize( new Dimension(scrCopying.getPreferredSize().width, duc.dialogUnitYAsPixel(100, scrCopying))); Action actClose = new CloseDialogAction(this); JButton btnClose = new JButton(actClose); getContentPane().add(btnClose, "4, 8"); //$NON-NLS-1$ getRootPane().setDefaultButton(btnClose); getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CloseDialogAction.class.getName()); getRootPane().getActionMap().put(CloseDialogAction.class.getName(), actClose); pack(); setMinimumSize(getSize()); setSize(getSize().width, getSize().height * 3 / 2); btnClose.requestFocusInWindow(); }
From source file:eu.lp0.cursus.ui.common.CommonDetailDialog.java
License:Open Source License
private void initialise() { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle(title);//from www .j a va 2 s . c om DefaultUnitConverter duc = DefaultUnitConverter.getInstance(); Dimension min = new Dimension(duc.dialogUnitXAsPixel(150, this), duc.dialogUnitYAsPixel(75, this)); min.width += getInsets().left + getInsets().right; min.height += getInsets().top + getInsets().bottom; FormLayout layout = new FormLayout( "2dlu, right:max(30dlu;pref), 2dlu, fill:max(0dlu;pref):grow, max(30dlu;pref), 2dlu, max(30dlu;pref), 2dlu", //$NON-NLS-1$ "2dlu, max(15dlu;pref), 2dlu, max(15dlu;pref), 2dlu:grow, max(16dlu;pref), 2dlu"); //$NON-NLS-1$ getContentPane().setLayout(layout); JLabel lblName = new JLabel(Messages.getString("entity.name") + ":"); //$NON-NLS-1$ //$NON-NLS-2$ getContentPane().add(lblName, "2, 2"); //$NON-NLS-1$ txtName = new DatabaseTextField(origItem.getName(), Constants.MAX_STRING_LEN); getContentPane().add(txtName, "4, 2, 4, 1"); //$NON-NLS-1$ JLabel lblDesc = new JLabel(Messages.getString("entity.description") + ":"); //$NON-NLS-1$ //$NON-NLS-2$ getContentPane().add(lblDesc, "2, 4"); //$NON-NLS-1$ txtDesc = new DatabaseTextField(origItem.getDescription(), Constants.MAX_STRING_LEN); getContentPane().add(txtDesc, "4, 4, 4, 1"); //$NON-NLS-1$ Action actCancel = new CancelDialogAction(this); JButton btnCancel = new JButton(actCancel); JButton btnSave = new JButton(new SaveDialogAction() { @Override public void actionPerformed(ActionEvent ae) { doSave(); } }); SwingHacks.addButtonsInUIOrder(getContentPane(), Arrays.asList(btnSave, btnCancel), Arrays.asList("5, 6", "7, 6")); //$NON-NLS-1$ //$NON-NLS-2$ getRootPane().setDefaultButton(btnSave); getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CancelDialogAction.class.getName()); getRootPane().getActionMap().put(CancelDialogAction.class.getName(), actCancel); pack(); setMinimumSize(getSize()); setSize(getSize().width * 3 / 2, getSize().height); }
From source file:jgnash.ui.budget.BudgetWizardDialog.java
License:Open Source License
private void initComponents() { okButton = new JButton(rb.getString("Button.Ok")); cancelButton = new JButton(rb.getString("Button.Cancel")); budgetPeriodCombo = new JComboBox<>(); budgetPeriodCombo.setModel(new DefaultComboBoxModel<>(BudgetPeriod.values())); budgetPeriodCombo.setSelectedItem(BudgetPeriod.MONTHLY); budgetNameField = new JTextField(); DefaultUnitConverter unitConverter = DefaultUnitConverter.getInstance(); helpPane = new JEditorPane(); helpPane.setEditable(false);//from w ww. j a v a 2 s.co m helpPane.setEditorKit(new StyledEditorKit()); helpPane.setBackground(getBackground()); helpPane.setText(TextResource.getString("NewBudgetOne.txt")); helpPane.setPreferredSize(new Dimension(unitConverter.dialogUnitXAsPixel(DLU_X, helpPane), unitConverter.dialogUnitYAsPixel(DLU_Y, helpPane))); roundButton = new JCheckBox(rb.getString("Button.RoundToWhole")); okButton.addActionListener(this); cancelButton.addActionListener(this); }
From source file:org.openthinclient.console.util.SectionTitleBar.java
License:Open Source License
public SectionTitleBar() { setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); DefaultUnitConverter duc = DefaultUnitConverter.getInstance(); int leftRight = duc.dialogUnitXAsPixel(4, this); int topBottom = duc.dialogUnitYAsPixel(2, this); setBorder(BorderFactory.createEmptyBorder(topBottom, leftRight, topBottom, leftRight)); updateUI();/*from www .j a v a2s . c o m*/ }