不要见笑,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. Shell在大数据的魅力时代:从一点点思路百度大数据面试题

    供Linux开发中的同学们,Shell这可以说是一个基本功. 对于同学们的操作和维护.Shell也可以说是一种必要的技能,Shell.对于Release Team,软件配置管理的同学来说.Shell也 ...

  2. [LeetCode62]Unique Paths

    题目: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). ...

  3. 8.Eclipse中创建Maven Web项目

     第一步: 创建maven webproject 注意以下一步: 第二步: 继承parent 改动pom.xml文件例如以下 <projectxmlns="http://maven ...

  4. Eclipse4.4设备egit插件提交本地项目代码到远程仓库

    一.设备egit 打开Eclipse的Marketplace.在搜索框中输入egit就可以,能够看到Eclipse4.4已经默认安装了egit,当然假设有新版本号的egit公布的话,也能够在下图上点击 ...

  5. FlowLayoutPanel 内的控件怎么调换顺序?

    lowLayoutPanel1.Controls.SetChildIndex("flowLayoutPanel中的控件",顺序索引)

  6. 给AspNetPager分页控件添加bootstrap样式

    AspNetPager分页控件算是比较好用的一个分页控件了.想要结合bootstrap使用,官方代码入口 .pagination a[disabled]{ color: #777;cursor: no ...

  7. Android Activity之间通信

    package com.example.myapp; import android.app.Activity; import android.content.DialogInterface; impo ...

  8. HDU - 5186 - zhx&#39;s submissions (精密塔尔苏斯)

    zhx's submissions Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  9. atcoder它A Mountaineer

    Time limit : 2sec / Stack limit : 256MB / Memory limit : 256MB Problem Dave is a mountaineer. He is ...

  10. Youtube最佳Red5 官方视频下载指南,字幕【亲测成功】

    前言 最近在研究Red5 流媒体服务框架,官网上的信息足以让一个新手入门 有官方參考手冊 -- 高速了解red5的相关信息 有Red5 on Stackoverflow  -- 在上面能够提问或者回答 ...