001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2008 Sun Microsystems, Inc. 025 * Portions Copyright 2014 ForgeRock AS 026 */ 027 028package org.opends.guitools.controlpanel.ui.components; 029 030import java.awt.GridBagConstraints; 031import java.awt.GridBagLayout; 032 033import javax.swing.JLabel; 034import javax.swing.JPanel; 035 036import org.opends.guitools.controlpanel.util.Utilities; 037import org.forgerock.i18n.LocalizableMessage; 038import org.forgerock.i18n.LocalizableMessageBuilder; 039 040/** 041 * This is a panel containing two labels with different fonts. It is used 042 * for instance in the index panel. The label on the left contains the type 043 * of object and the label on the right, details about the object. 044 * 045 */ 046public class TitlePanel extends JPanel 047{ 048 private static final long serialVersionUID = -5164867192115208627L; 049 private JLabel lTitle; 050 private JLabel lDetails; 051 052 private LocalizableMessage title; 053 private LocalizableMessage details; 054 055 /** 056 * Constructor of the panel. 057 * @param title the title of the panel. 058 * @param details the details of the panel. 059 */ 060 public TitlePanel(LocalizableMessage title, LocalizableMessage details) 061 { 062 super(new GridBagLayout()); 063 setOpaque(false); 064 GridBagConstraints gbc = new GridBagConstraints(); 065 LocalizableMessageBuilder mb = new LocalizableMessageBuilder(); 066 mb.append(title); 067 mb.append(" - "); 068 lTitle = Utilities.createTitleLabel(mb.toMessage()); 069 lDetails = Utilities.createDefaultLabel(details); 070 gbc.fill = GridBagConstraints.NONE; 071 gbc.anchor = GridBagConstraints.SOUTHWEST; 072 gbc.gridx = 0; 073 gbc.gridy = 0; 074 add(lTitle, gbc); 075 gbc.gridx ++; 076 add(lDetails, gbc); 077 this.title = title; 078 this.details = details; 079 } 080 081 /** 082 * Sets the title of this panel. 083 * @param title the title of this panel. 084 */ 085 public void setTitle(LocalizableMessage title) 086 { 087 lTitle.setText(title+" - "); 088 this.title = title; 089 } 090 091 /** 092 * Sets the details of this panel. 093 * @param details the details of this panel. 094 */ 095 public void setDetails(LocalizableMessage details) 096 { 097 lDetails.setText(details.toString()); 098 this.details = details; 099 } 100 101 /** 102 * Returns the title of this panel. 103 * @return the title of this panel. 104 */ 105 public LocalizableMessage getTitle() 106 { 107 return title; 108 } 109 110 /** 111 * Returns the details of this panel. 112 * @return the details of this panel. 113 */ 114 public LocalizableMessage getDetails() 115 { 116 return details; 117 } 118}