EditorPanel.java
/*
* Copyright 2013 Michael Mackenzie High
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mackenziehigh.snowflake.designer.gui.tabs;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JMenuItem;
import javax.swing.JTextArea;
import javax.swing.text.DefaultEditorKit;
/**
*
* @author mackenzie
*/
public class EditorPanel
extends javax.swing.JPanel
{
/**
* Creates new form EditorPanel
*/
public EditorPanel()
{
initComponents();
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents()
{
editorTextboxPopupMenu = new javax.swing.JPopupMenu();
jScrollPane2 = new javax.swing.JScrollPane();
editor_textbox = new javax.swing.JTextArea();
editorTextboxPopupMenu.setName("editorTextboxPopupMenu"); // NOI18N
editor_textbox.add(editorTextboxPopupMenu);
editor_textbox.setComponentPopupMenu(editorTextboxPopupMenu);
//
// Create the "Cut" menu item.
final JMenuItem cut = new JMenuItem(new DefaultEditorKit.CutAction());
cut.setText("Cut");
editorTextboxPopupMenu.add(cut);
//
// Create the "Copy" menu item.
final JMenuItem copy = new JMenuItem(new DefaultEditorKit.CopyAction());
copy.setText("Copy");
editorTextboxPopupMenu.add(copy);
//
// Create the "Paste" menu item.
final JMenuItem paste = new JMenuItem(new DefaultEditorKit.PasteAction());
paste.setText("Paste");
editorTextboxPopupMenu.add(paste);
//
// Add a horizontal separator.
editorTextboxPopupMenu.addSeparator();
//
// Create the "Select All" menu item.
final JMenuItem selectAll = new JMenuItem(new SelectAllAction());
selectAll.setText("Select All");
editorTextboxPopupMenu.add(selectAll);
setName("Form"); // NOI18N
jScrollPane2.setName("jScrollPane2"); // NOI18N
editor_textbox.setColumns(20);
editor_textbox.setRows(5);
editor_textbox.setName("editor_textbox"); // NOI18N
jScrollPane2.setViewportView(editor_textbox);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPopupMenu editorTextboxPopupMenu;
private javax.swing.JTextArea editor_textbox;
private javax.swing.JScrollPane jScrollPane2;
// End of variables declaration//GEN-END:variables
private final class SelectAllAction
extends AbstractAction
{
public void actionPerformed(ActionEvent e)
{
editor_textbox.selectAll();
}
}
public JTextArea getTextArea()
{
return editor_textbox;
}
}