자바 스윙 Jradio 버튼 선택 단추 구체 적 으로 사용
                                            
 2638 단어  SwingJRadioButton단일 선택 단추
                    
공식 자바 DocsApi:javax.swing.JRadioButton
Jradio Button,체크 버튼.
JButton 상용 구조 방법:
//    ,   
JRadioButton()
//    ,   
JRadioButton(String text)
//    ,       
JRadioButton(String text, boolean selected)
//           、         
void setText(String text)
void setFont(Font font)
void setForeground(Color fg)
/*         javax.swing.AbstractButton     */
//             
void setSelected(boolean b)
//           
boolean isSelected()
//           
void setEnabled(boolean enable)
//           、   、          
void setIcon(Icon defaultIcon)
void setPressedIcon(Icon pressedIcon)
void setDisabledIcon(Icon disabledIcon)
//           
void setIconTextGap(int iconTextGap)
 
JRadioButton      :
//          
void addChangeListener(ChangeListener l)
//        
ButtonGroup btnGroup = new ButtonGroup();
//           
btnGroup.add(radioBtn01);
btnGroup.add(radioBtn02);
package com.xiets.swing;
import javax.swing.*;
import java.awt.*;
public class Main {
  public static void main(String[] args) throws AWTException {
    JFrame jf = new JFrame("    ");
    jf.setSize(200, 200);
    jf.setLocationRelativeTo(null);
    jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    //         
    JRadioButton radioBtn01 = new JRadioButton(" ");
    JRadioButton radioBtn02 = new JRadioButton(" ");
    //      ,            
    ButtonGroup btnGroup = new ButtonGroup();
    btnGroup.add(radioBtn01);
    btnGroup.add(radioBtn02);
    //            
    radioBtn01.setSelected(true);
    panel.add(radioBtn01);
    panel.add(radioBtn02);
    jf.setContentPane(panel);
    jf.setVisible(true);
  }
}
 
 이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Swing 공통 구성 요소의 텍스트 상자 및 텍스트 영역1. JtextField(텍스트 상자) 사용 JtextField는 경량급 구성 요소로 한 줄의 텍스트를 편집하여 잘라내기, 복사, 붙여넣기, 단축키 등의 작업을 할 수 있으며, 텍스트의 길이가 표시 범위를 초과하면 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.