java完整布局代码

java完整布局代码

ID:38164168

大小:13.35 KB

页数:4页

时间:2019-06-06

java完整布局代码_第1页
java完整布局代码_第2页
java完整布局代码_第3页
java完整布局代码_第4页
资源描述:

《java完整布局代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、packagecom.cissst.exercise;importjava.awt.EventQueue;importjava.awt.Font;importjava.awt.GridBagConstraints;importjava.awt.GridBagLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjavax.swing.BorderFactory;importjavax.swing.JCheckBox;importjavax.swing.JComboBox;imp

2、ortjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JTextArea;publicclassGridBagLayoutTest{publicstaticvoidmain(String[]args){EventQueue.invokeLater(newRunnable(){publicvoidrun(){FontFrameframe=newFontFrame();frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setVisible(true

3、);}});}}classFontFrameextendsJFrame{publicFontFrame(){setTitle("GridBagLayoutTest");setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);GridBagLayoutlayout=newGridBagLayout();setLayout(layout);ActionListenerlistener=newFontAction();JLabelfaceLabel=newJLabel("face:");face=newJComboBox(newString[]{"SansSerif","

4、Monospaced","Dialog","DialogInput"});face.addActionListener(listener);JLabelsizeLabel=newJLabel("Size:");size=newJComboBox(newString[]{"8","10","12","15","18","24","36","48"});size.addActionListener(listener);bold=newJCheckBox("Bold");bold.addActionListener(listener);italic=newJCheckBox("Italic"

5、);italic.addActionListener(listener);sample=newJTextArea();sample.setText("Thequickbrownfoxjumosoverthelazydog");sample.setEditable(false);sample.setLineWrap(true);sample.setBorder(BorderFactory.createEtchedBorder());add(faceLabel,(newGBC(0,0)).setAnchor(GBC.EAST));add(face,(newGBC(1,0).setFill(

6、GBC.HORIZONTAL)).setWeight(100,0).setInsets(1));add(sizeLabel,newGBC(0,1).setAnchor(GBC.EAST));add(size,(newGBC(1,1).setFill(GBC.HORIZONTAL)).setWeight(100,0).setInsets(1));add(bold,(newGBC(0,2,2,1).setAnchor(GBC.CENTER)).setWeight(100,100));add(italic,(newGBC(0,3,2,1).setAnchor(GBC.CENTER)).set

7、Weight(100,100));add(sample,(newGBC(2,0,1,4).setFill(GBC.BOTH)).setWeight(100,100));}publicstaticfinalintDEFAULT_WIDTH=300;publicstaticfinalintDEFAULT_HEIGHT=200;privateJComboBoxface;privateJComboBoxsize;privateJCheckBoxbold

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。