当前位置: 首页>>代码示例>>Java>>正文


Java JLabel.getPreferredSize方法代码示例

本文整理汇总了Java中javax.swing.JLabel.getPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:Java JLabel.getPreferredSize方法的具体用法?Java JLabel.getPreferredSize怎么用?Java JLabel.getPreferredSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JLabel的用法示例。


在下文中一共展示了JLabel.getPreferredSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMinimumSize

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Returns the minimum dimensions this border requires
 * in order to fully display the border and title.
 * @param c the component where this border will be drawn
 * @return the {@code Dimension} object
 */
public Dimension getMinimumSize(Component c) {
    Insets insets = getBorderInsets(c);
    Dimension minSize = new Dimension(insets.right+insets.left,
                                      insets.top+insets.bottom);
    String title = getTitle();
    if ((title != null) && !title.isEmpty()) {
        JLabel label = getLabel(c);
        Dimension size = label.getPreferredSize();

        int position = getPosition();
        if ((position != ABOVE_TOP) && (position != BELOW_BOTTOM)) {
            minSize.width += size.width;
        }
        else if (minSize.width < size.width) {
            minSize.width += size.width;
        }
    }
    return minSize;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:TitledBorder.java

示例2: setup

import javax.swing.JLabel; //导入方法依赖的package包/类
private void setup()
{
	JLabel heading = new JLabel("<html><h2>Downloading Items...");

	itemCount = new JLabel("Downloading 0 of " + itemTotal + " Items");
	itemName = new JLabel();

	itemName.setForeground(Color.GRAY);

	final int height1 = heading.getPreferredSize().height;
	final int height2 = itemCount.getPreferredSize().height;

	final int[] rows = new int[]{height1, height2, height2, TableLayout.FILL};
	final int[] cols = new int[]{TableLayout.FILL};

	setLayout(new TableLayout(rows, cols, 5, 5));
	setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

	add(heading, new Rectangle(0, 0, 1, 1));

	add(itemCount, new Rectangle(0, 1, 1, 1));
	add(itemName, new Rectangle(0, 2, 1, 1));
}
 
开发者ID:equella,项目名称:Equella,代码行数:24,代码来源:DownloadPage.java

示例3: setup

import javax.swing.JLabel; //导入方法依赖的package包/类
private void setup()
{
	JLabel heading = new JLabel("<html><h2>Content Review");
	JLabel help1 = new JLabel("<html><b>The following content was found for upload:");

	JLabel help2 = new JLabel("<html><b>Select 'Next' to upload the content.");
	items = new JLabel();

	final int height1 = heading.getPreferredSize().height;
	final int height2 = help1.getPreferredSize().height;
	final int width = 10;

	final int[] rows = new int[]{height1, height2, height2, height2, height2, TableLayout.FILL};
	final int[] cols = new int[]{width, TableLayout.FILL};

	setLayout(new TableLayout(rows, cols, 5, 5));
	setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

	add(heading, new Rectangle(0, 0, 2, 1));
	add(help1, new Rectangle(0, 1, 2, 1));

	add(items, new Rectangle(1, 2, 1, 1));

	add(help2, new Rectangle(0, 4, 2, 1));
}
 
开发者ID:equella,项目名称:Equella,代码行数:26,代码来源:ReviewPage.java

示例4: createNiceMessages

import javax.swing.JLabel; //导入方法依赖的package包/类
private JComponent createNiceMessages()
{
	JLabel heading = new JLabel("<html><font size=+1>" + title + "</font></html>");

	JTextArea body = new JTextArea(message);
	body.setHighlighter(null);
	body.setEditable(false);
	body.setFocusable(false);
	body.setOpaque(false);
	body.setBorder(null);
	body.setLineWrap(true);
	body.setWrapStyleWord(true);
	body.setFont(heading.getFont());

	final int[] rows = new int[]{heading.getPreferredSize().height, TableLayout.FILL};
	final int[] columns = new int[]{TableLayout.FILL};

	TableLayout layout = new TableLayout(rows, columns, 5, 5);
	JPanel all = new JPanel(layout);
	all.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

	all.add(heading, new Rectangle(0, 0, 1, 1));
	all.add(body, new Rectangle(0, 1, 1, 1));

	return all;
}
 
开发者ID:equella,项目名称:Equella,代码行数:27,代码来源:ExceptionDialog.java

示例5: getComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
public Component getComponent() {
    if (chart == null) {
      label = new JLabel();
      srcOp = fileName == null || fileName.trim().length() == 0
            ? null : Op.load(fileName);
      if (srcOp != null) {
        label.setIcon(new OpIcon(srcOp));
      }
/*
      try {
        Image image = GameModule.getGameModule().getDataArchive().getCachedImage(fileName);
        ImageIcon icon = image == null ? null : new ImageIcon(image);
        label.setIcon(icon);
      }
      catch (IOException ex) {
        label.setText("Image " + fileName + " not found");
      }
*/
      final Dimension d = label.getPreferredSize();
      if (d.width > 300 || d.height > 300) {
        final JScrollPane scroll = new AdjustableSpeedScrollPane(label);
        scroll.getViewport().setPreferredSize(label.getPreferredSize());
        scroll.getViewport().setAlignmentY(0.0F);
        chart = scroll;
      }
      else {
        chart = label;
      }
    }
    return chart;
  }
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:32,代码来源:Chart.java

示例6: preferredHeaderWidth

import javax.swing.JLabel; //导入方法依赖的package包/类
private int preferredHeaderWidth() {
    final JLabel longestRowLabel = new JLabel("1.1.1");
    final JTableHeader header = table.getTableHeader();
    longestRowLabel.setBorder(header.getBorder());
    longestRowLabel.setHorizontalAlignment(SwingConstants.CENTER);
    longestRowLabel.setFont(header.getFont());
    return longestRowLabel.getPreferredSize().width;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:9,代码来源:TableRowHeader.java

示例7: Inicie

import javax.swing.JLabel; //导入方法依赖的package包/类
void Inicie(ParteAjuda sel) {
        this.setTitle(sel.getTitulo());
        if (sel.getByteImage() != null || sel.getHtml() != null) {//.isEmpty()) {
            Pan.removeAll();
            int H = 0;
            int W = 0;
            if (!sel.getHtml().isEmpty()) {
                JLabel htmLbl = new JLabel();
                htmLbl.setText(sel.getHtml());
                htmLbl.repaint();
                Dimension d = htmLbl.getPreferredSize();
                int x = (getPreferredSize().width - d.width) / 2;
                if (getPreferredSize().width < d.width) {
                    x = 0;
                }
//                int y = (getPreferredSize().height - d.height - subPan.getPreferredSize().height) / 2;
//                if (getPreferredSize().height - subPan.getPreferredSize().height < d.height) {
//                    y = 0;
//                }
                htmLbl.setBounds(x, 0, d.width, d.height);
                //Pan.setBackground(Color.yellow);
                Pan.add(htmLbl);
                H = d.height + 10;
                W = d.width;
            }
            if (sel.getByteImage() != null) {
                ImageIcon img = new ImageIcon(sel.getByteImage());
                JLabel picLabel = new JLabel(img);
                W = W > img.getIconWidth() ? W : img.getIconWidth();
                picLabel.setBounds(0, H, img.getIconWidth(), img.getIconHeight());
                picLabel.setPreferredSize(new Dimension(img.getIconWidth(), img.getIconHeight()));
                H += img.getIconHeight();
                Pan.setPreferredSize(new Dimension(W, H));
                Pan.add(picLabel);
            }
            Pan.revalidate();
            Pan.repaint();
        }
    }
 
开发者ID:chcandido,项目名称:brModelo,代码行数:40,代码来源:FrameSobre.java

示例8: setupGui

import javax.swing.JLabel; //导入方法依赖的package包/类
private void setupGui()
{
	JLabel typeLabel = new JLabel(CurrentLocale.get("com.tle.admin.schema.manager.transformdialog.name")); //$NON-NLS-1$
	JLabel fileLabel = new JLabel(CurrentLocale.get("com.tle.admin.schema.manager.transformdialog.xsl")); //$NON-NLS-1$

	schemaType = new JComboBox();
	schemaType.setEditable(true);
	fileSelector = new FileSelector(CurrentLocale.get("com.tle.admin.schema.manager.transformdialog.browse")); //$NON-NLS-1$
	fileSelector.setFileFilter(FileFilterAdapter.XSLT());

	ok = new JButton(CurrentLocale.get("com.tle.admin.ok")); //$NON-NLS-1$
	JButton cancel = new JButton(CurrentLocale.get("com.tle.admin.cancel")); //$NON-NLS-1$

	ok.addActionListener(this);
	cancel.addActionListener(this);

	final int height1 = typeLabel.getPreferredSize().height;
	final int height2 = schemaType.getPreferredSize().height;
	final int height3 = fileSelector.getPreferredSize().height;
	final int height4 = ok.getPreferredSize().height;
	final int width1 = cancel.getPreferredSize().width;

	final int[] rows = {height1, height2, height1, height3, height4,};
	final int[] cols = {TableLayout.FILL, width1, width1,};

	all = new JPanel(new TableLayout(rows, cols));
	all.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

	all.add(typeLabel, new Rectangle(0, 0, 3, 1));
	all.add(schemaType, new Rectangle(0, 1, 3, 1));
	all.add(fileLabel, new Rectangle(0, 2, 3, 1));
	all.add(fileSelector, new Rectangle(0, 3, 3, 1));
	all.add(ok, new Rectangle(1, 4, 1, 1));
	all.add(cancel, new Rectangle(2, 4, 1, 1));
}
 
开发者ID:equella,项目名称:Equella,代码行数:36,代码来源:TransformDialog.java

示例9: getBaseline

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Returns the baseline.
 *
 * @throws NullPointerException {@inheritDoc}
 * @throws IllegalArgumentException {@inheritDoc}
 * @see javax.swing.JComponent#getBaseline(int, int)
 * @since 1.6
 */
public int getBaseline(Component c, int width, int height) {
    if (c == null) {
        throw new NullPointerException("Must supply non-null component");
    }
    if (width < 0) {
        throw new IllegalArgumentException("Width must be >= 0");
    }
    if (height < 0) {
        throw new IllegalArgumentException("Height must be >= 0");
    }
    Border border = getBorder();
    String title = getTitle();
    if ((title != null) && !title.isEmpty()) {
        int edge = (border instanceof TitledBorder) ? 0 : EDGE_SPACING;
        JLabel label = getLabel(c);
        Dimension size = label.getPreferredSize();
        Insets insets = getBorderInsets(border, c, new Insets(0, 0, 0, 0));

        int baseline = label.getBaseline(size.width, size.height);
        switch (getPosition()) {
            case ABOVE_TOP:
                return baseline;
            case TOP:
                insets.top = edge + (insets.top - size.height) / 2;
                return (insets.top < edge)
                        ? baseline
                        : baseline + insets.top;
            case BELOW_TOP:
                return baseline + insets.top + edge;
            case ABOVE_BOTTOM:
                return baseline + height - size.height - insets.bottom - edge;
            case BOTTOM:
                insets.bottom = edge + (insets.bottom - size.height) / 2;
                return (insets.bottom < edge)
                        ? baseline + height - size.height
                        : baseline + height - size.height + insets.bottom;
            case BELOW_BOTTOM:
                return baseline + height - size.height;
        }
    }
    return -1;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:51,代码来源:TitledBorder.java

示例10: getBorderInsets

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Reinitialize the insets parameter with this Border's current Insets.
 * @param c the component for which this border insets value applies
 * @param insets the object to be reinitialized
 */
public Insets getBorderInsets(Component c, Insets insets) {
    Border border = getBorder();
    insets = getBorderInsets(border, c, insets);

    String title = getTitle();
    if ((title != null) && !title.isEmpty()) {
        int edge = (border instanceof TitledBorder) ? 0 : EDGE_SPACING;
        JLabel label = getLabel(c);
        Dimension size = label.getPreferredSize();

        switch (getPosition()) {
            case ABOVE_TOP:
                insets.top += size.height - edge;
                break;
            case TOP: {
                if (insets.top < size.height) {
                    insets.top = size.height - edge;
                }
                break;
            }
            case BELOW_TOP:
                insets.top += size.height;
                break;
            case ABOVE_BOTTOM:
                insets.bottom += size.height;
                break;
            case BOTTOM: {
                if (insets.bottom < size.height) {
                    insets.bottom = size.height - edge;
                }
                break;
            }
            case BELOW_BOTTOM:
                insets.bottom += size.height - edge;
                break;
        }
        insets.top += edge + TEXT_SPACING;
        insets.left += edge + TEXT_SPACING;
        insets.right += edge + TEXT_SPACING;
        insets.bottom += edge + TEXT_SPACING;
    }
    return insets;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:49,代码来源:TitledBorder.java

示例11: buildDetail

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Builds the details panel for the given FoundingFather.
 *
 * @param father a FoundingFather
 * @param panel the detail panel to build
 */
public void buildDetail(FoundingFather father, JPanel panel) {
    panel.setLayout(new MigLayout("wrap 2, fillx, gapx 20", "", ""));

    String name = Messages.getName(father);
    String type = Messages.message(father.getTypeKey());
    String text = name + " (" + type + ")";
    JLabel header = new JLabel(text);
    header.setFont(FontLibrary.createCompatibleFont(text,
        FontLibrary.FontType.HEADER, FontLibrary.FontSize.SMALL));

    Image image = ImageLibrary.getFoundingFatherImage(father, false);
    JLabel label = new JLabel(new ImageIcon(image));

    StringTemplate template = StringTemplate.label("")
        .add(Messages.descriptionKey(father))
        .addName("\n\n[")
        .add(father.getId() + ".birthAndDeath")
        .addName("] ")
        .add(father.getId() + ".text");
    final Turn turn = getMyPlayer().getElectionTurns().get(name);
    if (turn != null) {
        template
            .addName("\n\n")
            .add("report.continentalCongress.elected")
            .addName(" ")
            .addStringTemplate(turn.getLabel());
    }

    panel.add(header, "span, align center, wrap 40");
    panel.add(label, "top");
    JTextArea description = Utility.localizedTextArea(template, 20);
    panel.add(description, "top, growx");

    Dimension hSize = header.getPreferredSize(),
        lSize = label.getPreferredSize(),
        dSize = description.getPreferredSize(), size = new Dimension();
    size.setSize(lSize.getWidth() + dSize.getWidth() + 20,
        hSize.getHeight() + lSize.getHeight() + 10);
    panel.setPreferredSize(size);            
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:47,代码来源:FatherDetailPanel.java

示例12: ServerPage

import javax.swing.JLabel; //导入方法依赖的package包/类
public ServerPage(SharedData data)
{
	super(data);

	errorLabel = new JLabel();
	errorIcon = Icons.getErrorIcon();

	JLabel heading = new JLabel("<html><h2>Server Connection");
	JLabel help = new JLabel("<html><b>Please enter the server details:");
	JLabel serverLabel = new JLabel("Server URL");
	JLabel usernameLabel = new JLabel("Username");
	JLabel passwordLabel = new JLabel("Password");

	server = new JTextField("http://");
	username = new JTextField();
	password = new JPasswordField();

	final int width = serverLabel.getPreferredSize().width;
	final int height1 = heading.getPreferredSize().height;
	final int height2 = help.getPreferredSize().height;
	final int height3 = server.getPreferredSize().height;

	final int[] rows = new int[]{height1, height2, height3, height3, height3, height3, height3, TableLayout.FILL};
	final int[] cols = new int[]{width, TableLayout.FILL};

	setLayout(new TableLayout(rows, cols, 5, 5));
	setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

	add(heading, new Rectangle(0, 0, 2, 1));
	add(help, new Rectangle(0, 1, 2, 1));

	add(serverLabel, new Rectangle(0, 2, 1, 1));
	add(server, new Rectangle(1, 2, 1, 1));

	add(usernameLabel, new Rectangle(0, 3, 1, 1));
	add(username, new Rectangle(1, 3, 1, 1));

	add(passwordLabel, new Rectangle(0, 4, 1, 1));
	add(password, new Rectangle(1, 4, 1, 1));

	add(errorLabel, new Rectangle(0, 6, 2, 2));
}
 
开发者ID:equella,项目名称:Equella,代码行数:43,代码来源:ServerPage.java

示例13: init

import javax.swing.JLabel; //导入方法依赖的package包/类
@Override
public void init(Component parent)
{
	JLabel nameLabel = new JLabel(CurrentLocale.get("com.tle.admin.powersearch.detailstab.searchname")); //$NON-NLS-1$
	JLabel descriptionLabel = new JLabel(CurrentLocale.get("com.tle.admin.powersearch.detailstab.desc")); //$NON-NLS-1$
	JLabel ownerLabel = new JLabel(CurrentLocale.get("com.tle.admin.powersearch.detailstab.owner")); //$NON-NLS-1$

	JLabel schemaLabel = new JLabel(CurrentLocale.get("com.tle.admin.powersearch.detailstab.selectschema")); //$NON-NLS-1$
	JLabel itemdefLabel = new JLabel(CurrentLocale.get("com.tle.admin.powersearch.detailstab.selectcollections")); //$NON-NLS-1$

	descriptionLabel.setVerticalAlignment(SwingConstants.TOP);

	name = new I18nTextField(BundleCache.getLanguages());
	description = new I18nTextArea(BundleCache.getLanguages());

	owner = new SingleUserSelector(clientService.getService(RemoteUserService.class));

	itemdefs = new JShuffleBox<NameValue>();
	itemdefs.setAllowDuplicates(false);

	schemaList = new JComboBox();
	try
	{
		List<BaseEntityLabel> schemas = clientService.getService(RemoteSchemaService.class).listAll();
		List<NameValue> nameValues = BundleCache.getNameValues(schemas);
		Collections.sort(nameValues, Format.NAME_VALUE_COMPARATOR);
		AppletGuiUtils.addItemsToJCombo(schemaList, nameValues);
	}
	catch( RuntimeApplicationException ex )
	{
		LOGGER.error("Could not enumerate schemas", ex); //$NON-NLS-1$
		JOptionPane.showMessageDialog(parent, CurrentLocale.get("com.tle.admin.powersearch.detailstab.error")); //$NON-NLS-1$
	}

	schemaList.setSelectedIndex(-1);
	schemaList.addActionListener(this);
	lastSelectedIndex = -1;

	final int height1 = name.getPreferredSize().height;
	final int ownerHeight = owner.getPreferredSize().height;
	final int width1 = schemaLabel.getPreferredSize().width;

	final int[] rows = {height1, height1 * 3, ownerHeight, 20, height1, height1, TableLayout.DOUBLE_FILL,
			TableLayout.FILL};
	final int[] cols = {width1, TableLayout.DOUBLE_FILL, TableLayout.FILL,};

	setLayout(new TableLayout(rows, cols));
	setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

	add(nameLabel, new Rectangle(0, 0, 1, 1));
	add(name, new Rectangle(1, 0, 1, 1));

	add(descriptionLabel, new Rectangle(0, 1, 1, 1));
	add(description, new Rectangle(1, 1, 1, 1));

	add(ownerLabel, new Rectangle(0, 2, 1, 1));
	add(owner, new Rectangle(1, 2, 1, 1));

	add(schemaLabel, new Rectangle(0, 4, 1, 1));
	add(schemaList, new Rectangle(1, 4, 1, 1));

	add(itemdefLabel, new Rectangle(0, 5, 2, 1));
	add(itemdefs, new Rectangle(0, 6, 2, 1));

	// Make sure things are readonly.
	if( state.isReadonly() )
	{
		name.setEnabled(false);
		description.setEnabled(false);
		owner.setEnabled(false);
		schemaList.setEnabled(false);
		itemdefs.setEnabled(false);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:75,代码来源:DetailsTab.java

示例14: setup

import javax.swing.JLabel; //导入方法依赖的package包/类
private void setup()
{
	JLabel heading = new JLabel("<html><h2>Item Selection");
	JLabel typeLabel = new JLabel("Type");
	JLabel dirLabel = new JLabel("Source");
	JLabel xsltLabel = new JLabel("XSLT");
	JLabel requiredLabel = new JLabel("<html><b>Required:");
	JLabel optionalLabel = new JLabel("<html><b>Optional:");

	xsltTextField = new JTextField();
	dirTextField = new JTextField();

	xsltButton = new JButton("...");
	dirButton = new JButton("...");

	xsltTextField.setEditable(false);
	dirTextField.setEditable(true);

	xsltButton.addActionListener(this);
	dirButton.addActionListener(this);

	typeComboBox = new JComboBox();
	typeComboBox.setEnabled(false);

	dirChooser = new JFileChooser();
	dirChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

	xsltChooser = new JFileChooser();
	xsltChooser.setFileFilter(new XSLTFileFilter());

	final int height1 = typeComboBox.getPreferredSize().height;
	final int height2 = xsltTextField.getPreferredSize().height;
	final int height3 = optionalLabel.getPreferredSize().height;
	final int height4 = heading.getPreferredSize().height;

	final int width2 = xsltButton.getPreferredSize().width;
	final int width3 = dirLabel.getPreferredSize().width + 5;

	final int[] rows = new int[]{height4, height3, height1, height2, height3, height2};
	final int[] cols = new int[]{width3, TableLayout.FILL, width2};

	setLayout(new TableLayout(rows, cols, 5, 0));
	setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

	add(heading, new Rectangle(0, 0, 2, 1));

	add(requiredLabel, new Rectangle(0, 1, 3, 1));

	add(typeLabel, new Rectangle(0, 2, 1, 1));
	add(typeComboBox, new Rectangle(1, 2, 2, 1));

	add(dirLabel, new Rectangle(0, 3, 1, 1));
	add(dirTextField, new Rectangle(1, 3, 1, 1));
	add(dirButton, new Rectangle(2, 3, 1, 1));

	add(optionalLabel, new Rectangle(0, 4, 3, 1));

	add(xsltLabel, new Rectangle(0, 5, 1, 1));
	add(xsltTextField, new Rectangle(1, 5, 1, 1));
	add(xsltButton, new Rectangle(2, 5, 1, 1));
}
 
开发者ID:equella,项目名称:Equella,代码行数:62,代码来源:ImportPage.java

示例15: setupGUI

import javax.swing.JLabel; //导入方法依赖的package包/类
private void setupGUI()
{
	JLabel nameLabel = new JLabel(CurrentLocale.get("com.tle.admin.schema.manager.detailstab.name"));
	JLabel descriptionLabel = new JLabel(CurrentLocale.get("com.tle.admin.schema.manager.detailstab.desc"));
	JLabel ownerLabel = new JLabel(CurrentLocale.get("com.tle.admin.schema.manager.detailstab.owner"));
	JLabel nameXpathLabel = new JLabel(CurrentLocale.get("com.tle.admin.schema.manager.detailstab.path"));
	JLabel descriptionXpathLabel = new JLabel(CurrentLocale.get("com.tle.admin.schema.manager.detailstab.descpath"));

	descriptionLabel.setVerticalAlignment(SwingConstants.TOP);

	name = new I18nTextField(BundleCache.getLanguages());
	nameLabel.setLabelFor(name);

	description = new I18nTextArea(BundleCache.getLanguages());
	descriptionLabel.setLabelFor(description);

	owner = new SingleUserSelector(clientService.getService(RemoteUserService.class));
	ownerLabel.setLabelFor(owner);

	nameXpathChooser = new SingleTargetChooser(model, null);
	descriptionXpathChooser = new SingleTargetChooser(model, null);
	nameXpathLabel.setLabelFor(nameXpathChooser);
	descriptionXpathLabel.setLabelFor(descriptionXpathChooser);

	final int height1 = descriptionXpathChooser.getPreferredSize().height;
	final int ownerHeight = owner.getPreferredSize().height;
	final int width1 = descriptionXpathLabel.getPreferredSize().width;

	final int[] rows = {height1, height1 * 3, ownerHeight, height1, height1, TableLayout.FILL,};
	final int[] cols = {width1, TableLayout.DOUBLE_FILL, TableLayout.FILL,};

	setLayout(new TableLayout(rows, cols));

	add(nameLabel, new Rectangle(0, 0, 1, 1));
	add(name, new Rectangle(1, 0, 1, 1));

	add(descriptionLabel, new Rectangle(0, 1, 1, 1));
	add(description, new Rectangle(1, 1, 1, 1));

	add(ownerLabel, new Rectangle(0, 2, 1, 1));
	add(owner, new Rectangle(1, 2, 1, 1));

	add(nameXpathLabel, new Rectangle(0, 3, 1, 1));
	add(nameXpathChooser, new Rectangle(1, 3, 1, 1));

	add(descriptionXpathLabel, new Rectangle(0, 4, 1, 1));
	add(descriptionXpathChooser, new Rectangle(1, 4, 1, 1));

	// Make sure things are readonly.
	if( state.isReadonly() )
	{
		name.setEnabled(false);
		description.setEnabled(false);
		owner.setEnabled(false);
		nameXpathChooser.setEnabled(false);
		descriptionXpathChooser.setEnabled(false);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:59,代码来源:DetailsTab.java


注:本文中的javax.swing.JLabel.getPreferredSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。