• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with FlowLayout

 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I am trying to do a simple window, but get strange error:
============================================================
import java.awt.*;
import javax.swing.*;
public class FlowLayout{
static JFrame aWin = new JFrame("Window");
public static void main(String[] args){
Toolkit kit = aWin.getToolkit();
Dimension winSize = kit.getScreenSize();
aWin.setBounds(winSize.width/4, winSize.height/2, winSize.width/2, winSize.height/3);
aWin.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
FlowLayout flow = new FlowLayout();
Container content = aWin.getContentPane();
content.setLayout(flow);
for(int i = 1; i < 5; i++)
content.add(new JButton("button " + i));
aWin.setVisible(true);
}
}
===============================================================
error:
======
FlowLayout.java:16: Incompatible type for method. Explicit cast needed to convert FlowLayout to
java.awt.LayoutManager.content.setLayout(flow);
what's the problem?
thanks,
Alex
 
Angela Lamb
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't name your class FlowLayout.
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
same thing is happening...even after I rename the class.
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
never mind, got it working...thanks
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
never mind, got it working...thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!