Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Participants: Ben Allen * Stephanie August * Damon Loren Baker * Theo Ellin Ballew * Ivette Bayo Urban * John Bell * Paisley Benaza * Kathi Berens * David Berry * Sayan Bhattacharyya * Christina Boyles * Gregory Bringman * André Brock * Ron Burkey * Evan Buswell * Sarah Ciston * Eileen Clancy * Tara Conley * Krystal Cooper * Ranjodh Dhaliwal * Anthony Di Franco * Craig Dietrich * Jeremy Douglass * Kevin Driscoll * William Dyson * Brandee Easter * Martin Erwig * Schuyler Esprit * Max Feinstein * Todd Furmanski * Geoffrey Gimse * Erin Glass * Rochelle Gold * Catherine Griffiths * Ben Grosser * Fox Harrell * Sydette Harry * Brendan Howell * Nazua Idris * Jessica Johnson * Waliya Yohanna Joseph * Ted Kafala * Dorothy Kim * Corinna Kirsch * Steve Klabnik * Shelly Knotts * Peter Kudenov * Fidelia Lam * Liz Losh * Thor Magnusson * Jim Malazita * Judy Malloy * Zach Mann * Mark Marino * Lauren McCarthy * Irma McClaurin * Patrick McDonnell * Tara McPherson * Todd Milstein * Nick Montfort * Mark Neal * Safiya Noble * Keith O'Hara * David Ogborn * Allison Parrish * Ali Pearl * Gerol Petruzella * Andrew Pilsch * Samuel Pizelo * Jessica Pressman * Helen Pritchard * Daniel Punday * Kristopher Purzycki * Harvey Quamen * Amit Ray * Margaret Rhee * Lisa Rhody * Scott Richmond * Teddy Roland * Jamal Russell * Anastasia Salter * Mark Sample * Evan Schauer * Ari Schlesinger * Mehdy Sedaghat Payam * Ash Smith * Winnie Soon * Glen Southergill * Mel Stanfill * Samara Hayley Steele * Nikki Stevens * Tonia Sutherland * Miriam Sweeney * Ezra Teboul * Daniel Temkin * Dennis Tenen * Marilyn M. Thomas-Houston * Elizabeth Timbs * Giuseppe Torre * Rebecca Uliasz * Annette Vee * Sneha Veeragoudar * Ashleigh Wade * Kurt James Werner * Jacque Wernimont * Zach Whalen * Roger Whitson * Roger Whitson * Michael Widner * Jody Zellen * Kai Zhang
Coordinated by Mark Marino (USC), Jeremy Douglass (UCSB), Catherine Griffiths (USC), Ali Rachel Pearl (USC), and Teddy Roland (UCSB). Sponsored by the Humanities and Critical Code Studies Lab (USC), and the Digital Arts and Humanities Commons (UCSB).

Code that made me quit programming

This discussion was created from comments split from: Code and computer's creativity? hmmm....

