本文整理汇总了Java中javax.swing.JTextArea.insert方法的典型用法代码示例。如果您正苦于以下问题:Java JTextArea.insert方法的具体用法?Java JTextArea.insert怎么用?Java JTextArea.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextArea
的用法示例。
在下文中一共展示了JTextArea.insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insert
import javax.swing.JTextArea; //导入方法依赖的package包/类
@Override
public void insert(final String text, final int pos) {
final ScrollableJTextArea pane = getDelegate();
synchronized (getDelegateLock()) {
final JTextArea area = pane.getView();
final boolean doScroll = pos >= area.getDocument().getLength()
&& area.getDocument().getLength() != 0;
area.insert(text, pos);
revalidate();
if (doScroll) {
final JScrollBar vbar = pane.getVerticalScrollBar();
if (vbar != null) {
vbar.setValue(vbar.getMaximum() - vbar.getVisibleAmount());
}
}
}
repaintPeer();
}
示例2: EmigrationDialog
import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
* The constructor to use.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param frame The owner frame.
* @param europe The {@code Europe} where we can find the
* units that are prepared to emigrate.
* @param foy Is this emigration due to a fountain of youth?
*/
public EmigrationDialog(FreeColClient freeColClient, JFrame frame,
Europe europe, boolean foy) {
super(freeColClient, frame);
final ImageLibrary lib = freeColClient.getGUI().getImageLibrary();
final List<AbstractUnit> recruitables
= new ArrayList<>(europe.getExpandedRecruitables(false));
JTextArea header
= Utility.localizedTextArea("emigrationDialog.chooseImmigrant");
if (foy) {
header.insert(Messages.message(LostCityRumour.RumourType.FOUNTAIN_OF_YOUTH.getDescriptionKey())
+ "\n\n", 0);
}
MigPanel panel = new MigPanel(new MigLayout("wrap 1", "[fill]", ""));
panel.add(header, "wrap 20");
panel.setSize(panel.getPreferredSize());
List<ChoiceItem<Integer>> c = choices();
int i = Europe.MigrationType.getDefaultSlot();
AbstractUnit a0 = recruitables.remove(0);
c.add(new ChoiceItem<>(Messages.message(a0.getSingleLabel()), i++)
.defaultOption()
.setIcon(new ImageIcon(getSmallAbstractUnitImage(a0))));
for (AbstractUnit au : recruitables) {
c.add(new ChoiceItem<>(Messages.message(au.getSingleLabel()), i++)
.setIcon(new ImageIcon(getSmallAbstractUnitImage(au))));
}
initializeChoiceDialog(frame, false, panel, null, null, c);
}