不要见笑,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. 菜鸟教程工具(三)——Maven自己主动部署Tomcat

    书连接至背面,在博客上,他介绍了如何使用Maven该项目包,这篇文章说,关于如何使用Maven会踢war部署包Tomcat.而不是手动copy过去. 眼下比較流行的方式有两种:一种是利用Tomcat官 ...

  2. OpenCVR 有新成员 OpenCVV OpenCVC

    OpenCVC主要负责OpenCVR报名, OpenCVV支持Android IOS Mac Windows 的client 版权声明:本文博客原创文章,博客,未经同意,不得转载.

  3. T-SQL技术收集——删除重复数据

    原文:T-SQL技术收集--删除重复数据 在工作和面试中,经常出现如何查询或者删除重复数据的问题,如果有主键,那还好办一点,如果没有主键,那就有点麻烦. 当一个表上没有辅助键时,如果使用SSMS界面来 ...

  4. MVC5 Entity Framework学习之实现继承

    之前你已经学习了怎样处理并发异常,在本节中你将学习怎样实现继承. 在面向对象的编程中,你能够使用继承来重用代码.接下来你将改动Instructor和Student类,让它们派生自Person基类,该基 ...

  5. Cocos2d-x 游戏植入广告(百度插屏)

    DEMO下载:http://download.csdn.net/detail/oyangyufu/7652803 1.声明Activity <!-- 声明百度的Activity --> & ...

  6. SQL Server 2008 R2 安全性专题(一):安全原则

    原文:SQL Server 2008 R2 安全性专题(一):安全原则 本系列主要专注与SQL Server 2005以后的DBMS,由于本人工作使用2008 R2,所以目前就针对2008 R2来做说 ...

  7. ASP.Net中使用XMLDataSource

    在Web开发中,程序和数据库打交道是常有的事情.在平时使用过程中,使用较多的是MS SQLSERVER,因此经常用到SQLDataSource将数据绑定的数据控件上.有时数据量较小,无需要在数据库中创 ...

  8. 获得span里面价值(在特殊情况下 )

    如何获得A? <div class="warpper"> <span class="content"> A <span>12 ...

  9. spring mvc 控制器方法传递一些经验对象的数组

    由于该项目必须提交一个表单,其中多个对象,更好的方法是直接通过在控制器方法参数的数组. 因为Spring mvc框架在反射生成控制方法的參数对象的时候会调用这个类的getDeclaredConstru ...

  10. NSIS脚本:更改壁纸

    原文 NSIS脚本:更改壁纸 我们在制作主题安装包的时候,经常要进行自动更改壁纸的操作,其实用NSIS实现这一点非常简单.示例代码如下: 01 Name "更改壁纸" 02 Out ...