private void addTab(JTabbedPane tabControl, String title, JPanel content) { JLabel tabText = new JLabel(title, JLabel.LEFT); tabText.setPreferredSize(new Dimension(6 * controlHeight, controlHeight)); TitledBorder titledBorder = BorderFactory.createTitledBorder(title); titledBorder.setTitleJustification(TitledBorder.CENTER); content.setBorder(titledBorder); tabControl.addTab(null, content); tabControl.setTabComponentAt(tabControl.getTabCount() - 1, tabText); }
private void setSliderTitle(JSlider slider, Color color, String str) { //Border empty = BorderFactory.createTitledBorder( BorderFactory.createEmptyBorder() ); TitledBorder tb = new TitledBorder(BorderFactory.createEtchedBorder(), //empty, "", TitledBorder.CENTER, TitledBorder.ABOVE_BOTTOM, new Font("Sans", Font.PLAIN, 11)); tb.setTitleJustification(TitledBorder.LEFT); tb.setTitle(str); tb.setTitleColor(color); slider.setBorder(tb); }
private JSlider makeTitledSilder(String string, Color color, int minVal, int maxVal, int val) { //Border empty = BorderFactory.createTitledBorder( BorderFactory.createEmptyBorder() ); JSlider slider = new JSlider(JSlider.HORIZONTAL, minVal, maxVal, val ); TitledBorder tb = new TitledBorder(BorderFactory.createEtchedBorder(), //empty, "", TitledBorder.CENTER, TitledBorder.ABOVE_BOTTOM, new Font("Sans", Font.PLAIN, 11)); tb.setTitle(string); tb.setTitleJustification(TitledBorder.LEFT); tb.setTitleColor(color); slider.setBorder(tb); slider.setMajorTickSpacing((maxVal - minVal)/6 ); //slider.setMajorTickSpacing((maxVal - minVal)/10 ); slider.setPaintTicks(true); slider.addChangeListener( this ); slider.addChangeListener( this ); slider.addMouseListener(this); return slider; }
JPanel panel = new JPanel(); TitledBorder titledBorder = BorderFactory.createTitledBorder("Some title"); titledBorder.setTitleJustification(TitledBorder.CENTER); panel.setBorder(titledBorder); frame.add(panel);
/** * Creates the titled border. * * @param title * the title * @return the border */ public static Border createTitledBorder(final String title) { final TitledBorder b = BorderFactory.createTitledBorder(""); b.setTitle(JKMessage.get(title, true)); b.setTitleJustification(TitledBorder.DEFAULT_JUSTIFICATION); b.setTitlePosition(TitledBorder.CENTER); b.setTitleColor(JKColors.TITLE_BORDER_BG); return b; }
TitledBorder nameBorder = BorderFactory.createTitledBorder( "Change Description"); nameBorder.setTitleJustification(TitledBorder.LEFT); namePanel = new JPanel(toolBarLayout); namePanel.setPreferredSize(new Dimension(150, 150));// hardCoded sizing
title.setTitleJustification(TitledBorder.LEFT); setBorder(title);
/** * Creates a titled border instance that can be applied to any Swing * component. */ public Border createBorder(Component comp) { TitledBorder b = new TitledBorder(getTitle()); b.setTitlePosition(getPosition()); b.setTitleJustification(getJustification()); b.setTitleColor(new ColorProxy(getTextColorProperty())); return b; }
TitledBorder title=BorderFactory.createTitledBorder("Drag & Drop between JLists"); p.setBorder(title); title.setTitleJustification(TitledBorder.CENTER); p.add(new JScrollPane(makeList("play-left-list", h))); p.add(new JScrollPane(makeList("songs-right-list", h)));
border.setTitleJustification(TitledBorder.CENTER); layoutPanel.setBorder(border);
border.setTitleJustification(TitledBorder.CENTER); border.setTitleJustification(TitledBorder.CENTER);
border.setTitleJustification(TitledBorder.LEFT); bpanel.setBorder(border);
@Override protected JPanel createPatternsPanel() { JPanel patternsPanel = new JPanel(new SpringLayout()); TitledBorder titledBorder = BorderFactory.createTitledBorder(Bundle.CTL_Panel_OutputPattern_Border_TitleText()); titledBorder.setTitleJustification(TitledBorder.CENTER); patternsPanel.setBorder(titledBorder); TextFieldEditor textEditor = new TextFieldEditor(); addTextField(patternsPanel, textEditor, Bundle.CTL_Label_ProgressPattern(), ToolAdapterConstants.PROGRESS_PATTERN, false, null); propertyContainer.getDescriptor(ToolAdapterConstants.PROGRESS_PATTERN) .setValidator(new RegexFieldValidator()); addTextField(patternsPanel, textEditor, Bundle.CTL_Label_StepPattern(), ToolAdapterConstants.STEP_PATTERN, false, null); propertyContainer.getDescriptor(ToolAdapterConstants.STEP_PATTERN) .setValidator(new RegexFieldValidator()); addTextField(patternsPanel, textEditor, Bundle.CTL_Label_ErrorPattern(), ToolAdapterConstants.ERROR_PATTERN, false, null); propertyContainer.getDescriptor(ToolAdapterConstants.ERROR_PATTERN) .setValidator(new RegexFieldValidator()); SpringUtilities.makeCompactGrid(patternsPanel, 3, 2, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING); return patternsPanel; }