JTextAreaProblem

i am trying to create a Graphical User Interface using a JTextArea method in a java application

At the moment i have only included one panel in it at the moment but am going to add more later

import java.awt.*;

import javax.swing.*;

public class Marina extends JFrame

{

//This is a Graphical User Interface built in a Java application for the java revisited courrsework

//i am using a JtextArea in order to create the graphical User Interface

JTextArea Gui = new JTextArea(60, 30);

public Marina() {

//.I am now using panels to edit the gui

JPanel panel1 = new JPanel();

panel1.setLayout(new BorderLayout());

panel1.add(BorderLayout.CENTER);

//... Set window characteristics.

this.setContentPane(panel1);

this.setTitle("Marina");

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.pack();

}

//the main method for my program

public static void main(String[] args){

JFrame frame1 = new Marina();

Marina.setVisible(true);

}

}

I get these errors from the program

panel1.add(BorderLayout.CENTER);

^

H:\Marina.java:34: non-static method setVisible(boolean) cannot be referenced from a static context

Marina.setVisible(true);

basically i just need to know how to solve these errors so that i can display a simple JtextArea on the screen

[1432 byte] By [jonathanca] at [2007-11-27 6:58:14]
# 1

Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the posted code retains its original formatting.

> JPanel panel1 = new JPanel();

> panel1.setLayout(new BorderLayout());

> panel1.add(BorderLayout.CENTER);

Look at your code above. You create a class and then reference the variable when you want to modify a property of the class

> JFrame frame1 = new Marina();

> Marina.setVisible(true);

Now look at this code. You try to reference the class not the variable.

camickra at 2007-7-12 18:48:51 > top of Java-index,Java Essentials,Java Programming...
# 2
cheers m8 see what u mean
jonathanca at 2007-7-12 18:48:51 > top of Java-index,Java Essentials,Java Programming...