Comments

  • edited January 24

    This is the code that made me to quit programming. I took me 12 hours to code this on netbeans but I could not fix it. Please somebody should help me fix this error. I will be grateful to you.

    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package biblereader;
    
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.IOException;
    import javax.swing.JFileChooser;
    import javax.swing.JOptionPane;
    
    /**
     *
     * @author Yohanna
     */
    public class FileReader extends javax.swing.JFrame {
        private static final long serialVersionUID = 1L;
    
        /**
         * Creates new form FileReader
         */
        public FileReader() {
            initComponents();
        }
    
        private FileReader(String filename) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    
        /**
         * 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">                          
        private void initComponents() {
    
            jButton1 = new javax.swing.JButton();
            jScrollPane1 = new javax.swing.JScrollPane();
            jTextArea1 = new javax.swing.JTextArea();
    
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("Bible Reading Kits");
            setFont(new java.awt.Font("Algerian", 0, 10)); // NOI18N
            setForeground(new java.awt.Color(255, 0, 51));
            setName("Bible Standard"); // NOI18N
    
            jButton1.setForeground(new java.awt.Color(255, 51, 51));
            jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/biblereader/Bible.jpg"))); // NOI18N
            jButton1.setText("Read your Bible Always");
            jButton1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
            jButton1.setDebugGraphicsOptions(javax.swing.DebugGraphics.BUFFERED_OPTION);
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
                }
            });
    
            jTextArea1.setEditable(false);
            jTextArea1.setBackground(new java.awt.Color(51, 51, 255));
            jTextArea1.setColumns(20);
            jTextArea1.setFont(new java.awt.Font("MS Gothic", 0, 14)); // NOI18N
            jTextArea1.setForeground(new java.awt.Color(255, 51, 204));
            jTextArea1.setLineWrap(true);
            jTextArea1.setRows(5);
            jTextArea1.setWrapStyleWord(true);
            jTextArea1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Bible Standard Life", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12), new java.awt.Color(255, 255, 255))); // NOI18N
            jTextArea1.setCaretColor(new java.awt.Color(204, 255, 102));
            jTextArea1.setSelectionColor(new java.awt.Color(0, 255, 153));
            jScrollPane1.setViewportView(jTextArea1);
    
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(23, 23, 23)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jScrollPane1)
                        .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 482, Short.MAX_VALUE))
                    .addContainerGap())
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            );
    
            pack();
        }// </editor-fold>                        
    
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        JFileChooser chooser = new JFileChooser();
        chooser.showOpenDialog(null);
        File f = chooser.getSelectedFile();
        String filename = f.getAbsolutePath();
    
        try {
        FileReader reader = new FileReader(filename);
        BufferedReader br = new BufferedReader(reader);
    
        jTextArea1.read(br, null);
        br.close();
        jTextArea1.requestFocus();
        }
        catch(IOException e){
        JOptionPane.showMessageDialog(null, e);
        }
        }                                        
    
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            /* Set the Nimbus look and feel */
            //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
            /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
             * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
             */
            try {
                for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                    if ("Nimbus".equals(info.getName())) {
                        javax.swing.UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
            } catch (ClassNotFoundException ex) {
                java.util.logging.Logger.getLogger(FileReader.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                java.util.logging.Logger.getLogger(FileReader.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                java.util.logging.Logger.getLogger(FileReader.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (javax.swing.UnsupportedLookAndFeelException ex) {
                java.util.logging.Logger.getLogger(FileReader.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            }
            //</editor-fold>
    
            /* Create and display the form */
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new FileReader().setVisible(true);
                }
            });
        }
    
        // Variables declaration - do not modify                     
        private javax.swing.JButton jButton1;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JTextArea jTextArea1;
        // End of variables declaration                   
    }
    

    The result:

    /FileReader.java:107: error: incompatible types: FileReader cannot be converted to Reader
        BufferedReader br = new BufferedReader(reader);
                                               ^
    Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
    1 error
    
  • I need the CCS to start the criticism because this code knocked me out of programming entirely when I was frustrated. I need solution to it plus a new suggestion to improve it.

  • edited January 24

    Hi @Waliya --

    CCS Working Group may not be the best place to get specific debugging advice on Java programming -- in general it is more for talking about code in culture, not helping to debug fix programs that aren't working.

    If you do want help with your program, I would recommend a site like Stackoverflow. To get best results there, first search the error message and make sure there isn't already an answer to your question. Then, if posting a question, make sure you have posted an MCVE -- a Minimal, Complete, Verifiable Example. In particular, when posting to a forum for code help, notice this part of the advice:

    Describe the problem. "It doesn't work" is not a problem statement. Tell us what the expected behavior should be. Tell us what the exact wording of the error message is, and which line of code is producing it. Put a brief summary of the problem in the title of your question.

    So people trying to help would want to know what you expected the code to do once it was working correctly -- and, if you are modifying existing code, it might also help them to know where you got it from and what you were trying to change about it when it broke.

  • edited January 24

    One aspect of your question that in my opinion would make a good CCS topic of general interest is "code that makes people quit" -- quit a language, quit programming, et cetera. So for example it might be productive as a general discussion to ask forum members to reflect of stories of the specific code examples or languages tools etc. that made them quit something, or that they saw stopping or frustrating others. I would guess that many people have similar stories....

  • Thanks sir @jeremydouglass The code I posted above is supposed to open a GUI frame for someone to upload .txt extension document in order to read it. But, the BufferedReader code on line 107 refused to convert the filename and the results was read thus:
    FileReader.java:107: error: incompatible types: FileReader cannot be converted to Reader
    BufferedReader br = new BufferedReader(reader);
    ^
    Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
    1 error. This complexity was what knocked me out of coding.

Sign In or Register to comment.