PageRenderTime 234ms CodeModel.GetById 219ms app.highlight 5ms RepoModel.GetById 7ms app.codeStats 0ms

/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
 1<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>
 2  There is nothing remarkable about the toolbar panel that is placed
 3  inside the <tt class="classname">QuickNotepad</tt> object. The constructor
 4  shows the continued use of items from the plugin's properties file.
 5</p><div class="informalexample"><table border="0" bgcolor="#E0E0E0"><tr><td><pre class="programlisting">public class QuickNotepadToolPanel extends JPanel
 6{
 7    private QuickNotepad pad;
 8    private JLabel label;
 9
10    public QuickNotepadToolPanel(QuickNotepad qnpad)
11    {
12        pad = qnpad;
13        JToolBar toolBar = new JToolBar();
14        toolBar.setFloatable(false);
15
16        toolBar.add(makeCustomButton("quicknotepad.choose-file",
17            new ActionListener() {
18                public void actionPerformed(ActionEvent evt) {
19                    QuickNotepadToolPanel.this.pad.chooseFile();
20                }
21            }));
22        toolBar.add(makeCustomButton("quicknotepad.save-file",
23            new ActionListener() {
24                public void actionPerformed(ActionEvent evt) {
25                    QuickNotepadToolPanel.this.pad.saveFile();
26                }
27            }));
28        toolBar.add(makeCustomButton("quicknotepad.copy-to-buffer",
29            new ActionListener() {
30                public void actionPerformed(ActionEvent evt) {
31                    QuickNotepadToolPanel.this.pad.copyToBuffer();
32                }
33            }));
34        label = new JLabel(pad.getFilename(),
35            SwingConstants.RIGHT);
36        label.setForeground(Color.black);
37        label.setVisible(jEdit.getProperty(
38            QuickNotepadPlugin.OPTION_PREFIX
39            + "show-filepath").equals("true"));
40        this.setLayout(new BorderLayout(10, 0));
41        this.add(BorderLayout.WEST, toolBar);
42        this.add(BorderLayout.CENTER, label);
43        this.setBorder(BorderFactory.createEmptyBorder(0, 0, 3, 10));
44    }
45
46    ...
47
48}</pre></td></tr></table></div><p>
49  The method <tt class="classname">makeCustomButton()</tt> provides uniform
50  attributes for the three toolbar buttons corresponding to three of the
51  plugin's use actions.  The menu titles for the user actions serve double
52  duty as tooltip text for the buttons. There is also a
53  <tt class="function">propertiesChanged()</tt> method for the toolbar that
54  sets the text and visibility of the label containing the notepad file path.
55</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>