List of usage examples for com.jgoodies.forms.util DefaultUnitConverter dialogUnitXAsPixel
@Override public int dialogUnitXAsPixel(int dluX, Component c)
From source file:eu.lp0.cursus.ui.common.CommonDetailDialog.java
License:Open Source License
private void initialise() { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle(title);//ww w .j a va 2 s. c o m 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);//w w w. ja v a 2 s . c o 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();/* w ww .j av a2s. c om*/ }
From source file:org.openthinclient.console.util.SectionTitleBar.java
License:Open Source License
protected void paintComponent(Graphics g) { DefaultUnitConverter duc = DefaultUnitConverter.getInstance(); int w = getWidth() - 1; int h = getHeight(); int bevelSize = duc.dialogUnitXAsPixel(6, this); Graphics2D g2 = (Graphics2D) g; GeneralPath clip = new GeneralPath(); clip.moveTo(0, h);//from w w w . ja va2 s . com clip.lineTo(0, bevelSize); clip.curveTo(0, 0, 0, 0, bevelSize, 0); clip.lineTo(w - bevelSize, 0); clip.curveTo(w, 0, w, 0, w, bevelSize); clip.lineTo(w, h); Color fillColor = UIManager.getColor("InternalFrame.activeTitleGradient"); //$NON-NLS-1$ if (null == fillColor) fillColor = UIManager.getColor("InternalFrame.activeTitleBackground"); //$NON-NLS-1$ Object rhAA = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); GradientPaint painter = new GradientPaint(0, h / 2, new Color(fillColor.getRed(), fillColor.getGreen(), fillColor.getBlue(), 128), 0, h, new Color(fillColor.getRed(), fillColor.getGreen(), fillColor.getBlue(), 0)); g2.setPaint(painter); g2.fill(clip); Color lineColor = getBackground().darker(); painter = new GradientPaint(0, h / 2, lineColor, 0f, h, new Color(lineColor.getRed(), lineColor.getGreen(), lineColor.getBlue(), 0)); g2.setPaint(painter); g2.draw(clip); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, rhAA); super.paintComponent(g); }