最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

請(qǐng)問(wèn)下大佬們?yōu)槭裁次疫@個(gè)代碼運(yùn)行之后除了個(gè)框什么都沒(méi)有?

package com.Swing_Domo;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
//用面板
public class practise extends JFrame{
?//創(chuàng)建下拉列表
?JComboBox<String> jc=new JComboBox<>(new MyComboBox());
?JButton b1=new JButton("確定");
?JButton b2=new JButton("取消");
?//設(shè)置復(fù)選框組件
?JCheckBox jc1=new JCheckBox("男",true);
?JCheckBox jc2=new JCheckBox("女",true);
?JCheckBox jc3=new JCheckBox("不男不女???",true);
?public practise() {
??Container c=getContentPane();
??setTitle("皮一下窗體");
??setSize(300,300);
??setVisible(true);
??setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
??c.setBounds(0,0,100,100);
??b1.setBounds(280,110,30,10);
??b2.setBounds(280, 190, 30, 10);
??jc1.setBounds(120,150,10,10);
??jc2.setBounds(150,150,10,250);
??jc3.setBounds(180,150,10,20);
??c.add(b1);
??c.add(b2);
??c.add(jc1);
??c.add(jc2);
??c.add(jc3);
??//設(shè)置事件監(jiān)聽(tīng)器
??b1.addActionListener(new ActionListener() {
???public void actionPerformed(ActionEvent e) {
????setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
???}
??});
??//設(shè)置監(jiān)聽(tīng)器
??b2.addActionListener(new ActionListener() {
???public void actionPerformed(ActionEvent e) {
????setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
???}
??});
??jc1.addActionListener(new ActionListener() {
???public void actionPerformed(ActionEvent e) {
????
???}
??});
??jc2.addActionListener(new ActionListener() {
????? public void actionPerformed(ActionEvent e) {
????? ?
????? }
??});
??jc3.addActionListener(new ActionListener() {
????? public void actionPerformed(ActionEvent e) {
????? ?
????? }
??});
??
??
?}
?public static void main(String[] args) {
??// TODO Auto-generated method stub
??new practise();
??
?}
?
}

?class MyComboBox extends AbstractListModel <String>implements
? ComboBoxModel<String>{
??String selectedItem=null;
??String[] test= {"田螺菇?jīng)?,"巴扎黑","小明"};
??public String getElementAt(int index) {//返回索引處的值
???return test[index];
???
??}
??public int getSize() {//返回?cái)?shù)組的長(zhǎng)度
???return test.length;
??}
??public void setSelectedItem(Object item) {//設(shè)置下拉列表框項(xiàng)目
???selectedItem=(String)item;
???
??}
??public Object getSelectedItem() {//獲取下拉列表項(xiàng)目
???return selectedItem;
??}
??
??
?}

正在回答

2 回答


//這一行代碼有問(wèn)題,你創(chuàng)建一個(gè)新的窗體容器,各個(gè)組件都添加到了新建的里面,并沒(méi)有添加到窗體里,代碼有問(wèn)題 改一下試試。

import javax.swing.*;

import java.awt.*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

//用面板

public class practise extends JFrame{

?//創(chuàng)建下拉列表

?JComboBox<String> jc=new JComboBox<>(new MyComboBox());

?JButton b1=new JButton("確定");

?JButton b2=new JButton("取消");

?//設(shè)置復(fù)選框組件

?JCheckBox jc1=new JCheckBox("男",true);

?JCheckBox jc2=new JCheckBox("女",true);

?JCheckBox jc3=new JCheckBox("不男不女???",true);

?public practise() {

? JFrame frame=new JFrame("皮一下");

? frame.setLayout(null);

? Container c=frame.getContentPane();

? c.setBounds(0,0,100,100);

? b1.setBounds(new Rectangle(40,110,80,30));

? b2.setBounds(new Rectangle(130, 110, 80, 30));

? jc1.setBounds(new Rectangle(10,10,40,20));

? jc2.setBounds(new Rectangle(10,40,40,20));

? jc3.setBounds(new Rectangle(10,70,150,20));

? frame.add(b1);

? c.add(b2);

? c.add(jc1);

? c.add(jc2);

? c.add(jc3);

? frame.setSize(300,300);

? frame.setVisible(true);

? frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

? //設(shè)置事件監(jiān)聽(tīng)器

? b1.addActionListener(new ActionListener() {

? ?public void actionPerformed(ActionEvent e) {

? ? setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

? ?}

? });

? //設(shè)置監(jiān)聽(tīng)器

? b2.addActionListener(new ActionListener() {

? ?public void actionPerformed(ActionEvent e) {

? ? setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

? ?}

? });

? jc1.addActionListener(new ActionListener() {

? ?public void actionPerformed(ActionEvent e) {

? ??

? ?}

? });

? jc2.addActionListener(new ActionListener() {

? ? ? public void actionPerformed(ActionEvent e) {

? ? ? ?

? ? ? }

? });

? jc3.addActionListener(new ActionListener() {

? ? ? public void actionPerformed(ActionEvent e) {

? ? ? ?

? ? ? }

? });

??

??

?}

?public static void main(String[] args) {

? // TODO Auto-generated method stub

? new practise();

??

?}

?

}

?class MyComboBox extends AbstractListModel <String>implements?

? ComboBoxModel<String>{

? String selectedItem=null;

? String[] test= {"田螺菇?jīng)?,"巴扎黑","小明"};

? public String getElementAt(int index) {//返回索引處的值

? ?return test[index];

? ?

? }

? public int getSize() {//返回?cái)?shù)組的長(zhǎng)度

? ?return test.length;

? }

? public void setSelectedItem(Object item) {//設(shè)置下拉列表框項(xiàng)目

? ?selectedItem=(String)item;

? ?

? }

? public Object getSelectedItem() {//獲取下拉列表項(xiàng)目

? ?return selectedItem;

? }

??

??

?}



0 回復(fù) 有任何疑惑可以回復(fù)我~

setVisible(true);放最后一行

還是不行的話,百度setVisible(true);的相關(guān)異常

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

請(qǐng)問(wèn)下大佬們?yōu)槭裁次疫@個(gè)代碼運(yùn)行之后除了個(gè)框什么都沒(méi)有?

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)