当前位置: 首页>>代码示例>>Python>>正文


Python JTextArea.getCaret方法代码示例

本文整理汇总了Python中javax.swing.JTextArea.getCaret方法的典型用法代码示例。如果您正苦于以下问题:Python JTextArea.getCaret方法的具体用法?Python JTextArea.getCaret怎么用?Python JTextArea.getCaret使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTextArea的用法示例。


在下文中一共展示了JTextArea.getCaret方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ConsoleView

# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import getCaret [as 别名]
class ConsoleView(JPanel):

    def __init__(self, controller):
        '''
        Creates default empty console-looking panel.
        It should be separated from the rest of the GUI so that users can choose
        to show or hide the console. Or should it be a split panel?
        This panel will display log and validation/lemmatization messages.
        It might need its own toolbar for searching, etc.
        It will also accept commands in later stages of development, if need be.
        '''

        # Give reference to controller to delegate action response
        self.controller = controller

        # Make text area occupy all available space and resize with parent window
        self.setLayout(BorderLayout())

        #Create console-looking area
        self.editArea = JTextArea()
        self.editArea.border = BorderFactory.createEmptyBorder(4,4,4,4)
        self.editArea.font = Font("Courier New", Font.BOLD, 14)
        self.editArea.background = Color.BLACK
        self.editArea.foreground = Color.WHITE
        self.editArea.text = "Console started. Nammu's log will appear here.\n\n"

        # Disable writting in the console
        self.editArea.setEditable(False)

        # Will need scrolling controls
        scrollingText = JScrollPane(self.editArea)
        scrollingText.setPreferredSize(Dimension(1,150))

        # Make text area auto scroll down to last printed line
        caret = self.editArea.getCaret();
        caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

        # Add to parent panel
        self.add(scrollingText, BorderLayout.CENTER)


    def scroll(self):
        '''
        Scroll down to bottom.
        '''
        self.editArea.setCaretPosition(self.editArea.getDocument().getLength())
开发者ID:raquel-ucl,项目名称:nammu,代码行数:48,代码来源:ConsoleView.py


注:本文中的javax.swing.JTextArea.getCaret方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。