快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

java显示字样的代码,java如何在面板显示字

求Java窗体代码,可显示文本.

importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.event.KeyEvent;importjava.awt.event.KeyListener;importjavax.swing.JButton;importjavax.swing.JEditorPane;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JPanel;importjavax.swing.JTextField;publicclassWindowTestextendsJFrameimplementsActionListener,KeyListener{privatestaticfinallongserialVersionUID=1L;/***主方法*/publicstaticvoidmain(String[]args){WindowTestwin=newWindowTest();}/***下面是具体实现*/JTextFieldtext;JButtonbutton;JEditorPanetextArea;publicWindowTest(){super("测试窗体");text=newJTextField(15);text.addKeyListener(this);JPanelp1=newJPanel();p1.add(newJLabel("输入字符:"));p1.add(text);button=newJButton("清除");button.addActionListener(this);p1.add(button);p1.setBounds(5,5,220,100);textArea=newJEditorPane();textArea.setBounds(1,1,216,200);JPanelp2=newJPanel();p2.add(newJLabel("显示字符:"));p2.add(textArea);p2.setBounds(5,115,340,220);JPanelp3=newJPanel();p3.add(p1);p3.add(p2);add(p3);setBounds(160,60,400,300);setVisible(true);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}@OverridepublicvoidkeyPressed(KeyEvente){}@OverridepublicvoidkeyReleased(KeyEvente){if(e.getKeyCode()==KeyEvent.VK_ENTER){textArea.setText("");}else{Stringstr=text.getText();textArea.setText(str);}}@OverridepublicvoidkeyTyped(KeyEvente){}@OverridepublicvoidactionPerformed(ActionEvente){text.setText("");textArea.setText("");}}

成都创新互联提供网站设计、成都网站制作、网页设计,高端网站设计1元广告等致力于企业网站建设与公司网站制作,十多年的网站开发和建站经验,助力企业信息化建设,成功案例突破千余家,是您实现网站建设的好选择.

java中怎么设置label的字体大小及颜色显示

Java设置label字体代码如下:

ublic class SetColor extends JFrame{

JLabel jlabel = new JLabel("颜色,大小");

public SetColor(){

this.setLayout(null);

jlabel.setBounds(0, 0, 200, 40);

jlabel.setFont(new Font("",1,30));//设置字体大小

jlabel.setForeground(Color.BLUE);//设置字体颜色

this.add(jlabel);

this.setSize(200,200);

this.setVisible(true);

}

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

SetColor sc = new SetColor();

}}

编写JAVA程序,在其中有一个按钮和一个文本框。单击按钮时,文本框中显示按钮上显示的字。

1、首先,设置在网页中显示文本的格式,文本的高度为100像素,宽度为280像素。

2、定义显示文本的字体大小为22像素,离左侧和右侧的距离设置为自动,离顶部的距离设置为15像素。

3、用font标签在网页中插入要显示的文本。

4、由于显示的文本内容是动态控制的,所以设置一个标识符poemsi,用来动态表示显示的诗句。

5、然后,在网页中插入一个按钮。

6、按钮的高度为33像素,宽度为100像素,离左侧和右侧的距离为自动,离顶部的距离为20像素。

7、用type属性,定义按钮的类型为button。

8、定义按钮的标签为显示,单击后执行的函数为show。

9、按钮的背景色值为#aaeded,字体大小为20像素。


网站题目:java显示字样的代码,java如何在面板显示字
网站路径:http://6mz.cn/article/hocgds.html

其他资讯