我正在考虑如何画圆球作为一个球,因为每当我使用油漆时,我的框架总是会变成一个空白的空白区域。有没有什么办法可以将图形或绘画与那些JLabel结合起来?我已经在互联网上搜索过但我找不到任何答案,所以希望你能帮助我。
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class BasketBall extends JFrame implements ActionListener
{
JButton shootButton = new JButton("SHOOT");
JButton drbblButton = new JButton("DRIBBLE");
JButton holdButton = new JButton("HOLD");
JButton exitButton = new JButton("EXIT");
JLabel court = new JLabel(new ImageIcon("bcourt.jpg"));
public BasketBall()
{
Container c =getContentPane();
setLayout(null);
c.add(shootButton);
c.add(drbblButton);
c.add(holdButton);
c.add(exitButton);
c.add(court);
shootButton.setBounds(0,0,120,125);
drbblButton.setBounds(0,125,120,125);
holdButton.setBounds(0,250,120,125);
exitButton.setBounds(0,375,120,86);
court.setBounds(120,0,380,500);
setTitle("BasketBall");
c.setBackground(Color.black);
setSize(500,500);
setVisible(true);
}
//public void paint (Graphics g)
{
}
public void actionPerformed(ActionEvent e)
{
}
public static void main(String args[])
{
BasketBall ball = new BasketBall();
}
}