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