/* * Copyright (c) 2015, Skylar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ package com.netsyms.symat.padview; import static com.netsyms.symat.padview.GUI.logo; /** * * @author Skylar */ public class PopoutView extends javax.swing.JFrame { /** * Creates new form PopoutView * @param content * @param title */ public PopoutView(String content, String title) { initComponents(); setIconImages(logo); textBox.setText(content); setTitle(getTitle() + title); if (!PrefStorage.getSetting("wrapLines").equals("")) { wrapLines.setSelected(true); wrap(wrapLines.isSelected()); } } /** * 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") // //GEN-BEGIN:initComponents private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); textBox = new javax.swing.JTextArea(); closeBtn = new javax.swing.JButton(); wrapLines = new javax.swing.JCheckBox(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Preview: "); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); textBox.setEditable(false); textBox.setColumns(1); textBox.setRows(1); textBox.setTabSize(4); jScrollPane1.setViewportView(textBox); closeBtn.setText("Close"); closeBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { closeBtnActionPerformed(evt); } }); wrapLines.setText("Wrap long lines"); wrapLines.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { wrapLinesActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1) .addGroup(layout.createSequentialGroup() .addComponent(wrapLines) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 242, Short.MAX_VALUE) .addComponent(closeBtn)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(closeBtn) .addComponent(wrapLines)) .addGap(0, 0, 0) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)) ); pack(); setLocationRelativeTo(null); }// //GEN-END:initComponents private void wrapLinesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_wrapLinesActionPerformed wrap(wrapLines.isSelected()); }//GEN-LAST:event_wrapLinesActionPerformed private void wrap(boolean wrap) { textBox.setLineWrap(wrap); textBox.setWrapStyleWord(wrap); } private void save() { PrefStorage.saveSetting("wrapLines", (wrapLines.isSelected() ? "yes" : "")); } private void closeBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeBtnActionPerformed save(); dispose(); }//GEN-LAST:event_closeBtnActionPerformed private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing save(); }//GEN-LAST:event_formWindowClosing // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton closeBtn; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextArea textBox; private javax.swing.JCheckBox wrapLines; // End of variables declaration//GEN-END:variables }