• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with JFrame  RSS feed

 
hasan wasif2k1
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Written below program is compiling and also executing but not showing JButton
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class test
{
public static void main(String args[])
{
JFrame fr=new JFrame();
ticker f = new ticker(fr);
f.show();
}
}

class ticker extends Window
{
public ticker(JFrame fr)
{
super(fr);
JLabel l=new JLabel("Hello");
Container contentPane=fr.getContentPane();
contentPane.setLayout(new FlowLayout());
l.setBounds(60,50,100,60);
contentPane.add(l);
setSize(800,600);
setVisible(true);
show();
}
}
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not showing a JButton because you do not have a JButton anywhere in the code!

-Nate
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!