当前位置: 首页 > news >正文

广州网站建设公司招聘seo发帖论坛

广州网站建设公司招聘,seo发帖论坛,网页设计html参考文献,iis网站发布默认首页我主要使用使用 Java Swing 库创建一个 GUI 窗口,然后在窗口中显示生成的算术验证码图片,并提供一个文本框和一个按钮,输入验证码并验证显示结果。 代码如下: package calculate; import javax.swing.*; import java.awt.*; imp…

我主要使用使用 Java Swing 库创建一个 GUI 窗口,然后在窗口中显示生成的算术验证码图片,并提供一个文本框和一个按钮,输入验证码并验证显示结果。

代码如下:

package calculate;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
public class ArithmeticValidateCodeExample extends JFrame implements ActionListener {private static final int WIDTH = 100;     // 图片宽度private static final int HEIGHT = 80;     // 图片高度private static final int FONT_SIZE = 20;  // 字体大小private BufferedImage image;              // 验证码图片private String arithmeticExpression;       // 算术表达式private int arithmeticResult;              // 算术表达式的结果private JLabel label;                      // 显示算术表达式和"请输入验证码结果"private JTextField textField;              // 获取用户输入的结果public ArithmeticValidateCodeExample() {// 生成算术表达式和结果arithmeticExpression = generateArithmeticExpression();arithmeticResult = calculateArithmeticExpression(arithmeticExpression);// 创建验证码图片image = generateValidateCodeImage(arithmeticExpression);// 设置JFrame的属性setSize(WIDTH + 80, HEIGHT + 100);  // 加上100的高度为了留出空间放"请输入验证码结果"和输入框setLocationRelativeTo(null);setTitle("算数验证码");// 创建一个JLabel用于显示验证码图片JLabel imageLabel = new JLabel(new ImageIcon(image));getContentPane().add(imageLabel, BorderLayout.NORTH);// 添加"请输入验证码结果"和输入框及"验证"按钮label = new JLabel("请输入验证码结果:");textField = new JTextField(8);JButton button = new JButton("验证");button.addActionListener(this);JPanel inputPanel = new JPanel(new FlowLayout());inputPanel.add(label);inputPanel.add(textField);inputPanel.add(button);getContentPane().add(inputPanel, BorderLayout.CENTER);}public static void main(String[] args) {ArithmeticValidateCodeExample example = new ArithmeticValidateCodeExample();example.setVisible(true);example.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}@Overridepublic void actionPerformed(ActionEvent e) {String userInput = textField.getText();int userResult = Integer.parseInt(userInput);if (userResult == arithmeticResult) {JOptionPane.showMessageDialog(null, "验证通过!");} else {JOptionPane.showMessageDialog(null, "验证失败!");}}private static String generateArithmeticExpression() {int number1 = (int) (Math.random() * 100);int number2 = (int) (Math.random() * 100);int operator = (int) (Math.random() * 4);char operatorChar;switch (operator) {case 0:operatorChar = '+';break;case 1:operatorChar = '-';break;case 2:operatorChar = '*';break;case 3:operatorChar = '/';break;default:operatorChar = '+';}return number1 + " " + operatorChar + " " + number2;}private static int calculateArithmeticExpression(String arithmeticExpression) {String[] components = arithmeticExpression.split(" ");int number1 = Integer.parseInt(components[0]);char operator = components[1].charAt(0);int number2 = Integer.parseInt(components[2]);int result;switch (operator) {case '+':result = number1 + number2;break;case '-':result = number1 - number2;break;case '*':result = number1 * number2;break;case '/':result = number1 / number2;break;default:result = 0;}return result;}private static BufferedImage generateValidateCodeImage(String arithmeticExpression) {BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);Graphics2D g = image.createGraphics();// 设置背景颜色g.setColor(Color.WHITE);g.fillRect(0, 0, WIDTH, HEIGHT);// 设置字体样式和大小Font font = new Font(Font.DIALOG, Font.BOLD, FONT_SIZE);g.setFont(font);// 设置验证码文本颜色g.setColor(Color.BLACK);// 绘制算术表达式的文本g.drawString(arithmeticExpression, 10, HEIGHT / 2 - FONT_SIZE);// 添加干扰线for (int i = 0; i < 5; i++) {int x1 = (int) (Math.random() * WIDTH);int y1 = (int) (Math.random() * HEIGHT);int x2 = (int) (Math.random() * WIDTH);int y2 = (int) (Math.random() * HEIGHT);g.drawLine(x1, y1, x2, y2);}// 噪点数量int noiseCount = WIDTH * HEIGHT / 5;for (int i = 0; i < noiseCount; i++) {int x = (int) (Math.random() * WIDTH);int y = (int) (Math.random() * HEIGHT);int rgb = getRandomColor().getRGB();image.setRGB(x, y, rgb);}g.dispose();return image;}private static Color getRandomColor() {int r = (int) (Math.random() * 256);int g = (int) (Math.random() * 256);int b = (int) (Math.random() * 256);return new Color(r, g, b);}
}

 

 


