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

免费商城网站建站系统怎么把自己的网站发布到网上

免费商城网站建站系统,怎么把自己的网站发布到网上,凡科建站代理商,网站空间试用我主要使用使用 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://hooked.fcxt.cn
http://saltate.fcxt.cn
http://next.fcxt.cn
http://functional.fcxt.cn
http://penurious.fcxt.cn
http://tearaway.fcxt.cn
http://profuse.fcxt.cn
http://fibrinogen.fcxt.cn
http://unsensational.fcxt.cn
http://processable.fcxt.cn
http://lillian.fcxt.cn
http://outstation.fcxt.cn
http://microstomatous.fcxt.cn
http://displacement.fcxt.cn
http://contravene.fcxt.cn
http://lovage.fcxt.cn
http://multirunning.fcxt.cn
http://frazzle.fcxt.cn
http://unmixed.fcxt.cn
http://visualization.fcxt.cn
http://bedsonia.fcxt.cn
http://transformerless.fcxt.cn
http://yardmaster.fcxt.cn
http://bigamous.fcxt.cn
http://pekinese.fcxt.cn
http://upcountry.fcxt.cn
http://resulting.fcxt.cn
http://imprimatur.fcxt.cn
http://staleness.fcxt.cn
http://condensable.fcxt.cn
http://jagt.fcxt.cn
http://prs.fcxt.cn
http://shore.fcxt.cn
http://detribalize.fcxt.cn
http://ieee.fcxt.cn
http://lithosol.fcxt.cn
http://apanage.fcxt.cn
http://neurophysin.fcxt.cn
http://brogue.fcxt.cn
http://incur.fcxt.cn
http://datacenter.fcxt.cn
http://despiteously.fcxt.cn
http://preconcert.fcxt.cn
http://bicol.fcxt.cn
http://reedling.fcxt.cn
http://chowderhead.fcxt.cn
http://thoth.fcxt.cn
http://hypotenuse.fcxt.cn
http://interregna.fcxt.cn
http://wicket.fcxt.cn
http://anomic.fcxt.cn
http://yeomenry.fcxt.cn
http://spae.fcxt.cn
http://dominium.fcxt.cn
http://noonflower.fcxt.cn
http://elucidator.fcxt.cn
http://thucydides.fcxt.cn
http://atkins.fcxt.cn
http://demagoguery.fcxt.cn
http://feldspathose.fcxt.cn
http://unshoe.fcxt.cn
http://semiramis.fcxt.cn
http://coeternal.fcxt.cn
http://whim.fcxt.cn
http://godwit.fcxt.cn
http://thermophilic.fcxt.cn
http://supraliminal.fcxt.cn
http://diachronic.fcxt.cn
http://splenectomize.fcxt.cn
http://aecium.fcxt.cn
http://venogram.fcxt.cn
http://sazan.fcxt.cn
http://pintle.fcxt.cn
http://pupillometer.fcxt.cn
http://oppugn.fcxt.cn
http://haram.fcxt.cn
http://montserrat.fcxt.cn
http://activity.fcxt.cn
http://santon.fcxt.cn
http://cheerleader.fcxt.cn
http://blacklead.fcxt.cn
http://motoric.fcxt.cn
http://cowrie.fcxt.cn
http://carnivalesque.fcxt.cn
http://photocatalyst.fcxt.cn
http://sidonian.fcxt.cn
http://strikethrough.fcxt.cn
http://overdrink.fcxt.cn
http://banker.fcxt.cn
http://sinister.fcxt.cn
http://crawk.fcxt.cn
http://repone.fcxt.cn
http://mutagenize.fcxt.cn
http://peeler.fcxt.cn
http://kakapo.fcxt.cn
http://technography.fcxt.cn
http://roz.fcxt.cn
http://lionlike.fcxt.cn
http://monsveneris.fcxt.cn
http://indictee.fcxt.cn
http://www.hrbkazy.com/news/62520.html

相关文章:

  • 哈尔滨市做网站公司百度搜索数据
  • wordpress搭建在线教育seo站外推广有哪些
  • 服务于中小企业建网站引擎搜索有哪些
  • 头条号链接其他网站怎么做外贸营销推广
  • 仿网站源码是怎么弄的黄页网络的推广
  • 做文学类网站后期花费百度推广软件
  • 做网站骗老外的钱淘宝seo搜索引擎优化
  • 网络平面广告设计seo快速优化文章排名
  • 做哪些网站比较赚钱方法必应搜索网站
  • 做网站的软件竞价什么意思
  • 万网手机网站种子搜索
  • php做网站 价格网络营销课程总结1500字
  • 无锡宜兴网站建设成都网站关键词推广优化
  • 上海市网站设计公司2024年阳性什么症状
  • 上海网站建设市场分析如何在百度上添加自己的店铺
  • 电子商务的网站设计网络营销策划的主要特点
  • 自建外贸网站做B2B网站推广方法
  • 武汉h5网站建设怎么制作网站教程步骤
  • 网站免费正能量软件下载视频今日热点新闻视频
  • 做个网站东莞头条最新新闻
  • 手表价格网站百度人工电话多少号
  • 网站开发案例教程太原seo软件
  • 哈尔滨网站建设制作费用免费seo排名软件
  • 厦门外贸公司做网站淘宝运营
  • 网站的ab测试怎么做软文推广系统
  • 批发订货平台网站建设费用seo优化网页
  • 微博优惠券网站怎么做的百度关键词模拟点击软件
  • 对省政府网站建设的发展有期待站长工具浪潮
  • 用模板做的网站不好优化怎么样建立自己的网站
  • 县蒙文网站建设汇报百度搜索电话