Java Code Examples for javax.swing.JLabel.getPreferredSize()

The following are Jave code examples for showing how to use getPreferredSize() of the javax.swing.JLabel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: OpenJSharp   File: TitledBorder.java   View Source Code Vote up 6 votes
/**
 * 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;
}
 
Example 2
Project: Equella   File: DownloadPage.java   View Source Code Vote up 6 votes
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));
}
 
Example 3
Project: Equella   File: ReviewPage.java   View Source Code Vote up 6 votes
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));
}
 
Example 4
Project: Equella   File: ExceptionDialog.java   View Source Code Vote up 6 votes
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;
}
 
Example 5
Project: VASSAL-src   File: Chart.java   View Source Code Vote up 5 votes
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;
  }
 
Example 6
Project: ramus   File: TableRowHeader.java   View Source Code Vote up 5 votes
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;
}
 
Example 7
Project: brModelo   File: FrameSobre.java   View Source Code Vote up 5 votes
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();
        }
    }
 
Example 8
Project: Equella   File: TransformDialog.java   View Source Code Vote up 5 votes
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));
}
 
Example 9
Project: jdk8u-jdk   File: TitledBorder.java   View Source Code Vote up 4 votes
/**
 * 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;
}
 
Example 10
Project: OpenJSharp   File: TitledBorder.java   View Source Code Vote up 4 votes
/**
 * 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;
}
 
Example 11
Project: freecol   File: FatherDetailPanel.java   View Source Code Vote up 4 votes
/**
 * 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);            
}
 
Example 12
Project: Equella   File: ServerPage.java   View Source Code Vote up 4 votes
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));
}
 
Example 13
Project: Equella   File: DetailsTab.java   View Source Code Vote up 4 votes
@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);
	}
}
 
Example 14
Project: Equella   File: ImportPage.java   View Source Code Vote up 4 votes
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));
}
 
Example 15
Project: Equella   File: DetailsTab.java   View Source Code Vote up 4 votes
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);
	}
}
 
Example 16
Project: Logisim   File: ExportImage.java   View Source Code Vote up 4 votes
OptionsPanel(JList<?> list) {
	// set up components
	formatPng = new JRadioButton("PNG");
	formatGif = new JRadioButton("GIF");
	formatJpg = new JRadioButton("JPEG");
	ButtonGroup bgroup = new ButtonGroup();
	bgroup.add(formatPng);
	bgroup.add(formatGif);
	bgroup.add(formatJpg);
	formatPng.setSelected(true);

	slider = new JSlider(SwingConstants.HORIZONTAL, -3 * SLIDER_DIVISIONS, 3 * SLIDER_DIVISIONS, 0);
	slider.setMajorTickSpacing(10);
	slider.addChangeListener(this);
	curScale = new JLabel("222%");
	curScale.setHorizontalAlignment(SwingConstants.RIGHT);
	curScale.setVerticalAlignment(SwingConstants.CENTER);
	curScaleDim = new Dimension(curScale.getPreferredSize());
	curScaleDim.height = Math.max(curScaleDim.height, slider.getPreferredSize().height);
	stateChanged(null);

	printerView = new JCheckBox();
	printerView.setSelected(true);

	// set up panel
	gridbag = new GridBagLayout();
	gbc = new GridBagConstraints();
	setLayout(gridbag);

	// now add components into panel
	gbc.gridy = 0;
	gbc.gridx = GridBagConstraints.RELATIVE;
	gbc.anchor = GridBagConstraints.NORTHWEST;
	gbc.insets = new Insets(5, 0, 5, 0);
	gbc.fill = GridBagConstraints.NONE;
	addGb(new JLabel(Strings.get("labelCircuits") + " "));
	gbc.fill = GridBagConstraints.HORIZONTAL;
	addGb(new JScrollPane(list));
	gbc.fill = GridBagConstraints.NONE;

	gbc.gridy++;
	addGb(new JLabel(Strings.get("labelImageFormat") + " "));
	Box formatsPanel = new Box(BoxLayout.Y_AXIS);
	formatsPanel.add(formatPng);
	formatsPanel.add(formatGif);
	formatsPanel.add(formatJpg);
	addGb(formatsPanel);

	gbc.gridy++;
	addGb(new JLabel(Strings.get("labelScale") + " "));
	addGb(slider);
	addGb(curScale);

	gbc.gridy++;
	addGb(new JLabel(Strings.get("labelPrinterView") + " "));
	addGb(printerView);
}
 
Example 17
Project: Equella   File: CalendarEditor.java   View Source Code Vote up 4 votes
private JComponent createDetails()
{
	JLabel titleLabel = new JLabel(CurrentLocale.get("wizard.controls.title"));
	JLabel descriptionLabel = new JLabel(CurrentLocale.get("wizard.controls.description"));

	title = new I18nTextField(BundleCache.getLanguages());
	description = new I18nTextField(BundleCache.getLanguages());

	JComponent dateSelection = generateDefaultDate();

	formatGroup = new ButtonGroup();

	JLabel formatLabel = new JLabel(getString("date.format"));
	dayMonthYear = new JRadioButton(getDateString("full"));
	formatGroup.add(dayMonthYear);
	monthYear = new JRadioButton(getDateString("month"));
	formatGroup.add(monthYear);
	year = new JRadioButton(getDateString("year"));
	formatGroup.add(year);
	dayMonthYear.setSelected(true);// default

	mandatory = new JCheckBox(CurrentLocale.get("wizard.controls.mandatory"));

	reload = new JCheckBox(CurrentLocale.get("wizard.controls.reload"));
	reload.addActionListener(new ReloadHandler(reload));

	final int width1 = formatLabel.getPreferredSize().width;
	final int height1 = title.getPreferredSize().height;
	final int height2 = dateSelection.getPreferredSize().height;
	final int height3 = dayMonthYear.getPreferredSize().height;

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

	JPanel all = new JPanel(new TableLayout(rows, cols, 5, 5));

	int row = -1;
	all.add(titleLabel, new Rectangle(0, ++row, 1, 1));
	all.add(title, new Rectangle(1, row, 1, 1));

	all.add(descriptionLabel, new Rectangle(0, ++row, 1, 1));
	all.add(description, new Rectangle(1, row, 1, 1));

	all.add(dateSelection, new Rectangle(0, ++row, 2, 1));
	// TODO: format so it doesn't look so ugly
	all.add(formatLabel, new Rectangle(0, ++row, 1, 1));
	all.add(dayMonthYear, new Rectangle(1, ++row, 1, 1));
	all.add(monthYear, new Rectangle(1, ++row, 1, 1));
	all.add(year, new Rectangle(1, ++row, 1, 1));

	all.add(mandatory, new Rectangle(0, ++row, 2, 1));

	all.add(reload, new Rectangle(0, ++row, 2, 1));

	if( getWizardType() != WizardHelper.WIZARD_TYPE_POWERSEARCH )
	{
		range = new JCheckBox(CurrentLocale.get("wizard.controls.timerange"));
		all.add(range, new Rectangle(0, ++row, 2, 1));
	}

	return all;
}
 
Example 18
Project: jdk8u-jdk   File: TitledBorder.java   View Source Code Vote up 4 votes
/**
 * 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;
}
 
Example 19
Project: Equella   File: DetailsTab.java   View Source Code Vote up 4 votes
@Override
public void setup(ChangeDetector changeDetector)
{
	JLabel topicNameLabel = new JLabel(getString("detailstab.topicname")); //$NON-NLS-1$
	JLabel shortLabel = new JLabel(getString("detailstab.shortdesc")); //$NON-NLS-1$
	JLabel longLabel = new JLabel(getString("detailstab.fulldesc")); //$NON-NLS-1$
	JLabel sectionsLabel = new JLabel(getString("detailstab.sectionnames")); //$NON-NLS-1$
	JLabel subtopicsLabel = new JLabel(getString("detailstab.subtopics")); //$NON-NLS-1$
	JLabel searchResultsLabel = new JLabel(
		getString("detailstab.searchresults")); //$NON-NLS-1$
	JLabel advancedSearchLabel = new JLabel(
		getString("detailstab.advancedsearch")); //$NON-NLS-1$

	topicName = new I18nTextField(BundleCache.getLanguages());

	subtopicsSection = new I18nTextField(BundleCache.getLanguages());
	searchResultsSection = new I18nTextField(BundleCache.getLanguages());

	shortDescription = new I18nTextArea(BundleCache.getLanguages());
	longDescription = new I18nTextArea(BundleCache.getLanguages());

	hideSubtopicsWithNoResults = new JCheckBox(
		getString("detailstab.hidesubtopicswithnoresults")); //$NON-NLS-1$

	advancedSearchSelector = new JComboBox();
	advancedSearchSelector.addItem(getString("detailstab.nopowersearch")); //$NON-NLS-1$
	AppletGuiUtils.addItemsToJCombo(advancedSearchSelector, cache.getPowerSearches());

	final int width1 = 20;
	final int width2 = topicNameLabel.getPreferredSize().width - width1;
	final int width3 = Math.max(searchResultsLabel.getPreferredSize().width,
		searchResultsLabel.getPreferredSize().width) - width2;

	final int[] rows = {TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED,
			TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED,
			TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED,};
	final int[] cols = {width1, width2, width3, TableLayout.FILL,};

	setLayout(new TableLayout(rows, cols));

	int row = 0;
	add(topicNameLabel, new Rectangle(0, row, 2, 1));
	add(topicName, new Rectangle(2, row++, 2, 1));

	add(shortLabel, new Rectangle(0, row++, 4, 1));
	add(shortDescription, new Rectangle(1, row++, 3, 1));

	add(longLabel, new Rectangle(0, row++, 4, 1));
	add(longDescription, new Rectangle(1, row++, 3, 1));

	add(sectionsLabel, new Rectangle(0, row++, 4, 1));

	add(subtopicsLabel, new Rectangle(1, row, 2, 1));
	add(subtopicsSection, new Rectangle(3, row++, 1, 1));
	add(searchResultsLabel, new Rectangle(1, row, 2, 1));
	add(searchResultsSection, new Rectangle(3, row++, 1, 1));

	add(hideSubtopicsWithNoResults, new Rectangle(0, row++, 4, 1));

	add(advancedSearchLabel, new Rectangle(0, row++, 4, 1));
	add(advancedSearchSelector, new Rectangle(1, row++, 3, 1));

	changeDetector.watch(topicName);
	changeDetector.watch(shortDescription);
	changeDetector.watch(longDescription);
	changeDetector.watch(subtopicsSection);
	changeDetector.watch(searchResultsSection);
	changeDetector.watch(advancedSearchSelector);
}
 
Example 20
Project: Equella   File: IpAddressFinder.java   View Source Code Vote up 4 votes
public IpAddressEditor()
{
	JLabel addressLabel = new JLabel(CurrentLocale.get("com.tle.admin.recipients.ipaddressfinder.ipaddress"));
	JLabel maskLabel = new JLabel(CurrentLocale.get("com.tle.admin.recipients.ipaddressfinder.subnet"));
	JLabel dot1 = new JLabel(".");
	JLabel dot2 = new JLabel(".");
	JLabel dot3 = new JLabel(".");
	JLabel slash = new JLabel("/");

	addressLabel.setHorizontalTextPosition(SwingConstants.CENTER);
	addressLabel.setHorizontalAlignment(SwingConstants.CENTER);
	maskLabel.setHorizontalTextPosition(SwingConstants.CENTER);
	maskLabel.setHorizontalAlignment(SwingConstants.CENTER);

	part1 = new JNumberTextField(255);
	part2 = new JNumberTextField(255);
	part3 = new JNumberTextField(255);
	part4 = new JNumberTextField(255);
	mask = new JNumberTextField(32);

	part1.addKeyListener(this);
	part2.addKeyListener(this);
	part3.addKeyListener(this);
	part4.addKeyListener(this);
	mask.addKeyListener(this);

	final int width1 = maskLabel.getPreferredSize().width;
	final int width2 = slash.getPreferredSize().width;
	final int height1 = mask.getPreferredSize().height;
	final int height2 = addressLabel.getPreferredSize().height;

	final int[] rows = {height1, height2,};
	final int[] cols = {width1, width2, width1, width2, width1, width2, width1, width2, width1,};

	setLayout(new TableLayout(rows, cols));
	add(part1, new Rectangle(0, 0, 1, 1));
	add(dot1, new Rectangle(1, 0, 1, 1));
	add(part2, new Rectangle(2, 0, 1, 1));
	add(dot2, new Rectangle(3, 0, 1, 1));
	add(part3, new Rectangle(4, 0, 1, 1));
	add(dot3, new Rectangle(5, 0, 1, 1));
	add(part4, new Rectangle(6, 0, 1, 1));
	add(slash, new Rectangle(7, 0, 1, 1));
	add(mask, new Rectangle(8, 0, 1, 1));

	add(addressLabel, new Rectangle(0, 1, 7, 1));
	add(maskLabel, new Rectangle(8, 1, 1, 1));
}