java_JFrame_demo
不要见笑,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的更多相关文章
随机推荐
- earlysuspend调用过程
1. 电源管理的状态 Android的Linux内核为系统提供了4种电源状态,内核的源码为当中的3种定义了名字和相应的宏定义,名字定义在kernel/power/suspend.c中: constch ...
- MyBatis系列教程(六)-- 与Spring综合(Integrate with Spring)
其它工具或技术需要使用: 项目管理工具 : Maven 前台WEB图库:JSP 其他框架:Spring, Spring MVC 数据库 : Derby Maven的Web项目 Maven Depend ...
- 【Web探索之旅】第二部分第三课:框架和内容管理系统
内容简介 1.第二部分第三课:框架和内容管理系统 2.第二部分第四课预告:数据库 第二部分第三课:框架和内容管理系统 上一课我们介绍了服务器端的编程语言,有PHP,Java,Python,Ruby ...
- 构建安全的Xml Web Service系列之初探使用Soap头
原文:构建安全的Xml Web Service系列之初探使用Soap头 Xml Web Service 从诞生那天就说自己都么都么好,还津津乐道的说internet也会因此而进入一个新纪元,可5年多来 ...
- (hdu step 6.3.5)Card Game Cheater(匹配的最大数:a与b打牌,问b赢a多少次)
称号: Card Game Cheater Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- 【转】Directx11 HelloWorld之HLSL的Effect框架的使用
最近尝试用了下Directx下的Effect框架,作为一初学者初学者,说下为什么我们要使用Effect框架及其好处吧. 首先Effect最大好处的就是简单,使得编写Shader绘制的程序工作量大大下降 ...
- C#启动进程之Process
在程序设计中,我们经常会遇到要从当前的程序跳到另一个程序的设计需求.也就是当前进程创建另一个进程.C#提供了Process使得我们很方便的实现. 1.Process基本属性和方法 Id //进程的Id ...
- POJ 1659 Frogs' Neighborhood(度序列组成)
意甲冠军 中国 依据Havel-Hakimi定理构图即可咯 先把顶点按度数从大到小排序 可图的话 度数大的顶点与它后面的度数个顶点相连肯定是满足的 出现了-1就说明不可图了 #include ...
- HDU 1677 Nested Dolls
过了之后感觉曾经真的做过这样的类型的题. 之前一直非常疑惑二级排序的优先级问题,如今发现二级排序真的没有绝对的优先级. 对于此题,若按W排序,则有1到i件物品的W均小于等于第i+1件物品(设为A)的W ...
- Solr/SolrCloud -error
状态 2014-08-20 10:46:22,356 INFO [coreZkRegister-1-thread-1] [org.apache.solr.cloud.ShardLeaderElecti ...