本文整理汇总了Java中javax.swing.text.DefaultCaret类的典型用法代码示例。如果您正苦于以下问题:Java DefaultCaret类的具体用法?Java DefaultCaret怎么用?Java DefaultCaret使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultCaret类属于javax.swing.text包,在下文中一共展示了DefaultCaret类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TelemetryToolWindow
import javax.swing.text.DefaultCaret; //导入依赖的package包/类
private TelemetryToolWindow(Project project) {
ToolWindowManager manager = ToolWindowManager.getInstance(project);
if (window == null) {
textPane = new JTextPane();
textPane.setEditable(false);
JBScrollPane scrollPane = new JBScrollPane(textPane);
DefaultCaret caret = (DefaultCaret) textPane.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
textPane.setContentType("text/html");
initHtmlComposer();
window = manager.registerToolWindow(WINDOW_ID, scrollPane, ToolWindowAnchor.BOTTOM);
window.show(EMPTY_TASK);
}
}
示例2: restoreLegacyCaret
import javax.swing.text.DefaultCaret; //导入依赖的package包/类
@Override
protected void restoreLegacyCaret(Caret caret) {
int markOffsetAndBias = this.markOffsetAndBias;
if (markOffsetAndBias == COMPLEX_POSITIONS_MARKER) { // complex positions at time of undo edit creation
markOffsetAndBias = extraOffsets[1];
}
int markOffset = getOffset(markOffsetAndBias);
int dotOffset = getOffset(dotOffsetAndBias);
if (caret instanceof DefaultCaret) {
DefaultCaret dCaret = (DefaultCaret) caret;
dCaret.setDot(markOffset, getBias(markOffsetAndBias));
dCaret.moveDot(dotOffset, getBias(dotOffsetAndBias));
} else {
caret.setDot(markOffset);
caret.moveDot(dotOffset);
}
}
示例3: DebugFrame
import javax.swing.text.DefaultCaret; //导入依赖的package包/类
/**
* Creates a new DebugFrame used for the logger to log its messages onto.
*/
public DebugFrame() {
this.setUndecorated(true);
this.setBackground(new Color(0, 0, 0, 0));
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.setSize(Display.WINDOW_WIDTH / 3, Display.WINDOW_HEIGHT);
this.setLayout(new GridLayout(2, 5));
this.setLocation(Display.WINDOW_POSITION);
this.setResizable(false);
this.textPane = new ColorableTextPane();
this.textPane.setFont(new Font("Arial", Font.BOLD, 15));
this.setPreferredSize(new Dimension(Display.WINDOW_WIDTH / 3, Display.WINDOW_HEIGHT));
DefaultCaret caret = (DefaultCaret) this.textPane.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
final JScrollPane sp = new JScrollPane(this.textPane);
sp.getViewport().setBackground(Color.GRAY);
sp.getViewport().setFocusable(false);
sp.setBorder(BorderFactory.createLineBorder(Color.BLACK, 3));
this.add(sp);
this.setVisible(true);
}
示例4: PartidaView
import javax.swing.text.DefaultCaret; //导入依赖的package包/类
private PartidaView(Partida partida, boolean inicioTurno, GameCliente gameCliente) {
PARTIDA = partida;
this.gameCliente = gameCliente;
initComponents();
renderGraphics();
this.inicioTurno = inicioTurno;
DefaultCaret caret = (DefaultCaret) jTextAreaHistorico.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
hero = PARTIDA.getHero();
oponente = PARTIDA.getOponente();
adicionarPaineis();
//configura os atalhos da janela atual
inserirAtalhos();
PARTIDA.setPartidaView(getInstance());
PARTIDA.iniciarThreadExecutarJogadas();
glassPane = (JPanel) getInstance().getGlassPane();
glassPane.setLayout(new GridBagLayout());
Arrays.asList(hero, oponente).forEach(Heroi::refreshDanoMagico);
}
示例5: considerSettingFoundPointersTextArea
import javax.swing.text.DefaultCaret; //导入依赖的package包/类
private void considerSettingFoundPointersTextArea()
{
List<MemoryPointer> memoryPointers = memoryPointerSearcher.getMemoryPointers();
if (memoryPointers != null)
{
// Apply sorting
MemoryPointerSorting memoryPointerSorting = sortingSelection.getItemAt(sortingSelection.getSelectedIndex());
Comparator<MemoryPointer> comparator = memoryPointerSorting.getComparator();
memoryPointers.sort(comparator);
// Convert to String
int index = offsetPrintingSettingSelection.getSelectedIndex();
OffsetPrintingSetting offsetPrintingSetting = offsetPrintingSettingSelection.getItemAt(index);
String foundPointersText = MemoryPointer.toString(memoryPointers, offsetPrintingSetting);
// Disable the cursor position from changing when the text area is updated
DefaultCaret caret = (DefaultCaret) foundPointersOutputArea.getCaret();
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
foundPointersOutputArea.setText(foundPointersText);
}
}
示例6: ErrorWindow
import javax.swing.text.DefaultCaret; //导入依赖的package包/类
public ErrorWindow() {
txtStdErr = new JTextArea();
txtStdErr.setMargin(SizeHelper.getTextMargin());
txtStdErr.setLineWrap(true);
txtStdErr.setEditable(false);
txtStdErr.setWrapStyleWord(true);
txtStdErr.setForeground(Color.RED);
txtStdErr.addMouseListener(new LogAreaMouseListener());
DefaultCaret caret = (DefaultCaret) txtStdErr.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
JScrollPane scrollStdErr = new JScrollPane();
scrollStdErr.setViewportView(txtStdErr);
setLayout(new BorderLayout());
add(scrollStdErr, BorderLayout.CENTER);
addComponentListener(this);
}
示例7: OutputWindow
import javax.swing.text.DefaultCaret; //导入依赖的package包/类
public OutputWindow() {
txtStdOut = new JTextArea();
txtStdOut.setMargin(SizeHelper.getTextMargin());
txtStdOut.setLineWrap(true);
txtStdOut.setEditable(false);
txtStdOut.setWrapStyleWord(true);
txtStdOut.addMouseListener(new LogAreaMouseListener());
DefaultCaret caret = (DefaultCaret) txtStdOut.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
JScrollPane scrollStdOut = new JScrollPane();
scrollStdOut.setViewportView(txtStdOut);
setLayout(new BorderLayout());
add(scrollStdOut, BorderLayout.CENTER);
}
示例8: OrganizationCard
import javax.swing.text.DefaultCaret; //导入依赖的package包/类
public OrganizationCard(Organization organization) {
this.initComponents();
this.organization = organization;
DefaultCaret caret = (DefaultCaret) this.organizationInformation.getCaret();
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
this.organizationName.setText(organization.getName());
String information = organization.getInformation();
if (information.length() > 75) {
information = information.substring(0, 74) + "...";
}
this.organizationInformation.setText(information);
this.organizationSlug.setText("/" + organization.getSlug());
ImageIcon image = new ImageIcon("placeholderLogo.png");
if (!organization.getLogoPath().contains("missing")) {
image = new ImageIcon(logoUrl(organization.getLogoPath()));
}
image.setImage(image.getImage().getScaledInstance(49, 49, java.awt.Image.SCALE_SMOOTH));
this.logo.setIcon(image);
}
示例9: MaterialPasswordField
import javax.swing.text.DefaultCaret; //导入依赖的package包/类
/**
* Creates a new password field.
*/
public MaterialPasswordField() {
setBorder(null);
setFont(getFont().deriveFont(16f)); //use default font, Roboto's bullet doesn't work on some platforms (i.e. Mac)
floatingLabel.setText("");
setOpaque(false);
setBackground(MaterialColor.TRANSPARENT);
setCaret(new DefaultCaret() {
@Override
protected synchronized void damage(Rectangle r) {
MaterialPasswordField.this.repaint(); //fix caret not being removed completely
}
});
getCaret().setBlinkRate(500);
}
示例10: MaterialTextField
import javax.swing.text.DefaultCaret; //导入依赖的package包/类
/**
* Default constructor for {@code MaterialTextField}. A default model is
* created and the initial string is empty.
*/
public MaterialTextField() {
super();
setBorder(null);
setFont(Roboto.REGULAR.deriveFont(16f));
floatingLabel.setText("");
setOpaque(false);
setBackground(MaterialColor.TRANSPARENT);
setCaret(new DefaultCaret() {
@Override
protected synchronized void damage(Rectangle r) {
MaterialTextField.this.repaint(); //fix caret not being removed completely
}
});
getCaret().setBlinkRate(500);
}
示例11: BlockingFrame
import javax.swing.text.DefaultCaret; //导入依赖的package包/类
public BlockingFrame(OrgsecModel model) {
this.model = model;
JFrame frame = new JFrame("orgsec");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jtp = new JTabbedPane();
JTextArea area = new JTextArea();
out = new TextAreaOutputStream(area);
JScrollPane areapane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
DefaultCaret caret = (DefaultCaret) area.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
areapane.setViewportView(area);
jtp.add("blocking", areapane);
frame.setContentPane(jtp);
frame.setSize(400, 400);
frame.setVisible(true);
}
示例12: init
import javax.swing.text.DefaultCaret; //导入依赖的package包/类
/**
*
*/
@Override
public void init() {
display.setLayout(new BorderLayout());
display.setPreferredSize(new Dimension(800, 600));
// --------- text menu begin ------------------------
JPanel menuPanel = createMenuPanel();
display.add(menuPanel, BorderLayout.PAGE_START);
DefaultCaret caret = (DefaultCaret) pythonConsole.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
splitPane = createMainPane();
display.add(splitPane, BorderLayout.CENTER);
display.add(statusInfo, BorderLayout.PAGE_END);
}
示例13: makeOutputPanel
import javax.swing.text.DefaultCaret; //导入依赖的package包/类
private JPanel makeOutputPanel()
{
JPanel rv = new JPanel();
rv.setLayout(new BorderLayout());
outputArea.setLineWrap(false);
outputArea.setEditable(false);
DefaultCaret caret = (DefaultCaret) outputArea.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
// arg, this seems harder than it needs to be
outputArea.setEnabled(false);
Color trColor = outputArea.getBackground();
outputArea.setEnabled(true);
// setBackground doesn't seem to react to textResource colors
Color color = new Color(trColor.getRed(), trColor.getGreen(), trColor.getBlue());
outputArea.setBackground(color);
JScrollPane sp = new JScrollPane(outputArea);
rv.add(sp, BorderLayout.CENTER);
return rv;
}
示例14: FrmTextEditor
import javax.swing.text.DefaultCaret; //导入依赖的package包/类
/**
* Creates new form FrmTextEditor
*/
public FrmTextEditor() {
initComponents();
DefaultCaret caret = (DefaultCaret) this.jTextArea_Output.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
BufferedImage image = null;
try {
image = ImageIO.read(this.getClass().getResource("/org/meteoinfo/desktop/resources/snake.png"));
this.setIconImage(image);
} catch (Exception e) {
}
this.setScriptLanguage(_scriptLanguage);
addNewTextEditor("New file");
this._splitPanelSize = this.jSplitPane1.getBounds().getSize();
this.setSize(600, 600);
//this.jSplitPane1.setDividerLocation(0.6);
this.jSplitPane1.setDividerLocation(5);
//this.jScrollPane1.invalidate();
}
示例15: buisitLcdViewer
import javax.swing.text.DefaultCaret; //导入依赖的package包/类
/**
* Erstellt die Textarea, die das LCD des Bot zeigt
* @param d Display
*/
public void buisitLcdViewer(Actuators.LcDisplay d) {
JTextArea t = new JTextArea(d.getExternalModel(), null, d.getNumRows(), d.getNumCols());
t.setEnabled(false);
/*
* Fix fuer Bug 8 im Trac ("Kein Scrollen moeglich wenn Sim aktiv").
* Details hab ich nicht rausgekriegt, aber wenn man das Caret (=
* Cursor) abschaltet geht's. Siehe Bug:
* http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4201999 und
* zugehoerigen Fix:
* http://java.sun.com/j2se/1.5.0/docs/guide/swing/1.5/#swingText
*/
Misc.setCaretPolicy(t, DefaultCaret.NEVER_UPDATE);
t.setFont(new Font("Monospaced", Font.PLAIN, 12));
t.setDisabledTextColor(Color.BLACK);
t.setBackground(new Color(170, 200, 90));
t.setBorder(BorderFactory.createLoweredBevelBorder());
t.setToolTipText(d.getName());
t.setMaximumSize(t.getPreferredSize());
t.setAlignmentX(Component.CENTER_ALIGNMENT);
add(t);
add(Box.createRigidArea(new Dimension(0, 5)));
}