关于如何写一个组合框
想问问各位鱼友们,做图形用户界面的时候因该怎么写组合框,比如日历的选择年份和月份 点击那个箭头,下边会弹出来嘿嘿最好可以和下边的网格布局相匹配,就是我选择XX年XX月会跳出这个月的日历
import javax.swing.*;
import java.util.*;
import java.awt.*;
class GridLayoutFrame extends JFrame{
JLabel label1 = new JLabel("星期日 ",JLabel.CENTER);
JLabel label2 = new JLabel("星期一 ",JLabel.CENTER);
JLabel label3 = new JLabel("星期二 ",JLabel.CENTER);
JLabel label4 = new JLabel("星期三 ",JLabel.CENTER);
JLabel label5 = new JLabel("星期四 ",JLabel.CENTER);
JLabel label6 = new JLabel("星期五 ",JLabel.CENTER);
JLabel label7 = new JLabel("星期六 ",JLabel.CENTER);
String strArr[] = {"1","2","3","4","5","6","7",
"8","9","10","11","12","13","14",
"15","16","17","18","19","20","21",
"22","23","24","25","26","27","28",
"29","30","31","","",""};
JButton btnArr[];
GridLayoutFrame(){
setTitle("网格布局显示器");
setSize(750,550);
setLocation(300,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel p = new JPanel();
p.add(label1);
p.add(label2);
p.add(label3);
p.add(label4);
p.add(label5);
p.add(label6);
p.add(label7);
p.setLayout(new GridLayout(6,7,5,10));
btnArr = new JButton;
for(int i = 0;i<strArr.length;i++){
btnArr = new JButton(strArr);
p.add(btnArr);
}
setContentPane(p);
}
}
class main{
public static void main(String[] args){
GridLayoutFrame g = new GridLayoutFrame();
g.setVisible(true);
}
//SetFontFrame
} 比较简单的方法
使用JTabbedPanel类,弄个简单的选项卡
然后鼠标监听 z11397444 发表于 2019-12-19 09:36
比较简单的方法
使用JTabbedPanel类,弄个简单的选项卡
然后鼠标监听
可以写详细一定能嘛{:10_243:}不是很明白这块
页:
[1]