本文整理汇总了Java中javax.swing.JTextArea.setSize方法的典型用法代码示例。如果您正苦于以下问题:Java JTextArea.setSize方法的具体用法?Java JTextArea.setSize怎么用?Java JTextArea.setSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextArea
的用法示例。
在下文中一共展示了JTextArea.setSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MessageTextArea
import javax.swing.JTextArea; //导入方法依赖的package包/类
public MessageTextArea(boolean editable, String text, String labelText) {
setLayout(new BorderLayout());
area = new JTextArea("");
area.setSize(400, 400);
area.setWrapStyleWord(true);
area.setAutoscrolls(true);
area.setLineWrap(true);
area.setEditable(editable);
area.setText(text);
JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.getViewport().add(area);
scrollPane.setDoubleBuffered(true);
add(scrollPane, "Center");
JLabel message = new JLabel(labelText);
add(message, "North");
}
示例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: getGraphCellEditorComponent
import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
* Initialises the editor component with the edit string of the user
* object of <tt>value</tt> (which is required to be a {@link JCell}).
*/
@Override
public Component getGraphCellEditorComponent(org.jgraph.JGraph graph, Object value,
boolean isSelected) {
AspectJCell jCell = (AspectJCell) value;
// fill the set of labels for autocompletion
this.labels.clear();
this.labels.addAll(prefixes);
AspectJModel jmodel = (AspectJModel) graph.getModel();
TypeGraph type = jmodel.getResourceModel().getGrammar().getTypeGraph();
for (TypeLabel label : type.getLabels()) {
this.labels.add(label.text());
}
JTextArea result = getEditorComponent();
// scale with the jGraph
Font font = Options.getLabelFont().deriveFont(jCell.getVisuals().getFont());
font = (font != null) ? font : graph.getFont();
if (graph.getScale() != 1) {
double scale = graph.getScale();
Dimension size = result.getSize();
size.height *= scale;
size.width *= scale;
result.setSize(size);
font = font.deriveFont((float) (font.getSize() * scale));
}
result.setFont(font);
String editString = ((AspectJCell) value).getUserObject().toEditString();
result.setText(editString);
result.selectAll();
return result;
}
示例4: FirstContactDialog
import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
* Create an FirstContactDialog.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param frame The owner frame.
* @param player The {@code Player} making contact.
* @param other The {@code Player} to contact.
* @param tile An optional {@code Tile} on offer.
* @param settlementCount The number of settlements the other
* player has.
*/
public FirstContactDialog(FreeColClient freeColClient, JFrame frame,
Player player, Player other, Tile tile, int settlementCount) {
super(freeColClient, frame);
MigPanel panel
= new MigPanel(new MigLayout("wrap 1", "[center]", "[]20"));
panel.setOpaque(false);
String headerKey = BASE_KEY + other.getNation().getSuffix();
String imageKey = IMAGE_BASE_KEY + other.getNationResourceKey();
if (!Messages.containsKey(headerKey)) {
headerKey = BASE_KEY + NATIVES_KEY;
imageKey = IMAGE_BASE_KEY + NATIVES_KEY;
}
JLabel header = Utility.localizedHeaderLabel(headerKey,
SwingConstants.LEADING, FontLibrary.FontSize.MEDIUM);
JLabel image
= new JLabel(new ImageIcon(ResourceManager.getImage(imageKey)));
image.setOpaque(false);
JTextArea tutorial = null;
if (!player.hasContactedIndians() && freeColClient.tutorialMode()) {
tutorial = Utility.localizedTextArea(TUTORIAL_KEY);
}
String messageId = (tile != null)
? "firstContactDialog.welcomeOffer.text"
: "firstContactDialog.welcomeSimple.text";
String type = ((IndianNationType)other.getNationType())
.getSettlementTypeKey(true);
JTextArea text = Utility.localizedTextArea(StringTemplate
.template(messageId)
.addStringTemplate("%nation%", other.getNationLabel())
.addName("%camps%", Integer.toString(settlementCount))
.add("%settlementType%", type));
// Resize the text areas to better match the image.
int columns = (int)Math.floor(text.getColumns()
* image.getPreferredSize().getWidth()
/ text.getPreferredSize().getWidth());
text.setColumns(columns);
text.setSize(text.getPreferredSize());
if (tutorial != null) {
tutorial.setColumns(columns);
tutorial.setSize(tutorial.getPreferredSize());
}
panel.add(header);
panel.add(image);
if (tutorial != null) panel.add(tutorial);
panel.add(text);
panel.setSize(panel.getPreferredSize());
ImageIcon icon = new ImageIcon(
getImageLibrary().getMiscIconImage(other.getNation()));
initializeConfirmDialog(frame, false, panel, icon, "yes", "no");
}
示例5: getDefaultTextArea
import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
* Gets a text area with standard settings suitable for use in FreeCol
* panels, which adapt their size based on what they contain.
*
* @param text The text to display in the text area.
* @param columns The em-width number of columns to display the text in.
* @return A suitable text area.
*/
public static JTextArea getDefaultTextArea(String text, int columns) {
JTextArea textArea = createTextArea(text);
textArea.setColumns(columns);
textArea.setSize(textArea.getPreferredSize());
return textArea;
}