JAVA Label, Button Test

라벨, 버튼, 보더, 툴팁 TEST

Reference : 최종명 외 2인,프로그래머를 위한 JAVA2,홍릉출판사
JLabelButton.java





  1. import java.awt.*;
  2. import javax.swing.*;
  3. public class JLabelButton extends JFrame{
  4.     protected JButton textB,iconB;
  5.     protected JLabel label;
  6.    
  7.     public JLabelButton(){
  8.         super("Swing Button and Label");
  9.         getContentPane().setLayout(new FlowLayout());
  10.        
  11.         ImageIcon logo = new ImageIcon("woman.jpg");
  12.         label=new JLabel("the Lady",logo,JLabel.RIGHT);
  13.         //border설정
  14.         label.setBorder(BorderFactory.createTitledBorder("label"));
  15.         getContentPane().add(label);
  16.        
  17.         textB=new JButton("a Button");
  18.         getContentPane().add(textB);
  19.        
  20.         ImageIcon egon = new ImageIcon("egon.jpg");
  21.         iconB=new JButton("",egon);
  22.         //눌렸을때의 아이콘셋팅
  23.         iconB.setPressedIcon(new ImageIcon("egon2.jpg"));
  24.         //보더 셋팅
  25.         iconB.setBorder(BorderFactory.createEtchedBorder());
  26.         //마우스가 위에 있을때 안내문 표시
  27.         iconB.setToolTipText("Egon schiele");
  28.         getContentPane().add(iconB);
  29.        
  30.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  31.         setSize(500,400);
  32.         setVisible(true);
  33.     }
  34.     public static void main(String[] args) {
  35.         JLabelButton jlb = new JLabelButton();
  36.     }
  37. }



댓글

이 블로그의 인기 게시물

[Win32 API] WINAPI - 함수호출규약

JAVA Frame Icon setting

JAVA Spinner