📄 ne.java~21~
字号:
package font;import java.awt.*;import java.awt.event.*;import java.applet.*;import javax.swing.*;import com.borland.jbcl.layout.*;public class ne extends Applet { Color mycolor; int height; Font myfont; boolean isStandalone = false; JTextField theight = new JTextField(); JButton but = new JButton(); XYLayout xYLayout1 = new XYLayout(); JTextField r = new JTextField(); JTextField g = new JTextField(); JTextField b = new JTextField(); JLabel jLabel1 = new JLabel(); JLabel jLabel2 = new JLabel(); JLabel jLabel3 = new JLabel(); JLabel jLabel4 = new JLabel(); /**Get a parameter value*/ public String getParameter(String key, String def) { return isStandalone ? System.getProperty(key, def) : (getParameter(key) != null ? getParameter(key) : def); } /**Construct the applet*/ public ne() { } /**Initialize the applet*/ public void init() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { but.setText("确定"); but.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { but_actionPerformed(e); } }); this.setLayout(xYLayout1); r.setText("0"); r.setHorizontalAlignment(SwingConstants.LEFT); g.setText("0"); g.setHorizontalAlignment(SwingConstants.LEFT); b.setText("0"); b.setHorizontalAlignment(SwingConstants.LEFT); jLabel1.setFont(new java.awt.Font("Dialog", 0, 16)); jLabel1.setText("大小"); jLabel2.setFont(new java.awt.Font("Dialog", 0, 16)); jLabel2.setText("R"); jLabel3.setFont(new java.awt.Font("Dialog", 0, 16)); jLabel3.setText("G"); jLabel4.setFont(new java.awt.Font("Dialog", 0, 16)); jLabel4.setText("B"); theight.setText("32"); this.add(theight, new XYConstraints(50, 6, 60, 30)); this.add(r, new XYConstraints(172, 6, 60, 30)); this.add(g, new XYConstraints(49, 53, 60, 30)); this.add(b, new XYConstraints(172, 52, 60, 30)); this.add(jLabel1, new XYConstraints(4, 6, 40, 30)); this.add(jLabel2, new XYConstraints(129, 6, 40, 30)); this.add(jLabel3, new XYConstraints(4, 53, 40, 33)); this.add(jLabel4, new XYConstraints(129, 52, 40, 30)); this.add(but, new XYConstraints(245, 53, -1, -1)); } /**Get Applet information*/ public String getAppletInfo() { return "Applet Information"; } /**Get parameter info*/ public String[][] getParameterInfo() { return null; } void but_actionPerformed(ActionEvent e) { String s=theight.getText(); if(s==null) theight.setText("32"); try{ s=theight.getText(); height=Integer.parseInt(s); if(height>=60){ height=60; theight.setText("60"); } } catch(Exception ex){ ex.printStackTrace(); } myfont=new Font("TimesRoman",Font.PLAIN,height); String cr=r.getText(); if(cr==null) r.setText("0"); cr=r.getText(); int pr=Integer.parseInt(cr); if(pr>=255){ pr=255; r.setText("255"); } String cg=g.getText(); if(cg==null) g.setText("0"); cg=g.getText(); int pg=Integer.parseInt(cg); if(pg>=255){ pg=255; g.setText("255"); } String cb=b.getText(); if(cb==null) b.setText("0"); cb=b.getText(); int pb=Integer.parseInt(cb); if(pb>=255){ pb=255; b.setText("255"); } mycolor=new Color(pr,pg,pb); repaint(); } public void paint(Graphics g){ g.setColor(mycolor); g.setFont(myfont); if(height<=40) g.drawString("HAPPY TIME",10,150); else g.drawString("HAPPY TIME",10,3*height); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -