PageRenderTime 36ms CodeModel.GetById 10ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/org/gjt/sp/jedit/gui/TextAreaDialog.java

#
Java | 134 lines | 81 code | 21 blank | 32 comment | 0 complexity | e87e70c84ff6f2bfa33a0d2861482f66 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. /*
  2. * TextAreaDialog.java - A dialog box with a text area
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 2001, 2003 Slava Pestov
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. */
  22. package org.gjt.sp.jedit.gui;
  23. //{{{ Imports
  24. import javax.swing.*;
  25. import javax.swing.border.*;
  26. import java.awt.*;
  27. import java.awt.event.*;
  28. import org.gjt.sp.jedit.*;
  29. //}}}
  30. public class TextAreaDialog extends EnhancedDialog
  31. {
  32. //{{{ TextAreaDialog constructor
  33. public TextAreaDialog(Frame frame, String title, String caption,
  34. Icon icon, String text)
  35. {
  36. super(frame,title,true);
  37. init(caption,icon,text);
  38. } //}}}
  39. //{{{ TextAreaDialog constructor
  40. public TextAreaDialog(Frame frame, String name, Throwable t)
  41. {
  42. this(frame,jEdit.getProperty(name + ".title"),
  43. jEdit.getProperty(name + ".message"),
  44. UIManager.getIcon("OptionPane.errorIcon"),
  45. MiscUtilities.throwableToString(t));
  46. } //}}}
  47. //{{{ TextAreaDialog constructor
  48. public TextAreaDialog(Dialog frame, String title, String caption,
  49. Icon icon, String text)
  50. {
  51. super(frame,title,true);
  52. init(caption,icon,text);
  53. } //}}}
  54. //{{{ TextAreaDialog constructor
  55. public TextAreaDialog(Dialog frame, String name, Throwable t)
  56. {
  57. this(frame,jEdit.getProperty(name + ".title"),
  58. jEdit.getProperty(name + ".message"),
  59. UIManager.getIcon("OptionPane.errorIcon"),
  60. MiscUtilities.throwableToString(t));
  61. } //}}}
  62. //{{{ init() method
  63. private void init(String caption,
  64. Icon icon, String text)
  65. {
  66. JPanel content = new JPanel(new BorderLayout(12,12));
  67. content.setBorder(new EmptyBorder(12,12,12,12));
  68. setContentPane(content);
  69. Box iconBox = new Box(BoxLayout.Y_AXIS);
  70. iconBox.add(new JLabel(icon));
  71. iconBox.add(Box.createGlue());
  72. content.add(BorderLayout.WEST,iconBox);
  73. JPanel centerPanel = new JPanel(new BorderLayout(6,6));
  74. centerPanel.add(BorderLayout.NORTH,
  75. GUIUtilities.createMultilineLabel(caption));
  76. JTextArea textArea = new JTextArea(10,80);
  77. textArea.setText(text);
  78. textArea.setLineWrap(true);
  79. textArea.setCaretPosition(0);
  80. centerPanel.add(BorderLayout.CENTER,new JScrollPane(textArea));
  81. content.add(BorderLayout.CENTER,centerPanel);
  82. Box buttons = new Box(BoxLayout.X_AXIS);
  83. buttons.add(Box.createGlue());
  84. JButton ok = new JButton(jEdit.getProperty("common.ok"));
  85. ok.addActionListener(new ActionHandler());
  86. buttons.add(ok);
  87. buttons.add(Box.createGlue());
  88. content.add(BorderLayout.SOUTH,buttons);
  89. getRootPane().setDefaultButton(ok);
  90. pack();
  91. setLocationRelativeTo(getParent());
  92. setVisible(true);
  93. } //}}}
  94. //{{{ ok() method
  95. public void ok()
  96. {
  97. dispose();
  98. } //}}}
  99. //{{{ cancel() method
  100. public void cancel()
  101. {
  102. dispose();
  103. } //}}}
  104. //{{{ ActionHandler class
  105. class ActionHandler implements ActionListener
  106. {
  107. //{{{ actionPerformed() method
  108. public void actionPerformed(ActionEvent evt)
  109. {
  110. dispose();
  111. } //}}}
  112. } //}}}
  113. }