Reputation: 3
package textar;
import java.awt.*;
import javax.swing.*;
public class textarea extends JInternalFrame
{
public static JTextArea txtaMessage;
textarea() {
super("Private Cloud Environment",true,false,true,true);
txtaMessage=new JTextArea();
JScrollPane scrollPane=newJScrollPane(txtaMessage,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
txtaMessage.setFont(new Font("Serif", Font.BOLD, 16));
txtaMessage.setEditable(false);
getContentPane().setLayout(new GridLayout(1,1));
getContentPane().add(scrollPane);
setSize(650,650);
setVisible(true);
}
}
So above is my block of code which has to b called in the followin program
import package textar.*;
public Main()
{
//creating object for textarea InternalFrame
textarea objtxta=new textarea();
addFrame(objtxta);
}
but when compiling
import package textar.*;
^
1 error
"error: identifier expected" pops out !!
I hav skipped other parts of d program because they have nothing to do with the package.
Help me out please !! And Thanks in advance !!
Upvotes: 0
Views: 886
Reputation: 159844
The use of the package
keyword is invalid in import
statement here. You can use:
import textar.*;
Your calling class does not appear to have the class declared:
import textar.*;
public class Main {
public Main() {
//creating object for textarea InternalFrame
textarea objtxta=new textarea();
addFrame(objtxta);
}
...
Also there should be spaces between the keywords in the declaration of JScrollPane
in the textarea
class:
JScrollPane scrollPane = new JScrollPane(txtaMessage,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
Upvotes: 4