不要见笑,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. HDU 1885 Key Task 国家压缩+搜索

    点击打开链接 Key Task Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  2. 乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)

    原文:乐在其中设计模式(C#) - 桥接模式(Bridge Pattern) [索引页][源码下载] 乐在其中设计模式(C#) - 桥接模式(Bridge Pattern) 作者:webabcd 介绍 ...

  3. partial 的好处

    1.可以将一个类中的属 性, 方法分类来写 2.方法了可以写在多个类中, 这样可以对方法进行分类   由于项目上使用了代码生成工具, 自定义的一些按钮事件默认是不生成的,得自己定义,如果把定义的代码写 ...

  4. How to install PL/SQL developer on linux (转)

    PL/SQL developer 在linux上的安装方法工欲善其事必先利其器,PL/SQL和toad对于ORACLE从业人员来说都是很重要的工具,但这些工具都没有linux的发行版,如果要在linu ...

  5. IE按F12,开发者工具已经在最低点,那么国家就不会出错

    ie浏览器.按F12,开发工具将问世. 没有,试试下面的方法就可以解决: 开开发者工具图标,它会出来缩略图,于缩略图右键点-你可以最大限度地提高.然后选择IE8兼容模式可 版权声明:本文博主原创文章. ...

  6. ef添加字段

    先在实体类里添加字段 ,然后执行 Add-Migration updateNumberOfLikes Update-Database -Verbose

  7. RH033读书笔记(15)-Lab 16 The Linux Filesystem

    Lab 16 The Linux Filesystem Goal: Develop a better understanding of Linux filesystem essentials incl ...

  8. SDUT 2894-C(最短spfa)

    C Time Limit: 7000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描写叙述 给出一个带权无向图.包括n个点,m条边.求出s,e的最短路.保证最短路存在 ...

  9. SQL SERVER SQLOS的任务调度

    原文:SQL SERVER SQLOS的任务调度 原文地址:http://blogs.msdn.com/b/apgcdsd/archive/2011/11/24/sql-server-sqlos.as ...

  10. POJ 3280 Cheapest Palindrome (DP)

     Description Keeping track of all the cows can be a tricky task so Farmer John has installed a sys ...