use of javax.swing.text.DefaultCaret in project Orthanc_Tools by salimkanoun.
the class VueRest method showConsoleFrame.
/**
* Create GUI to display log message during retrieve operations
*/
private void showConsoleFrame() {
JFrame console = new JFrame();
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
console.add(panel);
JScrollPane scrollPane = new JScrollPane();
textAreaConsole = new JTextArea(10, 80);
textAreaConsole.setAutoscrolls(true);
DefaultCaret caret = (DefaultCaret) textAreaConsole.getCaret();
caret.setUpdatePolicy(DefaultCaret.OUT_BOTTOM);
scrollPane.setViewportView(textAreaConsole);
panel.add(scrollPane, BorderLayout.CENTER);
JButton btnCsvRetrieveReport = new JButton("Save To CSV");
btnCsvRetrieveReport.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
JFileChooser csvReport = new JFileChooser();
csvReport.setFileSelectionMode(JFileChooser.FILES_ONLY);
csvReport.setSelectedFile(new File("Report_AutoRetrieve_" + df.format(new Date()) + ".csv"));
int ok = csvReport.showSaveDialog(null);
if (ok == JFileChooser.APPROVE_OPTION) {
AutoQueryResultTableDialog.writeCSV(textAreaConsole.getText(), csvReport.getSelectedFile().getAbsolutePath().toString());
}
}
});
JPanel button = new JPanel();
btnCsvRetrieveReport.setToolTipText("Set Folder to generate report of AutoQuery");
button.add(btnCsvRetrieveReport);
panel.add(button, BorderLayout.SOUTH);
console.pack();
console.setLocationRelativeTo(this);
console.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
console.setVisible(true);
}
use of javax.swing.text.DefaultCaret in project chatty by chatty.
the class DebugWindow method createLogArea.
private static JTextArea createLogArea() {
// Caret to prevent scrolling
DefaultCaret caret = new DefaultCaret();
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
JTextArea text = new JTextArea();
text.setEditable(false);
text.setFont(Font.decode(Font.MONOSPACED));
text.setCaret(caret);
return text;
}
use of javax.swing.text.DefaultCaret in project Universal-Pointer-Searcher by BullyWiiPlaza.
the class UniversalPointerSearcherGUI method setFoundPointersText.
private void setFoundPointersText(String foundPointersText) {
// Disable the cursor position from changing when the text area is updated
val caret = (DefaultCaret) foundPointersOutputArea.getCaret();
caret.setUpdatePolicy(NEVER_UPDATE);
foundPointersOutputArea.setText(foundPointersText);
}
use of javax.swing.text.DefaultCaret in project invesdwin-util by invesdwin.
the class Components method disableCaretScrolling.
/**
* https://stackoverflow.com/questions/2039373/maintaing-jtextarea-scroll-position
*/
public static void disableCaretScrolling(final JTextComponent component) {
final DefaultCaret caret = (DefaultCaret) component.getCaret();
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
}
use of javax.swing.text.DefaultCaret in project NJAU-OS_sourse_design-simulated_linux by 404874351.
the class Dashboard method initConsole.
/**
* 初始化控制台
*/
public void initConsole() {
// 绘制控制台富文本
doc = this.console.getStyledDocument();
// 保持滚动条在底端
DefaultCaret caret = (DefaultCaret) this.console.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
// 设置控制台输出样式
this.logStyle = new SimpleAttributeSet();
StyleConstants.setFontFamily(this.logStyle, "Microsoft YaHei UI");
StyleConstants.setFontSize(this.logStyle, 14);
StyleConstants.setForeground(this.logStyle, Color.DARK_GRAY);
this.infoStyle = new SimpleAttributeSet();
StyleConstants.setFontFamily(this.infoStyle, "Microsoft YaHei UI");
StyleConstants.setFontSize(this.infoStyle, 14);
StyleConstants.setForeground(this.infoStyle, Color.BLUE);
this.errorStyle = new SimpleAttributeSet();
StyleConstants.setFontFamily(this.errorStyle, "Microsoft YaHei UI");
StyleConstants.setFontSize(this.errorStyle, 14);
StyleConstants.setForeground(this.errorStyle, Color.RED);
this.successStyle = new SimpleAttributeSet();
StyleConstants.setFontFamily(this.successStyle, "Microsoft YaHei UI");
StyleConstants.setFontSize(this.successStyle, 14);
StyleConstants.setForeground(this.successStyle, Color.GREEN);
}
Aggregations