Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AWT - Type Expected ???

 
Vivek Nambiar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Type expected.
bigUpperPanel.setLayout(new GridLayout(1, 3, 20, 0));
1 error
Why is this happening? WHERE DO I GET THE INFORMATION ON ERRORS SUCH AS THE ABOVE. I MEAN A COMPLETE LISTING OF THESE TYPE OF ERRORS. DOES IT COME WITH THE jdk1.2.2 itself??
thank u!

[This message has been edited by Vivek Nambiar (edited October 12, 2000).]
 
Aparna Murthy
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vivek,
I think there are some errors in your code . First the code starting with BigUpperPanel.setLayout() .... should be placed in a method block . You should place the setBounds() statement after populating all the panels and adding them to the frame. Finally you should add setVisible(true) ; to make Frame visible . The method should be called in main .
I tried compiling and running your code. It gave an error for the Scrollbar constructor (Scrollbar.HORIZANTAL, int, int, int) .
The field HORIZANTAL should be made HORIZONTAL and the Constructor takes 5 ints (including Scrollbar.HORIZONTAL). Hope this information helps you .
Here is the copy of my program which is running fine :
import java.awt.*;
import java.awt.event.* ;
public class Heir extends Frame
{
Heir()
{
super("Containment Heirarchy Demo");
}
String strings[] = {"Red :", "Green :", "Blue :"};
Panel bigUpperPanel = new Panel();
public void go()
{
setLayout(new BorderLayout(0, 25));
bigUpperPanel.setLayout(new GridLayout(1, 3, 20, 0));
for (int i=0; i<3; i++)
{
Panel levelPanel = new Panel();
levelPanel.setLayout(new GridLayout(3, 1, 0, 10));
levelPanel.add(new Label(strings[i]));
levelPanel.add(
new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 255));
levelPanel.add(new TextField("0"));
bigUpperPanel.add(levelPanel);
}
add(bigUpperPanel, BorderLayout.CENTER);
Panel lowerPanel = new Panel();
lowerPanel.add(new Button("Apply"));
lowerPanel.add(new Button("Reset"));
lowerPanel.add(new Button("Cancel"));
add(lowerPanel, BorderLayout.SOUTH);
setBounds (20, 20, 300, 180);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0) ;
}
} ) ;
setVisible(true) ;
}
public static void main(String args[])
{
new Heir().go() ;
}
}

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic