MaxxxxiorS

drugieokno.java

Jan 18th, 2019 (edited)
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.43 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3. import java.util.logging.Level;
  4. import java.util.logging.Logger;
  5. import javax.swing.JOptionPane;
  6.  
  7. /*
  8.  * To change this license header, choose License Headers in Project Properties.
  9.  * To change this template file, choose Tools | Templates
  10.  * and open the template in the editor.
  11.  */
  12.  
  13. /**
  14.  *
  15.  * @author TI
  16.  */
  17. public class opis extends javax.swing.JFrame {
  18.  
  19.     /**
  20.      * Creates new form opis
  21.      */
  22.     public opis() {
  23.         initComponents();
  24.     }
  25.  
  26.     /**
  27.      * This method is called from within the constructor to initialize the form.
  28.      * WARNING: Do NOT modify this code. The content of this method is always
  29.      * regenerated by the Form Editor.
  30.      */
  31.     @SuppressWarnings("unchecked")
  32.     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  33.     private void initComponents() {
  34.  
  35.         jTextField1 = new javax.swing.JTextField();
  36.         jLabel1 = new javax.swing.JLabel();
  37.         plyr = new javax.swing.JLabel();
  38.         ta = new javax.swing.JButton();
  39.  
  40.         jTextField1.setText("jTextField1");
  41.         jTextField1.addActionListener(new java.awt.event.ActionListener() {
  42.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  43.                 jTextField1ActionPerformed(evt);
  44.             }
  45.         });
  46.  
  47.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  48.  
  49.         jLabel1.setText("Witaj");
  50.  
  51.         ta.setText("jButton1");
  52.         ta.addActionListener(new java.awt.event.ActionListener() {
  53.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  54.                 taActionPerformed(evt);
  55.             }
  56.         });
  57.  
  58.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  59.         getContentPane().setLayout(layout);
  60.         layout.setHorizontalGroup(
  61.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  62.             .addGroup(layout.createSequentialGroup()
  63.                 .addGap(78, 78, 78)
  64.                 .addComponent(jLabel1)
  65.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  66.                 .addComponent(plyr, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
  67.                 .addContainerGap(220, Short.MAX_VALUE))
  68.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  69.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  70.                 .addComponent(ta)
  71.                 .addGap(59, 59, 59))
  72.         );
  73.         layout.setVerticalGroup(
  74.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  75.             .addGroup(layout.createSequentialGroup()
  76.                 .addGap(68, 68, 68)
  77.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  78.                     .addComponent(plyr, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
  79.                     .addComponent(jLabel1))
  80.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 131, Short.MAX_VALUE)
  81.                 .addComponent(ta)
  82.                 .addGap(64, 64, 64))
  83.         );
  84.  
  85.         pack();
  86.     }// </editor-fold>                        
  87.  
  88.     private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {                                            
  89.  
  90.     }                                          
  91.  
  92.     private void taActionPerformed(java.awt.event.ActionEvent evt) {                                  
  93.         File f = new File("player.txt");
  94.        
  95.         try {
  96.             FileReader fr = new FileReader(f);
  97.             int ch = fr.read();
  98.            
  99.             while(ch != -1)
  100.             {
  101.                 System.out.print((char) ch);
  102.  
  103.                 //plyr.setText((char) ch);
  104.                 ch = fr.read();
  105.             }
  106.         } catch(Exception ex){
  107.        
  108.         }
  109.     }                                  
  110.  
  111.     /**
  112.      * @param args the command line arguments
  113.      */
  114.     public static void main(String args[]) {
  115.         /* Set the Nimbus look and feel */
  116.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  117.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  118.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  119.          */
  120.        
  121.         //BufferedReader br = new BufferedReader(new FileReader("your_file.txt"));
  122.         //String line = br.readLine();
  123.         //ArrayList<String> listOfStrings = new ArrayList<>();
  124.         //player.add(line);
  125.        
  126.         //while(line != null)
  127.         //{
  128.         //    line = br.readLine();
  129.         //    player.add(line);
  130.         //}
  131.        
  132.        
  133.  
  134.        
  135.        
  136.        
  137.         //
  138.        
  139.         try {
  140.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  141.                 if ("Nimbus".equals(info.getName())) {
  142.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  143.                     break;
  144.                 }
  145.             }
  146.         } catch (ClassNotFoundException ex) {
  147.             java.util.logging.Logger.getLogger(opis.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  148.         } catch (InstantiationException ex) {
  149.             java.util.logging.Logger.getLogger(opis.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  150.         } catch (IllegalAccessException ex) {
  151.             java.util.logging.Logger.getLogger(opis.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  152.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  153.             java.util.logging.Logger.getLogger(opis.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  154.         }
  155.         //</editor-fold>
  156.  
  157.         /* Create and display the form */
  158.         java.awt.EventQueue.invokeLater(new Runnable() {
  159.             public void run() {
  160.                 new opis().setVisible(true);
  161.             }
  162.         });
  163.        
  164.     }
  165.  
  166.     // Variables declaration - do not modify                    
  167.     private javax.swing.JLabel jLabel1;
  168.     private javax.swing.JTextField jTextField1;
  169.     private javax.swing.JLabel plyr;
  170.     private javax.swing.JButton ta;
  171.     // End of variables declaration                  
  172. }
Add Comment
Please, Sign In to add comment