當前位置: 首頁>>代碼示例>>Java>>正文


Java JTextArea.getPreferredSize方法代碼示例

本文整理匯總了Java中javax.swing.JTextArea.getPreferredSize方法的典型用法代碼示例。如果您正苦於以下問題:Java JTextArea.getPreferredSize方法的具體用法?Java JTextArea.getPreferredSize怎麽用?Java JTextArea.getPreferredSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JTextArea的用法示例。


在下文中一共展示了JTextArea.getPreferredSize方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createDetailsSection

import javax.swing.JTextArea; //導入方法依賴的package包/類
private JComponent createDetailsSection()
{
	final JLabel notesLabel = new JLabel(getString("label.notes")); //$NON-NLS-1$

	notes = new JTextArea();
	notes.setWrapStyleWord(true);
	notes.setLineWrap(true);
	notes.setRows(3);
	notes.setBorder(new EmptyBorder(0, 0, 10, 0));

	final int height1 = notesLabel.getPreferredSize().height;
	final int height2 = notes.getPreferredSize().height;

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

	all.add(notesLabel, new Rectangle(0, 0, 1, 1));
	all.add(new JScrollPane(notes), new Rectangle(0, 1, 1, 1));

	return all;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:23,代碼來源:AdvancedScriptControlEditor.java

示例2: displayArea

import javax.swing.JTextArea; //導入方法依賴的package包/類
protected JTextArea displayArea(int linecount)
{
    JTextArea ta = new JTextArea();
    ta.setEditable(false);
    ta.setLineWrap(false);
    ta.setEnabled(true);

    // ugly hack to set a preferred height based on lines of text
    ta.setSize(100,Short.MAX_VALUE);
    StringBuilder b = new StringBuilder();
    for (int ii = 0; ii < linecount-1; ii++) {
        b.append(ii+"\n"+ii);
    }
    ta.setText(b.toString());
    int h = (int)(ta.getPreferredSize().height*0.9);
    ta.setPreferredSize(new Dimension(Short.MAX_VALUE, h));
    ta.setText("");
    return ta;
}
 
開發者ID:drytoastman,項目名稱:scorekeeperfrontend,代碼行數:20,代碼來源:DriverCarPanel.java

示例3: setupGUI

import javax.swing.JTextArea; //導入方法依賴的package包/類
@SuppressWarnings("nls")
private void setupGUI()
{
	JPanel all = new JPanel();

	allowNonSequential = new JCheckBox(
		getString("wizard.editor.allowNonSequential.label"));

	showPageTitlesNextPrev = new JCheckBox(
		getString("wizard.editor.showPageTitlesNextPrev.label"));

	JLabel cssLabel = new JLabel(
		getString("wizard.editor.additionalCssClass.label"));
	additionalCssClass = new JTextField();
	JLabel cssHelp = new JLabel(
		getString("wizard.editor.additionalCssClass.help"));
	cssHelp.setFont(all.getFont());
	accessibilityHelpTitle = new JLabel(
		getString("wizard.editor.accesshelp.title"));
	accessibilityHelp = new JTextArea(
		getString("wizard.editor.accesshelp.text"));
	accessibilityHelp.setEditable(false);
	accessibilityHelp.setBackground(all.getBackground());
	accessibilityHelp.setFont(all.getFont());

	JSeparator separator1 = new JSeparator();
	JSeparator separator2 = new JSeparator();
	int sh = separator1.getPreferredSize().height;

	final int columns[] = {cssLabel.getPreferredSize().width, TableLayout.FILL};
	final int rows[] = {allowNonSequential.getPreferredSize().height,
			showPageTitlesNextPrev.getPreferredSize().height, sh, additionalCssClass.getPreferredSize().height,
			cssHelp.getPreferredSize().height, sh, accessibilityHelpTitle.getPreferredSize().height,
			accessibilityHelp.getPreferredSize().height};

	all.setLayout(new TableLayout(rows, columns, 5, 5));
	all.add(allowNonSequential, new Rectangle(0, 0, 2, 1));
	all.add(showPageTitlesNextPrev, new Rectangle(0, 1, 2, 1));
	all.add(separator1, new Rectangle(0, 2, 2, 1));
	all.add(cssLabel, new Rectangle(0, 3, 1, 1));
	all.add(additionalCssClass, new Rectangle(1, 3, 1, 1));
	all.add(cssHelp, new Rectangle(0, 4, 2, 1));
	all.add(separator2, new Rectangle(0, 5, 2, 1));
	all.add(accessibilityHelpTitle, new Rectangle(0, 6, 2, 1));
	all.add(accessibilityHelp, new Rectangle(0, 7, 2, 1));

	addSection(all);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:49,代碼來源:WizardEditor.java

示例4: buildDetail

import javax.swing.JTextArea; //導入方法依賴的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


注:本文中的javax.swing.JTextArea.getPreferredSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。