mgtube

Untitled

Jan 14th, 2018
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.30 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package scptest;
  7.  
  8. import javax.swing.BoxLayout;
  9. import static javax.swing.BoxLayout.PAGE_AXIS;
  10. import javax.swing.JViewport;
  11.  
  12. /**
  13.  *
  14.  * @author mgtub
  15.  */
  16. public class FrmTest extends javax.swing.JFrame {
  17.  
  18.     /**
  19.      * Creates new form FrmTest
  20.      */
  21.     public FrmTest() {
  22.         initComponents();
  23.     }
  24.  
  25.     /**
  26.      * This method is called from within the constructor to initialize the form.
  27.      * WARNING: Do NOT modify this code. The content of this method is always
  28.      * regenerated by the Form Editor.
  29.      */
  30.     @SuppressWarnings("unchecked")
  31.     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  32.     private void initComponents() {
  33.  
  34.         scpNotes = new javax.swing.JScrollPane();
  35.         pnlNotes = new javax.swing.JPanel();
  36.         btnAdd = new javax.swing.JButton();
  37.  
  38.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  39.         setMinimumSize(new java.awt.Dimension(326, 517));
  40.  
  41.         scpNotes.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  42.         scpNotes.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  43.  
  44.         pnlNotes.setLayout(new javax.swing.BoxLayout(pnlNotes, javax.swing.BoxLayout.Y_AXIS));
  45.         scpNotes.setViewportView(pnlNotes);
  46.  
  47.         btnAdd.setText("Add text");
  48.         btnAdd.addActionListener(new java.awt.event.ActionListener() {
  49.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  50.                 btnAddActionPerformed(evt);
  51.             }
  52.         });
  53.  
  54.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  55.         getContentPane().setLayout(layout);
  56.         layout.setHorizontalGroup(
  57.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  58.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  59.                 .addContainerGap()
  60.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  61.                     .addComponent(scpNotes)
  62.                     .addGroup(layout.createSequentialGroup()
  63.                         .addGap(0, 231, Short.MAX_VALUE)
  64.                         .addComponent(btnAdd)))
  65.                 .addContainerGap())
  66.         );
  67.         layout.setVerticalGroup(
  68.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  69.             .addGroup(layout.createSequentialGroup()
  70.                 .addContainerGap()
  71.                 .addComponent(scpNotes, javax.swing.GroupLayout.DEFAULT_SIZE, 461, Short.MAX_VALUE)
  72.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  73.                 .addComponent(btnAdd)
  74.                 .addContainerGap())
  75.         );
  76.  
  77.         pack();
  78.     }// </editor-fold>                        
  79.  
  80.     private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {                                      
  81.         PnlText t = new PnlText();
  82.         pnlNotes.add(t, 0);
  83.         scpNotes.setViewportView(pnlNotes);
  84.         scpNotes.validate();
  85.     }                                      
  86.  
  87.     /**
  88.      * @param args the command line arguments
  89.      */
  90.     public static void main(String args[]) {
  91.         /* Set the Nimbus look and feel */
  92.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  93.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  94.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  95.          */
  96.         try {
  97.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  98.                 if ("Windows".equals(info.getName())) {
  99.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  100.                     break;
  101.                 }
  102.             }
  103.         } catch (ClassNotFoundException ex) {
  104.             java.util.logging.Logger.getLogger(FrmTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  105.         } catch (InstantiationException ex) {
  106.             java.util.logging.Logger.getLogger(FrmTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  107.         } catch (IllegalAccessException ex) {
  108.             java.util.logging.Logger.getLogger(FrmTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  109.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  110.             java.util.logging.Logger.getLogger(FrmTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  111.         }
  112.         //</editor-fold>
  113.  
  114.         /* Create and display the form */
  115.         java.awt.EventQueue.invokeLater(new Runnable() {
  116.             public void run() {
  117.                 new FrmTest().setVisible(true);
  118.             }
  119.         });
  120.     }
  121.  
  122.     // Variables declaration - do not modify                    
  123.     private javax.swing.JButton btnAdd;
  124.     private javax.swing.JPanel pnlNotes;
  125.     private javax.swing.JScrollPane scpNotes;
  126.     // End of variables declaration                  
  127. }
Add Comment
Please, Sign In to add comment