本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}