不要见笑,cs基本入行很少做

留个demo备忘

/*
* Copyright (c) 2014-2024 . All Rights Reserved.
*
* This software is the confidential and proprietary information of
* LoongTao. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms of the agreements
* you entered into with LoongTao.
*
*/
package com.loongtao.main; import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List; import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField; import com.**.utils.RegexUtils; @SuppressWarnings("serial")
public class TestJFrame extends JFrame implements ActionListener {
private static int x = 80;
private static int y = 80;
private static int w = 1000;
private static int h = 750; private JLabel htmlLabel = new JLabel();
private JLabel resultLabel = new JLabel(); private JTextField urlField = new JTextField("", 82);
private JTextField cssPathField = new JTextField("", 82);
private JTextArea htmlArea = new JTextArea(20, 80);
private JScrollPane htmlScrollPane = new JScrollPane(htmlArea); private JTextArea resultArea = new JTextArea(30, 80);
private JScrollPane resultScrollPane = new JScrollPane(resultArea); private JButton jbGetSource = new JButton("转换");
private JButton jbResetAll = new JButton("重置"); public TestJFrame() {
this.setTitle("转换工具 1.3 @email cphmvp@163.com");
this.setLayout(new FlowLayout()); // 设置标签
this.add(htmlLabel);
this.htmlLabel.setText("源文本 : ");
// 设置文本域
this.htmlArea.setAutoscrolls(false);
this.htmlArea.setLineWrap(true);
// 分别设置水平和垂直滚动条总是出现
htmlScrollPane
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
htmlScrollPane
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
this.add(htmlScrollPane, BorderLayout.CENTER);
// 设置大小不会无限下滑
this.htmlScrollPane.setPreferredSize(new Dimension(900, 200));
this.add(htmlScrollPane); // 设置标签
this.add(resultLabel);
this.resultLabel.setText("结果集 :");
// 设置文本域
this.resultArea.setAutoscrolls(false);
this.resultArea.setLineWrap(true);
// 分别设置水平和垂直滚动条总是出现
resultScrollPane
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
resultScrollPane
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
this.add(resultScrollPane, BorderLayout.CENTER);
// 设置大小不会无限下滑
this.resultScrollPane.setPreferredSize(new Dimension(900, 250));
this.add(resultScrollPane); this.add(jbGetSource);
this.add(jbResetAll); jbGetSource.addActionListener(this);
jbResetAll.addActionListener(this); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} public static void main(String[] args) {
TestJFrame t = new TestJFrame();
// 1 x 2 y 3 宽、4 、高
t.setBounds(x, y, w, h);
t.setVisible(true);
} public void actionPerformed(ActionEvent e) {
JButton jb = (JButton) e.getSource();
String html = "";
String cssQuery = "";
if (jb == jbGetSource) {
dealGetSource(html, cssQuery);
} else if (jb == jbResetAll) {
urlField.setText("");
cssPathField.setText("");
htmlArea.setText("");
resultArea.setText("");
}
} /**
* @declare:处理得到源码操作
* @param html
* @param cssQuery
* @author cphmvp
*/
private void dealGetSource(String html, String cssQuery) {
String txt = htmlArea.getText();
htmlArea.setText(txt);
List<String> htmls = RegexUtils.getStringList(txt, "\\w+", 0);
String result = htmls.toString();
result = result.replace("[", "").replace("]", "");
resultArea.setText(result);
}
}

java_JFrame_demo的更多相关文章

随机推荐

  1. WPF和Expression Blend开发实例:一个样式实现的数字输入框

    原文:WPF和Expression Blend开发实例:一个样式实现的数字输入框 今天来一个比较奇淫技巧的手法,很少人用,同时也不推荐太过频繁的使用. 先上样式: <Style x:Key=&q ...

  2. .NET 4 并行(多核)编程系列之四 Task的休眠

    原文:.NET 4 并行(多核)编程系列之四 Task的休眠 .NET 4 并行(多核)编程系列之四 Task的休眠 前言:之前的几篇文章断断续续的介绍了Task的一些功能:创建,取消.本篇介绍Tas ...

  3. MapReduce 规划 六系列 MultipleOutputs采用

    在前面的示例,输出文件名是默认: _logs part-r-00001 part-r-00003 part-r-00005 part-r-00007 part-r-00009 part-r-00011 ...

  4. 原生js判断css动画结束 css 动画结束的回调函数

    原文:原生js判断css动画结束 css 动画结束的回调函数 css3 的时代,css3--动画 一切皆有可能: 传统的js 可以通过回调函数判断动画是否结束:即使是采用CSS技术生成动画效果,Jav ...

  5. 在python正在使用mysql

    缘由 近期在折腾一个小东西须要抓取网上的页面.然后进行解析.将结果放到数据库中. 了解到Python在这方面有优势,便选用之. 由于我有台server上面安装有mysql,自然使用之.在进行数据库的这 ...

  6. python基础课程_学习笔记26:编程的乐趣

    编程的乐趣 编程柔术 当你坐下来,打算如何组织计划要定时,具体程序,然而,无论什么经验.在实现时间的函数的,你会逐渐学会了原来的设计,实用的新知识.我们不应该忽视沿途汲取的教训,相反,它们用于其他设计 ...

  7. Mybatis之ResultMap一个简短的引论,关联对象

    基础部分能够查看我的还有一篇博客http://blog.csdn.net/elim168/article/details/40622491 MyBatis中在查询进行select映射的时候.返回类型能 ...

  8. Following unknown configure options were used:--enable-fpm

    跑cd   php-5.2.13安装时间 ./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc ...

  9. OpenCV视频播放方法

    OpenCV视频播放方法 今天折腾了一下OpenCV的视频播放功能,希望能对项目又帮助- 代码还是非常easy的,仅仅是之前遇到点小麻烦,找不到cvCreateFileCapture函数的定义,花了一 ...

  10. 跳跃Java一些周期,双跳FOR周期

    今天写的代码写在一个双层for周期,目前仍在使用Iterator,大致意思是假定在第二个周期在排位赛中给了整个双回路跳. 刚開始,直接使用break.巴拉巴拉的敲了一堆代码,信心满满的就直接执行.等到 ...