2014-12-16 23:14:28

RSyntaxTextArea 在OS X下 css背景渲染速度非常慢的bug

很久就发现了一个RSyntaxTextArea在OS X下加载某些脚本文件的时候非常卡,不知道是什么原因。最近终于忍无可忍了跑去问了下RSyntaxTextArea作者得知这个bug已经在RSyntaxTextArea的最新版修复了。 问题大概发生的情况是:setSyntaxEditingStyle为SYNTAX_STYLE_JSP,然后jsp当中包含了如下css样式字符串如: body {background-color: #ffffff;color: #000000;} body {background-color: #ffffff;color: #000000;} body {background-color: #ffffff;color: #000000;} body {background-color: #ffffff;color: #000000;} body {background-color: #ffffff;color: #000000;} body {background-color: #ffffff;color: #000000;} body {background-color: #ffffff;color: #000000;} body {background-color: #ffffff;color: #000000;} body {bac

2014-11-29 23:55:07

JTabbedPane 监听tab选中改变事件

利用的是javax.swing.event.ChangeListener,原文Listening for Selected Tab Changes。实现方式都是callback,不过在实际当中为了方便我选择了自己写callback。 import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JTabbedPane; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; public class TabSample { static void add(JTabbedPane tabbedPane, String label) { JButton button = new JButton(label); tabbedPane.addTab(label, button); } public static void main(String args[]) { JFrame frame = new JFrame("Tabbed Pane Sample"); frame.setDefaultCloseO

2014-11-10 11:21:09

Idea 14注册机

今天在iteye看到有人发idea注册码:IntelliJ IDEA 14 注册码 IntelliJ IDEA 14 下载 分享几个license: key:IDEA value:61156-YRN2M-5MNCN-NZ8D2-7B4EW-U12L4 key:huangwei value:97493-G3A41-0SO24-W57LI-Y2UGI-JGTU2 key:hkl520 value:34423-VZYXD-FQXZ7-O6I7U-J3ZK8-R7V62 key:Intelligent value:40957-EG6O9-2915L-CF1RP-57IQJ-Y6VZ3 key:tommy value:49164-YPNVL-OXUZL-XIWM4-Z9OHC-LF053 key:whuanghk value:98220-IN97R-TV1ID-2JAPO-OXZEO-LAM70 key:itey value:91758-T1CLA-C64F3-T7X5R-A7YDO-CRSN1 yixiandave 提供了注册算法,为了方便我简单的画了个注册机。 下载地址:Idea14_KeyGen.jar

2014-11-05 10:50:54

JavaSwing JComboBox模拟html的select标签

JComboBox默认不支持name属性设置,getSelectedItem()默认返回的是String。实际上可以模仿原生的DefaultComboBoxModel实现一个自己的DefaultComboBoxModel。 DefaultComboBoxModel.java package org.javaweb.swing.ui; import java.util.Vector; import javax.swing.AbstractListModel; import javax.swing.ComboBoxModel; /** * 实现默认ComboBoxModel * * @author yz */ public class DefaultComboBoxModel extends AbstractListModel implements ComboBoxModel { private Object selectedItem; Vector<JComboBoxItem> objects; public DefaultComboBoxModel(Vector<JComboBoxItem> objects) { this.objects = objects; } @Override p

2014-10-10 10:48:55

JavaSwing 简单模拟Mac Finder

为了方便切换,我把Panel和JFrame分开了。之前画了个用的Netbeans,但是感觉毕竟没有手写的方便扩展。 NetBeans画的: 代码写的: MainFrame.java: package org.javaweb.burp.test; import java.awt.Dimension; import javax.swing.JFrame; /** * * @author yz */ public class MainFrame extends JFrame { private static final long serialVersionUID = 1L; public MainFrame() { initComponents(); } private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); this.setTitle("测试"); this.add(new ApplicationPanel()); int screenWidth = java.awt.Toolkit.getDefaultT

2014-08-31 17:34:33

Swing JTable 动态SQL语句查询

写了无数次了,保存起来下次不重写了。每执行一次查询更新一次table的表头和表行数据。 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton1ActionPerformed ResultSet rs = DBUtil.executeQuery(textField1.getText());//执行SQL语句 // jTable1 = new JTable(); try { List<List<Object>> ls = new ArrayList<List<Object>>(); List<String> column = new ArrayList<String>(); ResultSetMetaData rsm = rs.getMetaData();//获取表元数据 for (int i = 1; i < rsm.getColumnCount()+1; i++) { column.add(rsm.getColumnName(i)); } while (rs.next()) { List<Objec

2014-08-25 14:41:02

JTabbedPane 加close的两种方法(jdk1.5和1.6+)

JTabbedPane在1.6的时候新增了setTabComponentAt方法(http://docs.oracle.com/javase/tutorial/uiswing/components/tabbedpane.html),插入一个关闭按钮很方便,但是jdk1.6以下并不支持。找了两种能够支持关闭按钮的写法,第二种是从http://www.codeproject.com/Articles/18496/JTabbedPane-with-Closing-Tabs上拔下来,简单的改了下1.5应该可用。 NewJFrame.java package org.javaweb.jrat.server.ui; /** * * @author yz */ public class NewJFrame extends javax.swing.JFrame { public NewJFrame() { initComponents(); } private void initComponents() { jPanel1 = new javax.swing.JPanel(); jTabbedPane1 = new javax.swing.JTabbedPane(); jScrollPane1 = new

2014-08-06 18:43:52

JPanel流水布局加滚动条

JPanel设置布局为WrapLayout:WrapLayout layout = new WrapLayout(FlowLayout.LEFT, 55, 30);最后把JPanel加到JScrollPane。 WrapLayout.java package org.javaweb.jrat.server.ui; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Insets; import javax.swing.JScrollPane; import javax.swing.SwingUtilities; /** * FlowLayout subclass that fully supports wrapping of components. */ public class WrapLayout extends FlowLayout { private Dimension preferredLayoutSize; /** * Constructs a new <code>WrapLayout</code> with a left

2014-07-28 16:52:33

JavaSwing Jtree 自定义node(选中节点获取自定义节点信息)

如果选中一个节点直接通过node的text去获取很多时候是不行的,最简单的办法是继承DefaultMutableTreeNode类,重写toString和构造方法。 import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; public class TreeActionMap extends JFrame{ private static final long serialVersionUID = 1L; public static void main(String[] args) { JFrame j = new JFrame("Test"); j.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); j.setSize(500, 300); j.setLocation(500, 300); NodeBean root = new NodeBean("用户列表&quo

2014-07-25 22:50:21

Jtree

隐藏root:jtree.setRootVisible(false); 2: import java.awt.BorderLayout; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeNode; public class Admin extends JFrame{ private static final long serialVersionUID = 1L; private JTree createJTree() { JTree jTree = new JTree(); jTree.setRootVisible( false ); DefaultMutableTreeNode root = new DefaultMutableTreeNode("root node, should be invisible"); DefaultTreeModel defaultTreeModel = new DefaultTreeModel( root ); jT