无法将Jbutton加载到JFrame

时间:2016-12-01 18:05:10

标签: java jframe jbutton

我正在尝试在表单中添加一个按钮,将用户带回上一个屏幕。我可以显示表单和绘制的对象但无法显示按钮。 任何帮助将不胜感激

 public static JButton mainMenue = new JButton("Main Menue");

 public static void main(String[] args)
  {

//creating and setting the values for the Jframe   
JFrame form = new JFrame();

Color backColour = new Color(153,153,153);
form.getContentPane().setBackground(backColour);
form.add(mainMenue);
mainMenue.setVisible(true);
mainMenue.setLocation(100,100);
form.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
form.setBounds(30, 30, 1000, 1000);
form.getContentPane().add(new Layout());
form.setVisible(true);


}


@Override
public void paint(Graphics g) 
{
//creating the seating 

    Font titleFont = new Font("Dialog", Font.BOLD, 36);
    Font subTitleFont = new Font("Dialog", Font.BOLD, 14);

    Graphics2D g2 = (Graphics2D) g;
    super.paint(g);
    g.setColor(Color.blue);
    g.drawLine(225, 60, 255, 60);
    g.drawLine(340, 60, 400, 60);
    g.drawLine(400, 60, 400, 135);
    g.drawLine(400, 135, 650, 135);
    g.drawLine(650, 135, 650, 60);
    g.drawLine(650, 60, 680, 60);
    g.drawLine(765, 60, 825, 60);
    g.drawLine(225, 600, 450, 600);
    g.drawLine(600, 600, 850, 600);

0 个答案:

没有答案