Java Code Examples for javax.swing.JTextArea#insert()

The following examples show how to use javax.swing.JTextArea#insert() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LWTextAreaPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example 2
Source File: LWTextAreaPeer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example 3
Source File: LWTextAreaPeer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example 4
Source File: LWTextAreaPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example 5
Source File: LWTextAreaPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example 6
Source File: LWTextAreaPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example 7
Source File: LWTextAreaPeer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example 8
Source File: LWTextAreaPeer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example 9
Source File: LWTextAreaPeer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example 10
Source File: LWTextAreaPeer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example 11
Source File: LWTextAreaPeer.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example 12
Source File: LWTextAreaPeer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example 13
Source File: LWTextAreaPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example 14
Source File: EmigrationDialog.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 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);
    }

    JPanel 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);
}