List of utility methods to do Swing TitledBorder
Border | CreateTitledBorderwMargin(String title, int topMargin, int leftMargin, int bottomMargin, int rightMargin) Creates a Titled border having title that is on top and specified margins around it. Border bdrMargin = BorderFactory.createEmptyBorder(topMargin, leftMargin, bottomMargin, rightMargin);
return BorderFactory.createCompoundBorder(bdrMargin, BorderFactory.createTitledBorder(title));
|
TitledBorder | createTitledPanelBorder(String title) create Titled Panel Border TitledBorder border = BorderFactory.createTitledBorder(title); Font font = border.getTitleFont(); if (font == null) { font = UIManager.getFont("TitledBorder.font"); border.setTitleFont(new Font(font.getName(), Font.ITALIC, font.getSize())); return border; |
TitledBorder | formatTitle(TitledBorder titledBorder) Formats the title of a given TitledBorder Workaround for Java Bug ID: 7022041 Font titleBorderFont = UIManager.getDefaults().getFont("TitledBorder.font"); if (titleBorderFont != null) { titledBorder.setTitleFont(new Font(titleBorderFont.getName(), Font.BOLD, titleBorderFont.getSize())); return titledBorder; |
Border | getBorder(String title) get Border Border loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
Border b1 = BorderFactory.createEmptyBorder(5, 5, 5, 5);
Border b2 = BorderFactory.createTitledBorder(loweredetched, title);
return BorderFactory.createCompoundBorder(b1, b2);
|
Insets | getBorderInsetsForNoComponent(Border border) get Border Insets For No Component if (border instanceof TitledBorder) { return border.getBorderInsets(new Component() { }); return border.getBorderInsets(null); |
CompoundBorder | getCompoundBorder(String text) get Compound Border return BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(text),
BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
int | getTitledBorderHeight(Border border) get Titled Border Height if (border instanceof TitledBorder) { int fontSize = ((TitledBorder) border).getTitleFont() != null ? ((TitledBorder) border).getTitleFont().getSize() : 11; return fontSize + 4; return 0; |
Border | getTitleLabelBorder() Returns a border used in the TitlePanels. Border b1 = BorderFactory.createMatteBorder(1, 1, 0, 0, Color.WHITE); Border b2 = BorderFactory.createMatteBorder(0, 0, 1, 0, Color.GRAY); Border b3 = new EmptyBorder(3, 5, 3, 5); Border b = BorderFactory.createCompoundBorder(BorderFactory.createCompoundBorder(b2, b1), b3); return b; |
JPanel | makeBorderedPanel(String borderTitle) make Bordered Panel JPanel panel = new JPanel(); panel.setBorder(new TitledBorder(borderTitle)); return panel; |
Border | makeTitledBorder(String title) make Titled Border return BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), title);
|