/** * Constructor. * * @param win parent reference * @param mouse mouse interaction */ public BaseXMem(final Window win, final boolean mouse) { super(win); BaseXLayout.setWidth(this, DWIDTH); BaseXLayout.setHeight(this, getFont().getSize() + 6); if (mouse) { setCursor(CURSORHAND); addMouseListener(this); addMouseMotionListener(this); } final Thread t = new Thread() { @Override public void run() { repaint(); Performance.sleep(500); } }; t.setDaemon(true); t.start(); }
/** * Default constructor. * * @param txt initial text * @param editable editable flag * @param win parent window */ public TextPanel(final String txt, final boolean editable, final Window win) { super(win); this.editable = editable; editor = new TextEditor(gui); setFocusable(true); setFocusTraversalKeysEnabled(!editable); setBackground(BACK); setOpaque(editable); addMouseMotionListener(this); addMouseWheelListener(this); addComponentListener(this); addMouseListener(this); addKeyListener(this); addFocusListener( new FocusAdapter() { @Override public void focusGained(final FocusEvent e) { if (isEnabled()) caret(true); } @Override public void focusLost(final FocusEvent e) { caret(false); rend.caret(false); } }); setFont(dmfont); layout(new BorderLayout()); scroll = new BaseXScrollBar(this); rend = new TextRenderer(editor, scroll, editable, gui); add(rend, BorderLayout.CENTER); add(scroll, BorderLayout.EAST); setText(txt); hist = new History(editable ? editor.text() : null); new BaseXPopup( this, editable ? new GUICommand[] { new FindCmd(), new FindNextCmd(), new FindPrevCmd(), null, new GotoCmd(), null, new UndoCmd(), new RedoCmd(), null, new AllCmd(), new CutCmd(), new CopyCmd(), new PasteCmd(), new DelCmd() } : new GUICommand[] { new FindCmd(), new FindNextCmd(), new FindPrevCmd(), null, new GotoCmd(), null, new AllCmd(), new CopyCmd() }); }