[Java/Swing] 배치 관리자 3 - NoLayout 구현

2023. 2. 14. 17:08·Java/Swing (GUI)
728x90
728x90

코드

public class NoLayoutEx extends JFrame {

    JButton[] buttons = new JButton[5];

    public NoLayoutEx2() {
        initData();
        setInitLayout();
    }

    private void initData() {
        setTitle("좌표 기반 배치");
        setSize(500, 500);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // 버튼 인스턴스화
        for (int i = 0; i < buttons.length; i++) {
            buttons[i] = new JButton("버튼 " + (i + 1));
        }

        buttons[0].setSize(70, 440);
        buttons[1].setSize(380, 70);
        buttons[2].setSize(380, 70);
        buttons[3].setSize(70, 280);
        buttons[4].setSize(300, 280);
    }

    private void setInitLayout() {
        setLayout(null);

        buttons[0].setLocation(10, 10);
        buttons[1].setLocation(90, 380);
        buttons[2].setLocation(90, 10);
        buttons[3].setLocation(400, 90);
        buttons[4].setLocation(90, 90);

        // 버튼 추가
        for (int j = 0; j < buttons.length; j++) {
            add(buttons[j]);
        }

        setVisible(true);
    }

    public static void main(String[] args) {
        new NoLayoutEx();
    }

}

실행

320x100
반응형
저작자표시 비영리 변경금지 (새창열림)

'Java > Swing (GUI)' 카테고리의 다른 글

[Java/Swing] 컴포넌트 (Component)  (0) 2023.02.14
[Java/Swing] 배치 관리자 (Layout)  (0) 2023.02.14
[Java/Swing] 배치 관리자 2 - BorderLayout 구현  (0) 2023.02.14
[Java/Swing] 배치 관리자 1 - FlowLayout 구현  (0) 2023.02.14
[Java/Swing] 기본 구조  (0) 2023.02.14
'Java/Swing (GUI)' 카테고리의 다른 글
  • [Java/Swing] 컴포넌트 (Component)
  • [Java/Swing] 배치 관리자 (Layout)
  • [Java/Swing] 배치 관리자 2 - BorderLayout 구현
  • [Java/Swing] 배치 관리자 1 - FlowLayout 구현
스응
스응
    반응형
    250x250
  • 스응
    이서영의 개발 블로그
    스응
  • 전체
    오늘
    어제
  • 글쓰기 관리
    • 분류 전체보기 (385)
      • Java (134)
        • Base (54)
        • Spring Boot (37)
        • JSP (16)
        • Swing (GUI) (20)
        • Design Pattern (7)
      • C# (13)
      • PHP (18)
      • SQL (27)
      • Vue.js (9)
      • Tailwind CSS (4)
      • TypeScript (7)
      • HTML & CSS (27)
      • JavaScript (26)
      • jQuery (10)
      • Android (3)
      • - - - - - - - - - - - - - - (0)
      • Hotkeys (5)
      • CS (30)
      • IT Notes (13)
      • Error Notes (17)
      • Team Project (24)
        • Airlines Web Project (12)
        • University Web Project (6)
        • Strikers 1945 GUI Project (6)
      • My Project (18)
        • Library Web Project (8)
        • Pet Shopping Mall GUI Project (10)
      • etc. (0)
  • 블로그 메뉴

    • Home
    • Write
  • 링크

    • 깃허브
  • 공지사항

  • 인기 글

  • 태그

    vuejs
    개발일지
    면접
    http
    C#
    오블완
    Swing
    SQL
    jsp
    SpringBoot
    티스토리챌린지
    Wordpress
    errorNote
    php
    Android
    typeScript
    Hotkeys
    HTML
    SWAGGER
    CSS
    SEO
    js
    tailwindcss
    java
    zapier
    cs
    git
    Codeigniter
    jQuery
  • 최근 댓글

  • hELLO· Designed By정상우.v4.10.0
스응
[Java/Swing] 배치 관리자 3 - NoLayout 구현
상단으로

티스토리툴바