/www/tags/NOV_07_2009/htdocs/42docs/users-guide/plugin-implement-quicknotepadtoolbar.html
HTML | 55 lines | 51 code | 4 blank | 0 comment | 0 complexity | ed4401c851b66be54b3d9fabb9ed8489 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
- <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>The QuickNotepadToolBar Class</title><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="jEdit 4.2 User's Guide"><link rel="up" href="plugin-implement.html" title="Chapter 18. Implementing a Simple Plugin"><link rel="previous" href="plugin-implement-quicknotepad.html" title="The QuickNotepad Class"><link rel="next" href="plugin-implement-options.html" title="The QuickNotepadOptionPane Class"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">The QuickNotepadToolBar Class</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="plugin-implement-quicknotepad.html">Prev</a> </td><th width="60%" align="center">Chapter 18. Implementing a Simple Plugin</th><td width="20%" align="right"> <a accesskey="n" href="plugin-implement-options.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="plugin-implement-quicknotepadtoolbar"></a>The QuickNotepadToolBar Class</h2></div></div><div></div></div><p>
- There is nothing remarkable about the toolbar panel that is placed
- inside the <tt class="classname">QuickNotepad</tt> object. The constructor
- shows the continued use of items from the plugin's properties file.
- </p><div class="informalexample"><table border="0" bgcolor="#E0E0E0"><tr><td><pre class="programlisting">public class QuickNotepadToolPanel extends JPanel
- {
- private QuickNotepad pad;
- private JLabel label;
- public QuickNotepadToolPanel(QuickNotepad qnpad)
- {
- pad = qnpad;
- JToolBar toolBar = new JToolBar();
- toolBar.setFloatable(false);
- toolBar.add(makeCustomButton("quicknotepad.choose-file",
- new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- QuickNotepadToolPanel.this.pad.chooseFile();
- }
- }));
- toolBar.add(makeCustomButton("quicknotepad.save-file",
- new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- QuickNotepadToolPanel.this.pad.saveFile();
- }
- }));
- toolBar.add(makeCustomButton("quicknotepad.copy-to-buffer",
- new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- QuickNotepadToolPanel.this.pad.copyToBuffer();
- }
- }));
- label = new JLabel(pad.getFilename(),
- SwingConstants.RIGHT);
- label.setForeground(Color.black);
- label.setVisible(jEdit.getProperty(
- QuickNotepadPlugin.OPTION_PREFIX
- + "show-filepath").equals("true"));
- this.setLayout(new BorderLayout(10, 0));
- this.add(BorderLayout.WEST, toolBar);
- this.add(BorderLayout.CENTER, label);
- this.setBorder(BorderFactory.createEmptyBorder(0, 0, 3, 10));
- }
- ...
- }</pre></td></tr></table></div><p>
- The method <tt class="classname">makeCustomButton()</tt> provides uniform
- attributes for the three toolbar buttons corresponding to three of the
- plugin's use actions. The menu titles for the user actions serve double
- duty as tooltip text for the buttons. There is also a
- <tt class="function">propertiesChanged()</tt> method for the toolbar that
- sets the text and visibility of the label containing the notepad file path.
- </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="plugin-implement-quicknotepad.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="plugin-implement.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="plugin-implement-options.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">The QuickNotepad Class </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> The QuickNotepadOptionPane Class</td></tr></table></div></body></html>