자바 gui 크기 자유자재 조절하는 법?

조회수 900회

소스코드를 실행하면 다음과 같은 화면입니다.

어떻게 하면 그림 그리는 칸을 자유자재로 늘렸다 줄였다 할 수 있게 코드를 바꿀 수 있나요?

추가 질문으로 라디오 버튼에 색상을 입힐 수 있나요? 이미지

public void show() {
// 메인프레임 생성
    JFrame frame = new JFrame("20181567_윤원희 ");
    Container content = frame.getContentPane();

// create controls to apply colors and call clear feature
    JPanel controls = new JPanel();

    clearBtn = new JButton("초기화");
    clearBtn.addActionListener(actionListener);
    blackBtn = new JRadioButton("검정색");
    blackBtn.addActionListener(actionListener);
    greenBtn = new JRadioButton("녹색");
    greenBtn.addActionListener(actionListener);
    redBtn = new JRadioButton("빨강색");
    redBtn.addActionListener(actionListener);
    magentaBtn = new JRadioButton("보라색");
    magentaBtn.addActionListener(actionListener);

    blackBtn.setSelected(true);

    ButtonGroup groupRd = new ButtonGroup();

    groupRd.add(blackBtn);
    groupRd.add(greenBtn);
    groupRd.add(redBtn);
    groupRd.add(magentaBtn);
// add to panel
    controls.add(blackBtn);

    controls.add(redBtn);
    controls.add(magentaBtn);
    controls.add(greenBtn);
    controls.add(clearBtn);

// set layout on content pane
    content.setLayout(new FlowLayout());

// add to content pane
    content.add(controls, BorderLayout.NORTH);
// create draw area
    drawArea = new DrawArea();
// add to content pane
    content.add(drawArea, BorderLayout.CENTER);
// set container size
    frame.setSize(600, 600);
// can close frame
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// show the swing paint result
    frame.setVisible(true);
    frame.setResizable(true);
}
  • (•́ ✖ •̀)
    알 수 없는 사용자

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)