第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我怎樣才能像這張照片一樣設置 Gui

我怎樣才能像這張照片一樣設置 Gui

手掌心 2023-08-16 10:19:03
package matchgame;import java.awt.BorderLayout;import javax.swing.*;import javax.swing.border.Border;public class Start_Manu extends JFrame {    Start_Manu()    {        JLabel welcome=new JLabel("Welcome to Match Card Game ?");        JButton start=new JButton("Start");        JPanel manustart=new JPanel(new BorderLayout());        manustart.add(welcome,BorderLayout.NORTH);        manustart.add(start,BorderLayout.CENTER);        add(manustart);        //set Frame        setSize(800, 600);        setTitle("Match Card Game");        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        setLocationRelativeTo(null);        setVisible(true);    }    public static void main(String[] args) {        Start_Manu a=new Start_Manu();    }}我想設置喜歡這張照片。點擊開始按鈕后進入游戲狀態(tài)但是當我寫代碼的時候。你能告訴我如何編寫像我的第一張照片一樣的代碼嗎?
查看完整描述

1 回答

?
三國紛爭

TA貢獻1804條經(jīng)驗 獲得超7個贊

這只是一個粗略的設計。您想要嵌套不同的布局方法。這應該是您設計的準確框架,您可以根據(jù)自己的喜好調(diào)整一些數(shù)字(如空格等)。


        //Main Panel to contain everything

        JPanel main = new JPanel();

        main.setLayout(new BoxLayout(main,BoxLayout.Y_AXIS));


        JLabel welcome=new JLabel("Welcome to Match Card Game ?");

        //Setting prefered Font-Size

        welcome.setFont(new Font(welcome.getName(), Font.PLAIN, 24));



        JButton start=new JButton("Start Game");


        //Change button size and apparence

        start.setPreferredSize(new Dimension(150,50));

        start.setContentAreaFilled(false);



        //Add two sub-panels for advanced positioning

        JPanel welcome_p=new JPanel(new FlowLayout(1,0,150));

        JPanel button_p=new JPanel();


        //Set welcomepanel size to lower space to Button

        welcome_p.setPreferredSize(new Dimension(300,150));

        welcome_p.add(welcome);


        button_p.add(start);

        main.add(welcome_p);


        main.add(button_p);


        add(main);

        setSize(800, 600);

        setTitle("Match Card Game");

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        setLocationRelativeTo(null);

        setVisible(true);


查看完整回答
反對 回復 2023-08-16
  • 1 回答
  • 0 關注
  • 113 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號