java 图形用什么组件标题_java图形用户界面设计Swing常用组件(阅读).ppt
* * * * * Rows:列表框的行數 boolean multipleMode:指定列表框是否可以進行多項選擇。 列表框:打開文件對話框中的文件類型。 * * import javax.swing.*; import java.awt.event.*; import java.awt.*; import javax.swing.event.*; class Info extends JFrame implements ListSelectionListener { JFrame fadd; JTextField num1;JLabel lbdep; JList dataList; String []data={"控制與計算機工程學院","電氣與電子工程學院","能源與動力工程學院","經濟與管理學院","數理學院","法政系","英語系","國際教育學院","核科學與工程學院","可再生能源學院"}; public void launchFrame() { dataList=new JList(data);//dataList.setEnabled(false); dataList.setAutoscrolls(true); dataList.setVisibleRowCount(4); num1 = new JTextField(15); lbdep = new JLabel("院系名稱"); setLayout(new FlowLayout()); add(lbdep); add(num1);add(new JScrollPane(dataList));dataList.addListSelectionListener(this);pack(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setTitle("JList例子程序"); setSize(300,200); setVisible(true); }public void valueChanged(ListSelectionEvent ls) {num1.setText(dataList.getSelectedValue().toString());} public static void main(String[] args){ new Info().launchFrame(); } } * import java.awt.*; import java.awt.event.*; public class List1 implements ActionListener ,ItemListener {Frame f;TextField tf1;List ls1;public static void main(String arg[]){(new List1()).display();}public void display(){f = new Frame("列表框練習");f.setSize(300,200);f.setLocation(300,300);f.setBackground(Color.lightGray);f.setLayout(new FlowLayout());ls1 = new List();//創建列表框f.add(ls1);tf1 = new TextField (10);f.add(tf1);ls1.add("北京"); ls1.add("上海"); ls1.add("南京"); ls1.add("西安");f.setVisible(true);ls1.addActionListener(this);ls1.addItemListener(this);}public void actionPerformed(ActionEvent e){tf1.setText(ls1.getSelectedItem());} public void itemStateChanged(ItemEvent e){tf1.setText(ls1.getSelectedItem());} } * * drawOval(int?x, int?y, int?width, int?height) Parameters: x - the x coordinate of the upper left corner of the oval to be drawn. y - the y coordinate of the upper left corner of the oval to be drawn.
總結
以上是生活随笔為你收集整理的java 图形用什么组件标题_java图形用户界面设计Swing常用组件(阅读).ppt的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python右对齐函数_python右对
- 下一篇: java 待在原页面 代码_现在jav