Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

setting the size of the ImageIcon

843805Mar 8 2007 — edited Mar 8 2007
Hi,
I have a program below which helps me to keep an image as a button.But Im unable to see the image & the button is also very small.
PROGRAM CODE:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/*<applet code=jbt.class width=500 height=500>
</applet>*/
public class jbt extends JApplet implements ActionListener
{
Container c=getContentPane();
JLabel l=new JLabel("type");
JTextField t=new JTextField(10);
ImageIcon im1=new ImageIcon("yoga.jpeg");
String str="hey";
JButton mb=new JButton(str,im1);
public void init()
{
c.setLayout(new FlowLayout());
c.add(l);
c.add(t);
c.add(mb);
mb.addActionListener(this);
}
public void actionPerformed(ActionEvent a)
{
l.setText(t.getText());
}
}

Could anyone help me out?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 5 2007
Added on Mar 8 2007
4 comments
767 views