1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時(shí)間:8:30-17:00
      你可能遇到了下面的問(wèn)題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
      javaswinghelloworld-創(chuàng)新互聯(lián)

      1.概述

      一個(gè)簡(jiǎn)單的java swing程序hello world,只有一個(gè)button

      錫林浩特ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書(shū)未來(lái)市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)建站的ssl證書(shū)銷(xiāo)售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:028-86922220(備注:SSL證書(shū)合作)期待與您的合作!

      2.源碼

      import javax.swing.*;
      public class server
      {
          public static void main(String[] args) {
              JFrame jFrame = new JFrame("title");
              JButton button = new JButton("Test button");
      
              jFrame.add(button);//把button添加到JFrame中
              jFrame.setSize(300,300);//設(shè)置JFrame大小
              jFrame.setVisible(true);//設(shè)置可見(jiàn),不然的話看不到
          }
      }

      java swing hello world

      3.第一次修改

      有沒(méi)有覺(jué)得有點(diǎn)奇怪,整個(gè)button占滿了窗口?
      沒(méi)錯(cuò),少了一個(gè)JPanel:

      import javax.swing.*;
      public class server
      {
          public static void main(String[] args) {
              JFrame jFrame = new JFrame("title");
              JPanel jPanel = new JPanel();
              JButton button = new JButton("Test button");
      
              jPanel.add(button);
              jFrame.setContentPane(jPanel);
              jFrame.setSize(300,300);
              jFrame.setVisible(true);
          }
      }

      添加一個(gè)JPanel,把Button添加到JPanel中,然后設(shè)置JFrame的contenPane.
      效果如下:
      java swing hello world

      4.第二次修改

      嗯,有點(diǎn)hello world的樣子了,但是你有沒(méi)有點(diǎn)擊過(guò)左上角的x按鈕?

      點(diǎn)了之后,這個(gè)東西是"消失"了,但是在后臺(tái)還在運(yùn)行著,所以...

      jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      需要這樣設(shè)置它的默認(rèn)關(guān)閉操作.

      另一個(gè)修改就是對(duì)它居中顯示,要不然的話總是啟動(dòng)的時(shí)候在左上角.

      很簡(jiǎn)單,一行就可以了.

      jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      完整代碼:

      import javax.swing.*;
      public class server
      {
          public static void main(String[] args) {
              JFrame jFrame = new JFrame("title");
              JPanel jPanel = new JPanel();
              JButton button = new JButton("Test button");
      
              jPanel.add(button);
              jFrame.setContentPane(jPanel);
              jFrame.setSize(300,300);
              jFrame.setLocationRelativeTo(null);
              jFrame.setVisible(true);
              jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          }
      }

      創(chuàng)新互聯(lián)www.cdcxhl.cn,專業(yè)提供香港、美國(guó)云服務(wù)器,動(dòng)態(tài)BGP最優(yōu)骨干路由自動(dòng)選擇,持續(xù)穩(wěn)定高效的網(wǎng)絡(luò)助力業(yè)務(wù)部署。公司持有工信部辦法的idc、isp許可證, 機(jī)房獨(dú)有T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確進(jìn)行流量調(diào)度,確保服務(wù)器高可用性。佳節(jié)活動(dòng)現(xiàn)已開(kāi)啟,新人活動(dòng)云服務(wù)器買(mǎi)多久送多久。


      名稱欄目:javaswinghelloworld-創(chuàng)新互聯(lián)
      文章源于:http://ef60e0e.cn/article/cchged.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        化州市| 蓝山县| 阳西县| 门源| 洛隆县| 安龙县| 清流县| 恩平市| 静安区| 剑阁县| 绥棱县| 永胜县| 新巴尔虎右旗| 宣武区| 珠海市| 迭部县| 阳城县| 鹤壁市| 建阳市| 扶沟县| 界首市| 苍南县| 三门县| 成都市| 绥化市| 友谊县| 扶风县| 梁平县| 北川| 卫辉市| 通江县| 冷水江市| 康定县| 莱芜市| 彭山县| 同德县| 稷山县| 青海省| 莱芜市| 莲花县| 梁平县|