AutoCodeGenTool自动生成重复代码

AutoCodeGenTool自动生成重复代码
2011年06月01日
   公司系统用tikeswing做表现层,配置布局的时候有很多重复的代码,于是使用这个工具自动生成代码:
  
  左边是变化的变量名,右下是套用的重复代码格式,按钮指代使用哪种格式填入变量名。
  package transms.app._0all.util; import java.awt.BorderLayout; import java.text.BreakIterator; import javax.swing.JTextArea; import javax.swing.JTabbedPane; import javax.swing.JScrollPane; import javax.swing.border.TitledBorder; import javax.swing.JPanel; import javax.swing.JToolBar; import javax.swing.JButton; import javax.swing.JSplitPane; public class AutoCodeGenTool extends javax.swing.JFrame { private static final long serialVersionUID = 627855237034164778L; private javax.swing.JButton ivjJButton1 = null; private javax.swing.JPanel ivjJFrameContentPane = null; private javax.swing.JTextArea txtVar1 = null; private JTextArea txtResult = null; private JTextArea txtPara1 = null; private JTabbedPane tpWest = null; private JScrollPane spWest1 = null; private JScrollPane spWest2 = null; private JTextArea txtVar2 = null; private JScrollPane spWest3 = null; private JTextArea txtVar3 = null; private JTabbedPane tpSouth = null; private JScrollPane spSouth1 = null; private JScrollPane spSouth2 = null; private JScrollPane spSouth3 = null; private JTextArea txtPara2 = null; private JTextArea txtPara3 = null; private JScrollPane spCenter = null; private JToolBar jJToolBarBar = null; private JButton jButton = null; private JButton jButton1 = null; private JButton jButton2 = null; private JButton jButton3 = null; private JSplitPane jSplitPane = null; private JSplitPane jSplitPane1 = null; private JPanel jPanel = null; public AutoCodeGenTool() { super(); initialize(); } /** * Return the JButton1 property value. * * @return javax.swing.JButton */ private javax.swing.JButton getJButton1() { if (ivjJButton1 == null) { ivjJButton1 = new javax.swing.JButton(); ivjJButton1.setName("JButton1"); ivjJButton1.setText("开始"); ivjJButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { doStaff1(); getTxtResult().setSelectionStart(0); getTxtResult().setSelectionEnd(getTxtResult().getC aretPosition()); getTxtResult().requestFocusInWindow(); getTxtResult().copy(); } }); } return ivjJButton1; } protected void doStaff1() { String s1 = getVar(); BreakIterator it = BreakIterator.getLineInstance(); it.setText(s1); int start = it.first(); txtResult.setText(""); for (int end = it.next(); end != BreakIterator.DONE; start = end, end = it.next()) { doStaff2(s1.substring(start, end)); } } private String getVar() { switch (this.tpWest.getSelectedIndex()) { case 0: return txtVar1.getText(); case 1: return txtVar2.getText(); case 2: return txtVar3.getText(); default: return ""; } } private void doStaff2(String para) { String org = getPara(); /** * @@原参数 * @#首字母大写其他不变参数 #@首字母小写其他不变参数 全大写参数 >", para.toUpperCase()); org = org.replaceAll(">"); focusSouth(); } }); } return jButton2; } /** * This method initializes jButton3 * * @return javax.swing.JButton */ private JButton getJButton3() { if (jButton3 == null) { jButton3 = new JButton(); jButton3.setText(" 小 "); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { getTxt().replaceSelection("><"); focusSouth(); } }); } return jButton3; } /** * This method initializes jSplitPane * * @return javax.swing.JSplitPane */ private JSplitPane getJSplitPane() { if (jSplitPane == null) { jSplitPane = new JSplitPane(); jSplitPane.setResizeWeight(0.2D); jSplitPane.setRightComponent(getJSplitPane1()); jSplitPane.setLeftComponent(getTbWest()); } return jSplitPane; } /** * This method initializes jSplitPane1 * * @return javax.swing.JSplitPane */ private JSplitPane getJSplitPane1() { if (jSplitPane1 == null) { jSplitPane1 = new JSplitPane(); jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPL IT); jSplitPane1.setResizeWeight(0.8D); jSplitPane1.setBottomComponent(getJPanel()); jSplitPane1.setTopComponent(getSpCenter()); } return jSplitPane1; } /** * This method initializes jPanel * * @return javax.swing.JPanel */ private JPanel getJPanel() { if (jPanel == null) { jPanel = new JPanel(); jPanel.setLayout(new BorderLayout()); jPanel.add(getJJToolBarBar(), BorderLayout.NORTH); jPanel.add(getTpSouth(), BorderLayout.CENTER); } return jPanel; } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值