This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-11-16 16:30:05

poopo
Scratcher
Registered: 2009-09-20
Posts: 1000+

Java Help

For some reason netbeans won't display my container it just says:
run:
BUILD SUCCESSFUL (total time: 1 second)
If you know please tell me. I probably just made some stupid mistake.  tongue
Here is my code:

Code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class ChatBot extends JFrame implements ActionListener{
    String[][] sayings = new String[500][5];
    JTextArea bot = new JTextArea("Start the Conversation.");
    JScrollPane scroller = new JScrollPane(bot);
    public void ChatBot(){
        setTitle("ChatBot");
        setSize(600, 600);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        GridLayout grid = new GridLayout(2,1);
        setLayout(grid);
        add(scroller);
        setVisible(true);

    }
    public void actionPerformed(ActionEvent event){

    }
    public static void main(String args[]){
        ChatBot hi = new ChatBot();
    }
}

Yes I do plan to do a lot more.

Last edited by poopo (2011-11-25 12:36:55)


http://i45.tinypic.com/28rnqki.jpg

Offline

 

#2 2011-11-16 17:33:17

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Java Help

You need to remove 'void' from the ChatBot constructor.

Code:

public void ChatBot()

bcomes:

Code:

public ChatBot(){

http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#3 2011-11-16 20:14:16

poopo
Scratcher
Registered: 2009-09-20
Posts: 1000+

Re: Java Help

MathWizz wrote:

You need to remove 'void' from the ChatBot constructor.

Code:

public void ChatBot()

bcomes:

Code:

public ChatBot(){

But then it won't it require a return?


http://i45.tinypic.com/28rnqki.jpg

Offline

 

#4 2011-11-16 20:34:44

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Java Help

poopo wrote:

MathWizz wrote:

You need to remove 'void' from the ChatBot constructor.

Code:

public void ChatBot()

bcomes:

Code:

public ChatBot(){

But then it won't it require a return?

Constructors do not return anything.


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#5 2011-11-17 08:26:09

poopo
Scratcher
Registered: 2009-09-20
Posts: 1000+

Re: Java Help

MathWizz wrote:

poopo wrote:

MathWizz wrote:

You need to remove 'void' from the ChatBot constructor.

Code:

public void ChatBot()

bcomes:

Code:

public ChatBot(){

But then it won't it require a return?

Constructors do not return anything.

Thanks a lot!  smile


http://i45.tinypic.com/28rnqki.jpg

Offline

 

#6 2011-11-17 10:01:23

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Java Help

poopo wrote:

Thanks a lot!  smile

Glad I could help.  smile


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

Board footer