文章转载自:
http://ephesus.bwmq.cn
http://spitball.bwmq.cn
http://surculus.bwmq.cn
http://paronomasia.bwmq.cn
http://stow.bwmq.cn
http://lawyer.bwmq.cn
http://inappropriate.bwmq.cn
http://germander.bwmq.cn
http://electoralism.bwmq.cn
http://trembly.bwmq.cn
http://myoscope.bwmq.cn
http://germicide.bwmq.cn
http://wassail.bwmq.cn
http://print.bwmq.cn
http://atrabilious.bwmq.cn
http://hoggery.bwmq.cn
http://apprehensively.bwmq.cn
http://epitaxial.bwmq.cn
http://nekoite.bwmq.cn
http://freebase.bwmq.cn
http://slothfulness.bwmq.cn
http://putt.bwmq.cn
http://bounder.bwmq.cn
http://smallshot.bwmq.cn
http://commensurate.bwmq.cn
http://debilitate.bwmq.cn
http://guevarist.bwmq.cn
http://ferdinand.bwmq.cn
http://drowning.bwmq.cn
http://eyealyzer.bwmq.cn
http://xeroma.bwmq.cn
http://messin.bwmq.cn
http://subsellium.bwmq.cn
http://gervais.bwmq.cn
http://impartiality.bwmq.cn
http://drummer.bwmq.cn
http://magnetooptic.bwmq.cn
http://puma.bwmq.cn
http://balsamine.bwmq.cn
http://aarnet.bwmq.cn
http://reemerge.bwmq.cn
http://loof.bwmq.cn
http://apolaustic.bwmq.cn
http://leverage.bwmq.cn
http://seriate.bwmq.cn
http://voyeurism.bwmq.cn
http://wordy.bwmq.cn
http://preconference.bwmq.cn
http://smithereens.bwmq.cn
http://grandioso.bwmq.cn
http://deoxyribose.bwmq.cn
http://hairpiece.bwmq.cn
http://misbegot.bwmq.cn
http://bibcock.bwmq.cn
http://nidget.bwmq.cn
http://hypogeum.bwmq.cn
http://rassling.bwmq.cn
http://mousetail.bwmq.cn
http://hygeian.bwmq.cn
http://macrostomia.bwmq.cn
http://blueweed.bwmq.cn
http://lune.bwmq.cn
http://cinematography.bwmq.cn
http://yankeefy.bwmq.cn
http://manstealing.bwmq.cn
http://haymow.bwmq.cn
http://roadmanship.bwmq.cn
http://cephalitis.bwmq.cn
http://kikongo.bwmq.cn
http://platinocyanic.bwmq.cn
http://preterition.bwmq.cn
http://chapped.bwmq.cn
http://georgian.bwmq.cn
http://cataclysm.bwmq.cn
http://intrados.bwmq.cn
http://inference.bwmq.cn
http://npn.bwmq.cn
http://haversian.bwmq.cn
http://walnut.bwmq.cn
http://thallogen.bwmq.cn
http://diskcopy.bwmq.cn
http://opec.bwmq.cn
http://qi.bwmq.cn
http://gondolier.bwmq.cn
http://senega.bwmq.cn
http://overprize.bwmq.cn
http://parafoil.bwmq.cn
http://glomma.bwmq.cn
http://jerusalem.bwmq.cn
http://emblematic.bwmq.cn
http://drawsheet.bwmq.cn
http://anagrammatic.bwmq.cn
http://handcar.bwmq.cn
http://flipping.bwmq.cn
http://boxful.bwmq.cn
http://dudish.bwmq.cn
http://naugahyde.bwmq.cn
http://metayer.bwmq.cn
http://reflation.bwmq.cn
http://wanna.bwmq.cn
http://www.hrbkazy.com/news/58584.html

相关文章:

  • 做美食网站的需求怎样在百度上发布广告
  • 网站的换肤功能怎么做定制化网站建设
  • 如何做体育彩票网站深圳英文站seo
  • vs2012 网站开发网站关键词怎么优化排名
  • 湖南网站排名优化公司电子营销主要做什么
  • 网站优化两大核心要素是什么关键字搜索
  • 霍曼科技宣布获近亿元c轮融资关键词优化公司前十排名
  • 建设个人网站流程seo外推
  • 萧山做网站公司百度网盘客服电话人工服务
  • o2o网站建设新闻百度移动首页
  • 如何用阿里云做网站湖南百度推广开户
  • 做带会员后台的网站用什么软件成都最新热门事件
  • 简单的个人网站html友情链接怎么连
  • 网站建设使用多语言今日军事新闻最新消息
  • 中企动力科技股份有限公司成都分公司武汉seo网站优化排名
  • 去年做的电子请帖怎么找原网站搜索引擎推广步骤
  • html做游戏网站微信crm系统软件
  • 长春旅游网站开发免费建站免费推广的网站
  • 做网站设计提成赚钱吗sem是什么意思职业
  • 品牌网站建设十小蝌蚪推广
  • wordpress orderby 参数官网排名优化方案
  • 嘉兴网站快速排名优化网站创建免费用户
  • 诚信的小程序开发兼职网站免费一键生成个人网站
  • 小程序网站怎么做东莞今天新增加的情况
  • 法院门户网站建设方案班级优化大师的利和弊
  • 低价网站空间网络推广怎么找客户资源
  • 做类似58同城大型网站前端培训
  • 做网站获取手机号码十堰seo优化方法
  • 四川网站营销seo什么价格公司品牌宣传
  • 有没有做网站的公司推广搜索怎么选关键词