use of javax.swing.text.DefaultCaret in project zaproxy by zaproxy.
the class ZapLabel method setDefaults.
private void setDefaults() {
this.setEditable(false);
this.setCursor(null);
this.setBorder(null);
this.setBackground(new Color(UIManager.getLookAndFeel().getDefaults().getColor("Label.background").getRGB()));
this.setForeground(new Color(UIManager.getLookAndFeel().getDefaults().getColor("Label.foreground").getRGB()));
((DefaultCaret) getCaret()).setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
}
use of javax.swing.text.DefaultCaret in project SKMCLauncher by SKCraft.
the class OptionsDialog method buildAboutPanel.
/**
* Build the about panel.
*
* @return panel
*/
private JPanel buildAboutPanel() {
JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
JLabel label;
label = new JLabel("SK's Minecraft Launcher");
label.setAlignmentX(Component.LEFT_ALIGNMENT);
panel.add(label);
label = new JLabel("Version " + Launcher.VERSION);
label.setAlignmentX(Component.LEFT_ALIGNMENT);
panel.add(label);
LinkButton btn = new LinkButton("https://github.com/sk89q/skmclauncher");
btn.setAlignmentX(Component.LEFT_ALIGNMENT);
panel.add(btn);
panel.add(Box.createVerticalStrut(20));
final JTextArea text = new JTextArea() {
private static final long serialVersionUID = -1743545646109139950L;
@Override
public Dimension getPreferredSize() {
return new Dimension(300, super.getPreferredSize().height);
}
};
text.setEditable(false);
text.setWrapStyleWord(true);
text.setLineWrap(true);
text.setFont(label.getFont());
DefaultCaret caret = (DefaultCaret) text.getCaret();
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
JScrollPane scroll = new JScrollPane(text);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setAlignmentX(Component.LEFT_ALIGNMENT);
scroll.setPreferredSize(new Dimension(text.getPreferredSize().width, 200));
panel.add(scroll);
panel.add(Box.createVerticalGlue());
btn.addActionListener(ActionListeners.openURL(this, "https://github.com/sk89q/skmclauncher"));
// Fetch notices
new Thread(new Runnable() {
@Override
public void run() {
final String notices = Launcher.getNotices();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
text.setText(notices);
}
});
}
}).start();
return panel;
}
use of javax.swing.text.DefaultCaret in project jadx by skylot.
the class AbstractCodeArea method addCaretActions.
private void addCaretActions() {
Caret caret = getCaret();
if (caret instanceof DefaultCaret) {
((DefaultCaret) caret).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
}
this.addFocusListener(new FocusListener() {
// fix caret missing bug.
// when lost focus set visible to false,
// and when regained set back to true will force
// the caret to be repainted.
@Override
public void focusGained(FocusEvent e) {
caret.setVisible(true);
}
@Override
public void focusLost(FocusEvent e) {
caret.setVisible(false);
}
});
addCaretListener(new CaretListener() {
int lastPos = -1;
String lastText = "";
@Override
public void caretUpdate(CaretEvent e) {
int pos = getCaretPosition();
if (lastPos != pos) {
lastPos = pos;
lastText = highlightCaretWord(lastText, pos);
}
}
});
}
use of javax.swing.text.DefaultCaret in project Universal-G-Code-Sender by winder.
the class CommandPanel method checkScrollWindow.
private void checkScrollWindow() {
// Console output.
DefaultCaret caret = (DefaultCaret) consoleTextArea.getCaret();
if (scrollWindowMenuItem.isSelected()) {
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
consoleTextArea.setCaretPosition(consoleTextArea.getDocument().getLength());
} else {
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
}
}
use of javax.swing.text.DefaultCaret in project Universal-G-Code-Sender by winder.
the class MainWindow method checkScrollWindow.
private void checkScrollWindow() {
// Console output.
DefaultCaret caret = (DefaultCaret) consoleTextArea.getCaret();
if (scrollWindowCheckBox.isSelected()) {
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
consoleTextArea.setCaretPosition(consoleTextArea.getDocument().getLength());
} else {
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
}
// Command table.
this.commandTable.setAutoWindowScroll(scrollWindowCheckBox.isSelected());
}
Aggregations