下面列出了怎么用javax.swing.border.TitledBorder的API类实例代码及写法,或者点击链接到github查看源代码。
public void addMBeanNotificationInfo(MBeanNotificationInfo mbni) {
emptyInfoTable();
emptyDescTable();
((TitledBorder) infoBorderPanel.getBorder()).setTitle(
Messages.MBEAN_NOTIFICATION_INFO);
String text = Messages.NOTIFICATION + ":";
DefaultTableModel tableModel = (DefaultTableModel) infoTable.getModel();
Object rowData[] = new Object[2];
rowData[0] = new TableRowDivider(text);
rowData[1] = new TableRowDivider("");
tableModel.addRow(rowData);
rowData[0] = Messages.NAME;
rowData[1] = mbni.getName();
tableModel.addRow(rowData);
rowData[0] = Messages.DESCRIPTION;
rowData[1] = mbni.getDescription();
tableModel.addRow(rowData);
rowData[0] = Messages.NOTIF_TYPES;
rowData[1] = Arrays.toString(mbni.getNotifTypes());
tableModel.addRow(rowData);
addDescriptor(mbni.getDescriptor(), text);
tableModel.newDataAvailable(new TableModelEvent(tableModel));
}
/**
*
* @Title: init
* @Description: Component Initialization
* @param
* @return void
* @throws
*/
private void init()
{
this.setLayout(new BorderLayout(RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH));
this.setBorder(BorderFactory.createEmptyBorder(RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH));
vReq = new ReqView();
vRsp = new RspView();
vHist = new HistView();
tp = new JTabbedPane();
tp.add(RESTConst.REQUEST, vReq);
tp.add(RESTConst.RESPONSE, vRsp);
tp.add(RESTConst.HIST, vHist);
this.add(tp);
this.setBorder(BorderFactory.createTitledBorder(null, RESTConst.REST_CLIENT, TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION));
}
public static void main(String[] args) {
Graphics g = new BufferedImage(9, 9, 9).getGraphics();
BrokenBorder broken = new BrokenBorder();
TitledBorder titled = new TitledBorder(broken, broken.getClass().getName());
Insets insets = (Insets) broken.getBorderInsets(broken).clone();
titled.getBorderInsets(broken);
broken.validate(insets);
for (int i = 0; i < 10; i++) {
titled.paintBorder(broken, g, 0, 0, i, i);
broken.validate(insets);
titled.getBaseline(broken, i, i);
broken.validate(insets);
}
}
public JPanel createPanel1()
{
JPanel jpanel1 = new JPanel();
TitledBorder titledborder1 = new TitledBorder(null,"FeatureType Parameters",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,new Color(33,33,33));
jpanel1.setBorder(titledborder1);
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:6.0CM:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0)","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
CellConstraints cc = new CellConstraints();
jpanel1.setLayout(formlayout1);
_nameLabel.setName("nameLabel");
_nameLabel.setText("name");
jpanel1.add(_nameLabel,cc.xy(2,3));
_nameTextField.setName("nameTextField");
jpanel1.add(_nameTextField,cc.xy(4,3));
addFillComponents(jpanel1,new int[]{ 1,2,3,4 },new int[]{ 1,2,3,4,5,6 });
return jpanel1;
}
public JPanel createPanel3()
{
JPanel jpanel1 = new JPanel();
TitledBorder titledborder1 = new TitledBorder(null,"Header Information",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,new Color(33,33,33));
jpanel1.setBorder(titledborder1);
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0)","FILL:DEFAULT:GROW(1.0)");
CellConstraints cc = new CellConstraints();
jpanel1.setLayout(formlayout1);
_headerTable.setName("headerTable");
JScrollPane jscrollpane1 = new JScrollPane();
jscrollpane1.setViewportView(_headerTable);
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jpanel1.add(jscrollpane1,cc.xy(1,1));
addFillComponents(jpanel1,new int[0],new int[0]);
return jpanel1;
}
public JPanel createPanel4()
{
JPanel jpanel1 = new JPanel();
TitledBorder titledborder1 = new TitledBorder(null,"First Point Information",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,new Color(33,33,33));
jpanel1.setBorder(titledborder1);
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0)","FILL:DEFAULT:NONE");
CellConstraints cc = new CellConstraints();
jpanel1.setLayout(formlayout1);
_firstPointTable.setName("firstPointTable");
JScrollPane jscrollpane1 = new JScrollPane();
jscrollpane1.setViewportView(_firstPointTable);
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jpanel1.add(jscrollpane1,cc.xy(1,1));
addFillComponents(jpanel1,new int[0],new int[0]);
return jpanel1;
}
private void addConflictTypeDescription(Point windowLocationOnScreen,
ConflictInfoPanel conflictInfoPanel) {
Point infoPanelLocation = conflictInfoPanel.getLocationOnScreen();
TitledBorder border = (TitledBorder) conflictInfoPanel.getBorder();
Dimension minimumSize = border.getMinimumSize(new JPanel());
int width = minimumSize.width;
int endTitleTextX = infoPanelLocation.x - windowLocationOnScreen.x + width;
int arrowHeadX = endTitleTextX + 10;
int arrowTailX = arrowHeadX + 50;
int descriptionX = arrowTailX + 10;
int endTitleTextY = infoPanelLocation.y - windowLocationOnScreen.y;
int arrowTailY = endTitleTextY - 5;
int arrowHeadY = endTitleTextY + 5;
int descriptionY = endTitleTextY;
mtfGenerator.drawArrow(Color.RED, 2, new Point(arrowTailX, arrowTailY),
new Point(arrowHeadX, arrowHeadY), 8);
mtfGenerator.drawText("Type of conflict to resolve.", Color.RED,
new Point(descriptionX, descriptionY), DESCRIPTION_FONT_SIZE);
}
/**
* Creates a new panel object.
*/
public CAbstractOperatorPanel() {
super(new BorderLayout());
final JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.setBorder(new TitledBorder(getBorderTitle()));
final JPanel infoPanel = new JPanel(new BorderLayout());
infoPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
m_infoField.setBackground(infoPanel.getBackground());
m_infoField.setLineWrap(true);
m_infoField.setWrapStyleWord(true);
m_infoField.setEditable(false);
infoPanel.add(m_infoField, BorderLayout.CENTER);
mainPanel.add(infoPanel, BorderLayout.CENTER);
add(mainPanel, BorderLayout.CENTER);
}
public JPanel createPanel()
{
JPanel jpanel1 = new JPanel();
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(0.6),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE,CENTER:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE");
CellConstraints cc = new CellConstraints();
jpanel1.setLayout(formlayout1);
jpanel1.add(createPanel1(),cc.xywh(2,2,9,1));
jpanel1.add(createPanel2(),cc.xywh(2,4,9,3));
jpanel1.add(createPanel3(),cc.xywh(2,14,18,1));
jpanel1.add(createPanel4(),cc.xywh(13,2,7,5));
jpanel1.add(createPanel5(),cc.xywh(13,12,7,1));
_syntaxHelpTab.setName("syntaxHelpTab");
TitledBorder titledborder1 = new TitledBorder(null,"Syntax Help",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,new Color(33,33,33));
_syntaxHelpTab.setBorder(titledborder1);
jpanel1.add(_syntaxHelpTab,cc.xywh(2,8,9,5));
_debugCheckbox.setActionCommand("Debug");
_debugCheckbox.setName("debugCheckbox");
_debugCheckbox.setText("Debug");
jpanel1.add(_debugCheckbox,cc.xywh(13,8,7,1));
jpanel1.add(createPanel6(),cc.xywh(13,10,7,1));
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 });
return jpanel1;
}
GroupsPanel() {
JScrollPane groupScroll = new JScrollPane( m_groupTable);
groupScroll.setBorder( new TitledBorder( "Groups"));
HtmlButton create = new HtmlButton( "Create Group") {
@Override protected void actionPerformed() {
onCreateGroup();
}
};
HtmlButton update = new HtmlButton( "Update") {
@Override protected void actionPerformed() {
onTransmit();
}
};
JPanel buts = new VerticalPanel();
buts.add( create);
buts.add( update);
setLayout( new BorderLayout() );
add( groupScroll);
add( buts, BorderLayout.EAST);
}
private void yoloChooser() {
JPanel panel = new JPanel(new GridLayout(0, 2));
Border border = BorderFactory.createTitledBorder("Choose Yolo");
((TitledBorder) border).setTitleFont(FONT_ITALIC);
panel.setBorder(border);
ButtonGroup group = new ButtonGroup();
yolo = new JRadioButton("Load Real Yolo");
yolo.setFont(FONT);
group.add(yolo);
panel.add(yolo);
JRadioButton tinyYolo = new JRadioButton("Tiny Yolo");
tinyYolo.setSelected(true);
panel.add(tinyYolo);
group.add(tinyYolo);
tinyYolo.setFont(FONT);
mainPanel.add(panel);
}
private void setEnabledTextureExport() {
overwriteCheck.setEnabled(exportAll.isSelected());
noTexturesCheck.setEnabled(exportAll.isSelected());
generateUniqueCheck.setEnabled(exportAll.isSelected());
((TitledBorder) pathBlock.getBorder()).setTitleColor(exportAll.isSelected() ?
UIManager.getColor("TitledBorder.titleColor") :
UIManager.getColor("Label.disabledForeground"));
pathBlock.repaint();
pathLabel.setEnabled(exportAll.isSelected());
pathText.setEnabled(exportAll.isSelected());
browseButton.setEnabled(exportAll.isSelected());
useBuckets.setEnabled(exportAll.isSelected());
noOfBuckets.setEnabled(exportAll.isSelected() && useBuckets.isSelected());
}
@Override
public void doTranslation() {
((TitledBorder)pointContentSourcePanel.getBorder()).setTitle(Language.I18N.getString("pref.kmlexport.balloon.contentSourceForPoint.border"));
pointIncludeDescription.setText(Language.I18N.getString("pref.kmlexport.balloon.label.includeDescription"));
pointGenAttribRadioButton.setText(Language.I18N.getString("pref.kmlexport.balloon.label.genAttrib"));
pointFileRadioButton.setText(Language.I18N.getString("pref.kmlexport.balloon.label.file"));
pointGenAttribAndFileRadioButton.setText(Language.I18N.getString("pref.kmlexport.balloon.label.genAttribAndFile"));
pointBrowseButton.setText(Language.I18N.getString("common.button.browse"));
// pointContentInSeparateFile.setText(Language.I18N.getString("pref.kmlexport.balloon.label.contentInSeparateFile"));
// pointWarningLabel.setText(Language.I18N.getString("pref.kmlexport.balloon.label.warningLabel"));
((TitledBorder)curveContentSourcePanel.getBorder()).setTitle(Language.I18N.getString("pref.kmlexport.balloon.contentSourceForCurve.border"));
curveIncludeDescription.setText(Language.I18N.getString("pref.kmlexport.balloon.label.includeDescription"));
curveGenAttribRadioButton.setText(Language.I18N.getString("pref.kmlexport.balloon.label.genAttrib"));
curveFileRadioButton.setText(Language.I18N.getString("pref.kmlexport.balloon.label.file"));
curveGenAttribAndFileRadioButton.setText(Language.I18N.getString("pref.kmlexport.balloon.label.genAttribAndFile"));
curveBrowseButton.setText(Language.I18N.getString("common.button.browse"));
// curveContentInSeparateFile.setText(Language.I18N.getString("pref.kmlexport.balloon.label.contentInSeparateFile"));
// curveWarningLabel.setText(Language.I18N.getString("pref.kmlexport.balloon.label.warningLabel"));
warningLabel1.setText(Language.I18N.getString("pref.kmlexport.balloon.label.settingsApplyFrom1"));
warningLabel2.setText(Language.I18N.getString("pref.kmlexport.balloon.label.settingsApplyFrom2"));
}
public static void main(String[] args) {
Graphics g = new BufferedImage(9, 9, 9).getGraphics();
BrokenBorder broken = new BrokenBorder();
TitledBorder titled = new TitledBorder(broken, broken.getClass().getName());
Insets insets = (Insets) broken.getBorderInsets(broken).clone();
titled.getBorderInsets(broken);
broken.validate(insets);
for (int i = 0; i < 10; i++) {
titled.paintBorder(broken, g, 0, 0, i, i);
broken.validate(insets);
titled.getBaseline(broken, i, i);
broken.validate(insets);
}
}
private void create() {
setLayout(new BorderLayout());
JPanel middlePanel = new JPanel();
middlePanel.setBorder(new TitledBorder(new EtchedBorder(), title));
display = new JTextArea(10, 48);
display.getDocument().putProperty(DefaultEditorKit.EndOfLineStringProperty, "\n");
display.setEditable(false);
display.setForeground(fontColor);
JScrollPane scroll = new JBScrollPane(display);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
middlePanel.add(scroll);
add(middlePanel, BorderLayout.CENTER);
JPanel progressPanel = new JPanel();
progressPanel.setLayout(new BoxLayout(progressPanel, BoxLayout.Y_AXIS));
}
/**
* Updates the condition configuration panel.
*
* @param node The actively selected node.
*/
private void updateDefineConditionPanel(final JCriteriumTreeNode node) {
final Component component = node.getCriterium().getCriteriumPanel();
m_defineConditionPanel.removeAll();
m_defineConditionPanel.setBorder(null);
if (component == null) {
final JPanel defaultPanel = new JPanel(new BorderLayout());
defaultPanel.setBorder(new TitledBorder("Define Condition"));
m_defineConditionPanel.add(defaultPanel, BorderLayout.CENTER);
} else {
m_defineConditionPanel.add(component);
}
m_defineConditionPanel.updateUI();
}
private void anhadeTextAreaParaTextoAnalizado(Container contenedor) {
areaDeTextoAAnalizar = new JTextArea();
areaDeTextoAAnalizar.setLineWrap(true);
areaDeTextoAAnalizar.setWrapStyleWord(true);
areaDeTextoAAnalizar.setColumns(40);
areaDeTextoAAnalizar.invalidate();
JScrollPane scroll = new JScrollPane(areaDeTextoAAnalizar);
scroll.setBorder(new TitledBorder("Escribe o copia aqu� un texto"));
GridBagConstraints constraints = new GridBagConstraints();
constraints.gridx = 0;
constraints.gridy = 1;
constraints.gridwidth = 4;
constraints.gridheight = 1;
constraints.weightx = 1.0;
constraints.weighty = 1.0;
constraints.fill = GridBagConstraints.BOTH;
contenedor.add(scroll, constraints);
}
/**
* @return Message components.
*/
private Component createMessageComponents() {
JPanel panel = new JPanel(new GridLayout(1, 0));
panel.setBorder(BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(
Version.HIGHLIGHT ? Color.RED : null,
Version.HIGHLIGHT ? Color.RED : null),
GT._T("Message"),
TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION));
if (Version.HIGHLIGHT) {
panel.setBackground(Color.RED);
}
HTMLPane textMessage = HTMLPane.createHTMLPane(Version.MESSAGE);
JScrollPane scrollMessage = new JScrollPane(textMessage);
scrollMessage.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
panel.add(scrollMessage);
return panel;
}
protected TitledBorder getObject() {
return new TitledBorder(
new EmptyBorder(1, 2, 3, 4),
"TITLE",
TitledBorder.CENTER,
TitledBorder.ABOVE_TOP,
new Font("Arial", Font.ITALIC, 12),
Color.RED);
}
protected Border createInstanceImpl() {
Font font = titleFont == null || titleFont.isUIResource() ?
null : titleFont.createInstance();
Color color = titleColor == null || titleColor.isUIResource() ?
null : titleColor.createInstance();
return new TitledBorder(border == null ? null : border.createInstance(),
title, titleJustification, titlePosition, font, color);
}
public MemoryMonitor() {
setLayout(new BorderLayout());
setBorder(new TitledBorder(new EtchedBorder(), "Memory Monitor"));
add(surf = new Surface());
controls = new JPanel();
controls.setPreferredSize(new Dimension(135,80));
Font font = new Font("serif", Font.PLAIN, 10);
JLabel label = new JLabel("Sample Rate");
label.setFont(font);
label.setForeground(Color.red);
controls.add(label);
tf = new JTextField("1000");
tf.setPreferredSize(new Dimension(45,20));
controls.add(tf);
controls.add(label = new JLabel("ms"));
label.setFont(font);
label.setForeground(Color.red);
controls.add(dateStampCB);
dateStampCB.setFont(font);
addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
removeAll();
if ((doControls = !doControls)) {
surf.stop();
add(controls);
} else {
try {
surf.sleepAmount = Long.parseLong(tf.getText().trim());
} catch (Exception ex) {}
surf.start();
add(surf);
}
validate();
repaint();
}
});
}
public Example_11_View_NotesPanel() {
super();
setBorder(new TitledBorder(null, "Notes", TitledBorder.LEADING, TitledBorder.TOP, null, null));
setLayout(new BorderLayout(0, 0));
notesTextArea = new StrictThreadingJTextArea();
JScrollPane scrollPane = new JScrollPane(notesTextArea);
add(scrollPane, BorderLayout.CENTER);
dirtyFlagLabel = new StrictThreadingJLabel("");
add(dirtyFlagLabel, BorderLayout.EAST);
}
private JPanel setupRiverPanel() {
GridBagLayout layout = new GridBagLayout();
GridBagConstraints constraints = setupConstraints();
JPanel panel = new JPanel(layout);
// Row 1, Column 1.
constraints.gridx = 0;
constraints.gridy = 0;
constraints.gridwidth = 1;
JLabel riverChanceLabel = new JLabel(Messages.getString("RandomMapDialog.labProbRiver"));
panel.add(riverChanceLabel, constraints);
// Row 1, Columns 2-4.
constraints.gridx++;
constraints.weightx = 1;
constraints.weighty = 1;
riverChanceField.setRequired(true);
riverChanceField.setSelectAllTextOnGotFocus(true);
riverChanceField.addVerifier(new VerifyInRange(0, 100, true));
riverChanceField.setToolTipText(Messages.getString("RandomMapDialog.riverChanceField.toolTip"));
riverChanceField.setName(riverChanceLabel.getText());
panel.add(riverChanceField, constraints);
panel.setBorder(new TitledBorder(new LineBorder(Color.black, 2),
Messages.getString("RandomMapDialog.borderRiver")));
return panel;
}
public void init() {
Font font = new Font("Dialog", Font.PLAIN, 12); // NON-NLS: the font name
TitledBorder border = BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(),
"Panel Title", // NON-NLS: the title of the border
TitledBorder.DEFAULT_JUSTIFICATION,
TitledBorder.DEFAULT_POSITION,
font);
JPanel panel = new JPanel();
panel.setBorder(border);
getContentPane().add(panel);
}
private void showCredits() {
credits = new JLabel(
getString(
"TableDemo.credits",
"<html><p align=\"center\">Academy Award data<br>courtesy of Howard Katz</p></html>"));
credits.setFont(UIManager.getFont("Table.font").deriveFont(24f));
credits.setHorizontalAlignment(JLabel.CENTER);
credits.setBorder(new CompoundBorder(new TitledBorder(""),
new EmptyBorder(20, 20, 20, 20)));
dataPanel.showMessageLayer(credits, .75f);
}
/**
* Check behaviour of method TitledBorder.getTitleFont()
*/
private static void checkTitleFont() {
TitledBorder titledBorder = new TitledBorder(new EmptyBorder(1, 1, 1, 1));
Font defaultFont = UIManager.getLookAndFeelDefaults().getFont("TitledBorder.font");
Font titledBorderFont = titledBorder.getTitleFont();
// check default configuration
if (defaultFont == null) {
if (titledBorderFont == null) {
return;
}
else {
throw new RuntimeException("TitledBorder default font should be null");
}
}
if (!defaultFont.equals(titledBorderFont)) {
throw new RuntimeException("L&F default font " + defaultFont.toString()
+ " differs from TitledBorder font " + titledBorderFont.toString());
}
// title font is explicitly specified
Font font = new Font("Dialog", Font.PLAIN, 10);
titledBorder.setTitleFont(font);
if (!font.equals(titledBorder.getTitleFont())) {
throw new RuntimeException("TitledBorder font should be " + font.toString());
}
// title Font is unspecified
titledBorder.setTitleFont(null);
if (!defaultFont.equals(titledBorder.getTitleFont())) {
throw new RuntimeException("L&F default font " + defaultFont.toString()
+ " differs from TitledBorder font " + titledBorderFont.toString());
}
}
private JPanel getChooseFromPanel() {
final JPanel thePanel = new JPanel();
thePanel.setLayout( new GridBagLayout() );
final GridBagConstraints theCons = DomGui.getGridBagConstraints( 2 );
JScrollPane theChooseFromScroller = new JScrollPane(getChooseFromList(), JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
theChooseFromScroller.setBorder(new TitledBorder( "Choose from these" ));
theChooseFromScroller.setPreferredSize(new Dimension(150,200));
thePanel.add(theChooseFromScroller, theCons);
return thePanel;
}
public static TitledBorder createTitledBorder(Border border,
String title,
int titleJustification,
int titlePosition,
Font titleFont,
Color titleColor) {
return IdeBorderFactory.createTitledBorder(title, false, new Insets(TITLED_BORDER_TOP_INSET,0,0,0));
}
CreateLinkOptionPanel(TagType linkType, List<ExtentTag> argumentCandidates) throws MaeDBException {
super();
List<ArgumentType> argTypes = new ArrayList<>(linkType.getArgumentTypes());
setLayout(new GridLayout(1, argTypes.size()));
argumentsMap = new LinkedHashMap<>();
int typeNum = 0;
for (final ArgumentType type : argTypes) {
final JComboBox<ExtentTag> candidates = new JComboBox<>();
candidates.setFont(MaeStrings.UNICODE_FONT);
candidates.addItem(null);
for (ExtentTag tag : argumentCandidates) {
candidates.addItem(tag);
}
candidates.addActionListener(event ->
argumentsMap.put(type, (ExtentTag) candidates.getSelectedItem()));
candidates.setSelectedIndex((typeNum++ % argumentCandidates.size()) + 1);
JPanel comboPanel = new JPanel();
comboPanel.add(candidates);
TitledBorder titledBorder = BorderFactory.createTitledBorder(
etched, type.getName());
titledBorder.setTitleJustification(TitledBorder.CENTER);
comboPanel.setBorder(titledBorder);
add(comboPanel);
}
}
public static void main(String[] args) throws Exception {
for (UIManager.LookAndFeelInfo lookAndFeel : UIManager.getInstalledLookAndFeels()) {
for (Object[] defaultTitlePosition : DEFAULT_TITLE_POSITIONS) {
if (defaultTitlePosition[0].equals(lookAndFeel.getName())) {
UIManager.setLookAndFeel(lookAndFeel.getClassName());
final int expectedPosition = (Integer) defaultTitlePosition[1];
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
List<TitledBorder> borders = new ArrayList<>();
borders.add(BorderFactory.createTitledBorder(new EmptyBorder(0, 0, 0, 0), "Title"));
try {
Method getPositionMethod = TitledBorder.class.getDeclaredMethod("getPosition");
getPositionMethod.setAccessible(true);
for (TitledBorder border : borders) {
int position = (Integer) getPositionMethod.invoke(border);
if (position != expectedPosition) {
throw new RuntimeException("Invalid title position");
}
}
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
});
System.out.println("Test passed for LookAndFeel " + lookAndFeel.getName());
}
}
}
}