제발 자바상에서 버튼 크기 좀 조절어떻게 하는지좀 가르쳐주세

다크슈테펜의 이미지

import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Font;

/*
* Created on 2004. 11. 16
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/

/**
* @author root
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class javaones extends JFrame {

public static void main(String args[]) {
javaones frame = new javaones();
frame.setBounds(100, 100, 500, 375);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}

public javaones() {
super();
getContentPane().setFont(new Font("Baekmuk Headline", Font.PLAIN, 12));

final JButton button = new JButton();
//getContentPane().add(button, BorderLayout.WEST);

button.setSize(125,125);
button.setText("야후");
button.setLocation(120,120);
add(button);

//
}
}

소스는 이거인데요...버튼 위치하고 크기 조절하는 거 어떻게 하나요....?
제발 가르쳐주세요..ㅠ0ㅠ;;

neosphere의 이미지

코드를 좀더 보기 좋게 해보죠..

public class Javaones extends JFrame {

	public static void main(String args[]) {
		Javaones frame = new Javaones();
		
		frame.setBounds(100, 100, 500, 375);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.show();
	}

	public Javaones() {
		super();
		Container gc = getContentPane();
		gc.setFont(new Font("Baekmuk Headline", Font.PLAIN, 12));
		gc.setLayout(new BorderLayout());

		final JButton button = new JButton();

		button.setSize(125, 125);
		button.setText("야후");
		button.setLocation(120, 120);
		gc.add(button, BorderLayout.CENTER);

		// 
	}
}

이렇게 하시면 됩니다. 그런데 BorderLayout은 사용자가 지정한 크기로 나타나지 않습니다.

Flow 나 Box 같은거 쓰시면 원하는 크기로 나타날 겁니다.

Gentoo. Bioinformatics, Protein Interaction.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.