Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Making a little Lua script 'generator', JFrame showing up blank.

  1. #1

    Default Making a little Lua script 'generator', JFrame showing up blank.

    (This may have Netbeans XML left in)

    public class Main extends javax.swing.JFrame {
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
     
            jScrollPane1 = new javax.swing.JScrollPane();
            jTextArea1 = new javax.swing.JTextArea();
            jScrollPane2 = new javax.swing.JScrollPane();
            jTree1 = new javax.swing.JTree();
            jButton1 = new javax.swing.JButton();
            jButton2 = new javax.swing.JButton();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("Testable");
            setResizable(false);
     
            jTextArea1.setColumns(20);
            jTextArea1.setRows(5);
            jScrollPane1.setViewportView(jTextArea1);
     
            javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("root");
            javax.swing.tree.DefaultMutableTreeNode treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Events");
            javax.swing.tree.DefaultMutableTreeNode treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("Brick");
            javax.swing.tree.DefaultMutableTreeNode treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("OnTouched");
            javax.swing.tree.DefaultMutableTreeNode treeNode5 = new javax.swing.tree.DefaultMutableTreeNode("Delete the brick that touched");
            treeNode4.add(treeNode5);
            treeNode3.add(treeNode4);
            treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("OnTouched(by a player)");
            treeNode5 = new javax.swing.tree.DefaultMutableTreeNode("Kill the player");
            treeNode4.add(treeNode5);
            treeNode3.add(treeNode4);
            treeNode2.add(treeNode3);
            treeNode1.add(treeNode2);
            treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Actions");
            treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("Bricks");
            treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Dissappear(smooth)");
            treeNode3.add(treeNode4);
            treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Dissappear");
            treeNode3.add(treeNode4);
            treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Reappear(smooth)");
            treeNode3.add(treeNode4);
            treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Reappear");
            treeNode3.add(treeNode4);
            treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Move");
            treeNode5 = new javax.swing.tree.DefaultMutableTreeNode("Towards");
            javax.swing.tree.DefaultMutableTreeNode treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Nearest brick");
            treeNode5.add(treeNode6);
            treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Nearest player");
            treeNode5.add(treeNode6);
            treeNode4.add(treeNode5);
            treeNode5 = new javax.swing.tree.DefaultMutableTreeNode("Upwards (y+)");
            treeNode4.add(treeNode5);
            treeNode5 = new javax.swing.tree.DefaultMutableTreeNode("Downwards (y-)");
            treeNode4.add(treeNode5);
            treeNode5 = new javax.swing.tree.DefaultMutableTreeNode("To the left (x-)");
            treeNode4.add(treeNode5);
            treeNode5 = new javax.swing.tree.DefaultMutableTreeNode("To the right (x+)");
            treeNode4.add(treeNode5);
            treeNode5 = new javax.swing.tree.DefaultMutableTreeNode("To the other left (z-)");
            treeNode4.add(treeNode5);
            treeNode5 = new javax.swing.tree.DefaultMutableTreeNode("To the other right (z+)");
            treeNode4.add(treeNode5);
            treeNode3.add(treeNode4);
            treeNode2.add(treeNode3);
            treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("Other");
            treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Wait");
            treeNode5 = new javax.swing.tree.DefaultMutableTreeNode("Wait under a second");
            treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Wait one millisecond");
            treeNode5.add(treeNode6);
            treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Wait two milliseconds");
            treeNode5.add(treeNode6);
            treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Wait three milliseconds");
            treeNode5.add(treeNode6);
            treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Wait four milliseconds");
            treeNode5.add(treeNode6);
            treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Wait five milliseconds");
            treeNode5.add(treeNode6);
            treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Wait six milliseconds");
            treeNode5.add(treeNode6);
            treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Wait seven milliseconds");
            treeNode5.add(treeNode6);
            treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Wait two milliseconds");
            treeNode5.add(treeNode6);
            treeNode4.add(treeNode5);
            treeNode3.add(treeNode4);
            treeNode2.add(treeNode3);
            treeNode1.add(treeNode2);
            jTree1.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
            jTree1.setRootVisible(false);
            jScrollPane2.setViewportView(jTree1);
     
            jButton1.setText("Generate");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
                }
            });
     
            jButton2.setText("Help");
     
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE)
                        .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE))
                    .addContainerGap())
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addComponent(jButton2)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 278, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 38, Short.MAX_VALUE)))
                    .addContainerGap())
            );
     
            pack();
        }// </editor-fold>
     
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
            String text = this.jTextArea1.getText();
            String news = "";
            String[] lns = new String[100];
            int ll=0;
            int l=0;
            for(int i=0;i<text.length();i++) {
                if(text.substring(i,i).equals("\n")) {
                    lns[l] = text.substring(ll,i);
                    ll=i+1;
                    l++;
                }
            }
            for(int f =0;f<100;l++) {
                if(lns[f] != null) {
                    String c = lns[f];
                    if(c.equals("OnTouched")) {
                        news += "script.Parent.OnTouched:connect(function(hit)\n";
                    }
                    else if(c.equals("OnTouched(by a player)")) {
                        news += "script.Parent.OnTouched:connect(function(hit)\n\tif(not hit.Parent:findFirstChild(\"Humanoid\")) then\n\t\treturn;\n\\n";
                    }
                    else if(c.equals("Kill the player")) {
                        news += "\thit.Parent.Humanoid.Health = 0;\n";
                    }
                    else if(c.equals("Delete the brick that touched")) {
                        news += "\thit:remove();\n";
                    }
                }
            }
        }
     
         /**
          * @param args 
         */
        public static void main(String[] args) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new Main().setVisible(true);
                }
            });
        }
        // Variables declaration - do not modify
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JScrollPane jScrollPane2;
        private javax.swing.JTextArea jTextArea1;
        private javax.swing.JTree jTree1;
        // End of variables declaration
    }

    Can I have some help please? Thank you.


  2. #2

    Default Re: Making a little Lua script 'generator', JFrame showing up blank.

    I don't mean to be impatient but I haven't got this laptop for long..

  3. #3

    Default Re: Making a little Lua script 'generator', JFrame showing up blank.

    Please can somebody respond? I'm getting impatient. Woah. That's rare.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,301
    Thanks
    181
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: Making a little Lua script 'generator', JFrame showing up blank.

    Not sure how much bumping the thread will help in getting quicker responses....

    Anyway, I don't see where anything is added to the JFrame

    frame.getContentPane().add(/*The component you wish to add to the JFrame/*);

  5. #5

    Default Re: Making a little Lua script 'generator', JFrame showing up blank.

    Also, even the title doesn't change from "" to "Testable"

  6. #6

    Default Re: Making a little Lua script 'generator', JFrame showing up blank.

    4 hours and waiting...

Similar Threads

  1. Showing database results
    By randyrr in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 27th, 2010, 11:26 PM
  2. JTable gridlines not showing in a nimbus L&F
    By chronoz13 in forum AWT / Java Swing
    Replies: 0
    Last Post: February 22nd, 2010, 06:45 AM
  3. Showing a picture in a GUI
    By joachim89 in forum AWT / Java Swing
    Replies: 1
    Last Post: February 15th, 2010, 01:42 PM
  4. Java password generator program to generate 8 random integers
    By Lizard in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 16th, 2009, 07:49 AM
  5. [SOLVED] Random number method implementation
    By big_c in forum Java Theory & Questions
    Replies: 2
    Last Post: April 15th, 2009, 01:10 PM