public static void updateTitledBorderFont(final TitledBorder border, final Font font, final float zoom_factor) { Font old_title_font = border.getTitleFont(); Font new_title_font = font.deriveFont(old_title_font.getStyle(), Math.round(old_title_font.getSize() * zoom_factor)); border.setTitleFont(new_title_font); }
TitledBorder border = new TitledBorder(...); border.setTitleFont( border.getTitleFont().deriveFont(Font.BOLD + Font.ITALIC) );
/** * Creates a Titled Border with appropriate font settings. * @param title Title. * @return TitledBorder Object. */ public static TitledBorder createTitledBorder (String title) { TitledBorder border = new TitledBorder(title); Font font = border.getTitleFont(); Font newFont = new Font (font.getFamily(), Font.BOLD, font.getSize()+2); border.setTitleFont(newFont); border.setTitleColor(new Color(102,51,51)); return border; } }
/** * Creates a Titled Border with appropriate font settings. * @param title Title. * @return TitledBorder Object. */ public static TitledBorder createTitledBorder (String title) { TitledBorder border = new TitledBorder(title); Font font = border.getTitleFont(); Font newFont = new Font (font.getFamily(), Font.BOLD, font.getSize()+2); border.setTitleFont(newFont); border.setTitleColor(new Color(102,51,51)); return border; } }
private JPanel createControlsPanel(String fkTableName, String pkTableName) { JPanel ret = new JPanel(new GridBagLayout()); GridBagConstraints gbc; gbc = new GridBagConstraints(0,0,1,1,0,0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5,5,5,5), 0,0); JLabel lblLocalCol = new JLabel(s_stringMgr.getString("graph.ConfigureNonDbConstraintDlg.Localcolumn", fkTableName)); ret.add(lblLocalCol, gbc); gbc = new GridBagConstraints(1,0,1,1,1,0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5,5,5,5), 0,0); _cboFkCol = new JComboBox(); ret.add(_cboFkCol, gbc); gbc = new GridBagConstraints(0,1,1,1,0,0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5,5,5,5), 0,0); JLabel lblRefrencing = new JLabel(s_stringMgr.getString("graph.ConfigureNonDbConstraintDlg.Referencing", pkTableName)); ret.add(lblRefrencing, gbc); gbc = new GridBagConstraints(1,1,1,1,1,0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5,5,5,5), 0,0); _cboPkCol = new JComboBox(); ret.add(_cboPkCol, gbc); Dimension preferredSize = lblLocalCol.getPreferredSize(); preferredSize.width = Math.max(lblLocalCol.getPreferredSize().width, lblRefrencing.getPreferredSize().width); lblLocalCol.setPreferredSize(preferredSize); lblRefrencing.setPreferredSize(preferredSize); gbc = new GridBagConstraints(2,0,1,2,0,0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0,5,5,5), 0,0); ret.add(createAddButtonsPanel(), gbc); TitledBorder titledBorder = BorderFactory.createTitledBorder(s_stringMgr.getString("graph.ConfigureNonDbConstraintDlg.AddColsTitle")); titledBorder.setTitleFont(titledBorder.getTitleFont().deriveFont(Font.BOLD)); ret.setBorder(titledBorder); return ret; }
private JButton createArrowButton() { JButton button = new JButton("arrow", iconArrow[COLLAPSED]); button.setBorder(BorderFactory.createEmptyBorder(0, 1, 5, 1)); button.setVerticalTextPosition(AbstractButton.CENTER); button.setHorizontalTextPosition(AbstractButton.LEFT); button.setMargin(new Insets(0, 0, 3, 0)); //We want to use the same font as those in the titled border font Font font = BorderFactory.createTitledBorder("Sample").getTitleFont(); Color color = BorderFactory.createTitledBorder("Sample").getTitleColor(); button.setFont(font); button.setForeground(color); button.setFocusable(false); button.setContentAreaFilled(false); button.addActionListener(new CollapsiblePanel.ExpandAndCollapseAction()); return button; }
JPanel aPanel = new JPanel(){ @Override public Dimension getPreferredSize(){ Dimension d = super.getPreferredSize(); Border b = this.getBorder(); if(b == null) return d; if(!(b instanceof TitledBorder)) return d; TitledBorder tb = (TitledBorder)b; if(tb.getTitle() == null) return d; int insets = 2 * (tb.getBorderInsets(this).left + tb.getBorderInsets(this).right); double minWidth = this.getFontMetrics(tb.getTitleFont()).stringWidth(tb.getTitle()) + insets; if(d.getWidth() > minWidth) return d; return new Dimension((int)minWidth, d.height); } };
/** * Returns a button with an arrow icon and a collapse/expand action listener. * * @return button Button which is used in the titled border component */ private JButton createArrowButton () { JButton button = new JButton("arrow", iconArrow[COLLAPSED]); button.setBorder(BorderFactory.createEmptyBorder(0,1,5,1)); button.setVerticalTextPosition(AbstractButton.CENTER); button.setHorizontalTextPosition(AbstractButton.LEFT); button.setMargin(new Insets(0,0,3,0)); //We want to use the same font as those in the titled border font Font font = BorderFactory.createTitledBorder("Sample").getTitleFont(); Color color = BorderFactory.createTitledBorder("Sample").getTitleColor(); button.setFont(font); button.setForeground(color); button.setFocusable(false); button.setContentAreaFilled(false); button.addActionListener(new CollapsiblePanel.ExpandAndCollapseAction()); return button; }
/** * Returns a button with an arrow icon and a collapse/expand action listener. * * @return button Button which is used in the titled border component */ private JButton createArrowButton () { JButton button = new JButton("arrow", iconArrow[COLLAPSED]); button.setBorder(BorderFactory.createEmptyBorder(0,1,5,1)); button.setVerticalTextPosition(AbstractButton.CENTER); button.setHorizontalTextPosition(AbstractButton.LEFT); button.setMargin(new Insets(0,0,3,0)); //We want to use the same font as those in the titled border font Font font = BorderFactory.createTitledBorder("Sample").getTitleFont(); Color color = BorderFactory.createTitledBorder("Sample").getTitleColor(); button.setFont(font); button.setForeground(color); button.setFocusable(false); button.setContentAreaFilled(false); button.addActionListener(new CollapsiblePanel.ExpandAndCollapseAction()); return button; }
/** * Returns a button with an arrow icon and a collapse/expand action listener. * * @return button Button which is used in the titled border component */ private JButton createArrowButton() { JButton button = new JButton("arrow", iconArrow[COLLAPSED]); button.setBorder(BorderFactory.createEmptyBorder(0, 1, 5, 1)); button.setVerticalTextPosition(AbstractButton.CENTER); button.setHorizontalTextPosition(AbstractButton.LEFT); button.setMargin(new Insets(0, 0, 3, 0)); //We want to use the same font as those in the titled border font Font font = BorderFactory.createTitledBorder("Sample").getTitleFont(); Color color = BorderFactory.createTitledBorder("Sample").getTitleColor(); button.setFont(font); button.setForeground(color); button.setFocusable(false); button.setContentAreaFilled(false); button.addActionListener(new CollapsablePanel.ExpandAndCollapseAction()); return button; }
/** * Returns a button with an arrow icon and a collapse/expand action listener. * * @return button Button which is used in the titled border component */ private JButton createArrowButton () { JButton button = new JButton("arrow", iconArrow[COLLAPSED]); button.setBorder(BorderFactory.createEmptyBorder(0,1,5,1)); button.setVerticalTextPosition(AbstractButton.CENTER); button.setHorizontalTextPosition(AbstractButton.LEFT); button.setMargin(new Insets(0,0,3,0)); //We want to use the same font as those in the titled border font Font font = BorderFactory.createTitledBorder("Sample").getTitleFont(); Color color = BorderFactory.createTitledBorder("Sample").getTitleColor(); button.setFont(font); button.setForeground(color); button.setFocusable(false); button.setContentAreaFilled(false); button.addActionListener(new CollapsiblePanel.ExpandAndCollapseAction()); return button; }
/** * Returns a button with an arrow icon and a collapse/expand action listener. * * @return button Button which is used in the titled border component */ private JButton createArrowButton () { JButton button = new JButton("arrow", iconArrow[COLLAPSED]); button.setBorder(BorderFactory.createEmptyBorder(0,1,5,1)); button.setVerticalTextPosition(AbstractButton.CENTER); button.setHorizontalTextPosition(AbstractButton.LEFT); button.setMargin(new Insets(0,0,3,0)); //We want to use the same font as those in the titled border font Font font = BorderFactory.createTitledBorder("Sample").getTitleFont(); Color color = BorderFactory.createTitledBorder("Sample").getTitleColor(); button.setFont(font); button.setForeground(color); button.setFocusable(false); button.setContentAreaFilled(false); button.addActionListener(new CyCollapsiblePanel.ExpandAndCollapseAction()); return button; }
/** * Returns a button with an arrow icon and a collapse/expand action listener. * * @return button Button which is used in the titled border component */ private JButton createArrowButton() { JButton button = new JButton("arrow", iconArrow[COLLAPSED]); button.setBorder(BorderFactory.createEmptyBorder(0, 1, 5, 1)); button.setVerticalTextPosition(AbstractButton.CENTER); button.setHorizontalTextPosition(AbstractButton.LEFT); button.setMargin(new Insets(0, 0, 3, 0)); //We want to use the same font as those in the titled border font Font font = BorderFactory.createTitledBorder("Sample").getTitleFont(); Color color = BorderFactory.createTitledBorder("Sample").getTitleColor(); button.setFont(font); button.setForeground(color); button.setFocusable(false); button.setContentAreaFilled(false); button.addActionListener(new CollapsablePanel.ExpandAndCollapseAction()); return button; }
/** * Returns a button with an arrow icon and a collapse/expand action * listener. * * @return button Button which is used in the titled border component */ private JButton createArrowButton() { JButton button = new JButton("arrow", iconArrow[COLLAPSED]); button.setBorder(BorderFactory.createEmptyBorder(0, 1, 5, 1)); button.setVerticalTextPosition(AbstractButton.CENTER); button.setHorizontalTextPosition(AbstractButton.LEFT); button.setMargin(new Insets(0, 0, 3, 0)); // We want to use the same font as those in the titled border font Font font = BorderFactory.createTitledBorder("Sample").getTitleFont(); Color color = BorderFactory.createTitledBorder("Sample").getTitleColor(); button.setFont(font); button.setForeground(color); button.setFocusable(false); button.setContentAreaFilled(false); button.addActionListener(new BasicCollapsiblePanel.ExpandAndCollapseAction()); return button; }
pnlBordered.add(new JScrollPane(_table.getComponent())); TitledBorder titledBorder = BorderFactory.createTitledBorder(s_stringMgr.getString("graph.ConfigureNonDbConstraintDlg.tblTitle")); titledBorder.setTitleFont(titledBorder.getTitleFont().deriveFont(Font.BOLD)); pnlBordered.setBorder(titledBorder); getContentPane().add(pnlBordered, gbc);
if (titledBorder.getTitle() != null && !"".equals(titledBorder.getTitle())) { Font font = titledBorder.getTitleFont(); if (font == null) { font = panel.getFont();
if (titledBorder.getTitle() != null && !"".equals(titledBorder.getTitle())) { Font font = titledBorder.getTitleFont(); if (font == null) { font = panel.getFont();
FontMetrics fm = getFontMetrics( tb.getTitleFont() ); int titleWidth = fm.stringWidth(tb.getTitle()) + 20; Rectangle bounds = new Rectangle(0, 0, titleWidth, fm.getHeight());
Font titledBorderDefaultFont = this.fsViewModeJPanelBorder.getTitleFont(); if (titledBorderDefaultFont == null) {
titledBorder.setTitleFont(titledBorder.getTitleFont().deriveFont(Font.BOLD, 24)); setBorder(titledBorder); setLayout(new GridBagLayout());