当前位置: 代码迷 >> Java相关 >> [讨论]一个小小的建议
  详细解决方案

[讨论]一个小小的建议

热度:169   发布时间:2007-07-07 15:09:11.0
[讨论]一个小小的建议
论坛里发贴的时候很多人一大段的代码直接贴在贴子里,这样别人测试的时候从浏览器里复制很容易出错,而且排版也乱了(最明显的一点就是TAB变为了空格),而且如果代码较长在浏览器里看也是不方便的。所以我建议无论多长的代码(当然一两行除外),大家都能够提供一个下载,这样方便大家使用。

比如可以只贴出你自己的博客(主页)上的下载链接如:

http://cocobear.cn/src/Jwind.java

不知道大家觉得合适不。
搜索更多相关的解决方案: 小小的  

----------------解决方案--------------------------------------------------------

最好是把关键代码帖出来,然后打包所有代码上传


----------------解决方案--------------------------------------------------------
QUOTE:
以下是引用千里冰封在2007-7-7 16:46:04的发言:

最好是把关键代码帖出来,然后打包所有代码上传

嗯,有道理.
----------------解决方案--------------------------------------------------------
非也非也~用NetBeans可以自动进行代码整理
----------------解决方案--------------------------------------------------------

QUOTE:
以下是引用神vLinux飘飘在2007-7-7 18:05:17的发言:
非也非也~用NetBeans可以自动进行代码整理

 这个和自动代码整理没有关系啊.
----------------解决方案--------------------------------------------------------
NetBeans为了适应这种情况,已经预先把所有的TAB都替换成空格了
[CODE]
/*
* PanelA.java
*
* Created on 2007年7月7日, 下午6:23
*/

package help;

/**
*
* @author vlinux
*/
public class MyPanel extends javax.swing.JPanel {

/** Creates new form PanelA */
public MyPanel() {
initComponents();
}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {

jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jEditorPane1 = new javax.swing.JEditorPane();

jLabel1.setText("jLabel1");

jLabel2.setText("jLabel2");

jLabel3.setText("jLabel3");

jTextField1.setText("jTextField1");

jTextField2.setText("jTextField2");

jTextField3.setText("jTextField3");

jButton1.setText("jButton1");

jButton2.setText("jButton2");

jButton3.setText("jButton3");

jScrollPane1.setViewportView(jEditorPane1);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton3)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE)
.addContainerGap())
);
}// </editor-fold>


// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JEditorPane jEditorPane1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
// End of variables declaration

}

[/CODE]
----------------解决方案--------------------------------------------------------

回复:(可可熊)[讨论]一个小小的建议
可惜不能直接粘贴上netbeans的html输出

[此贴子已经被作者于2007-7-8 9:31:38编辑过]


----------------解决方案--------------------------------------------------------
??
我的解决办法是:
1 复制到EditPlus
2 然后从EditPlus复制到word
3 然后居中, 接着左对齐
4 最后就复制到NB里了, 哈哈。

可惜的是代码风格变了, 我在NB里ctrl+shif+f怎么就不能调整格式?
----------------解决方案--------------------------------------------------------
预先把TAB替换为空格,这个可不好啊。
----------------解决方案--------------------------------------------------------
用IE浏览器,TAB会自动变成4个半角空格,不会影响排版和编译的。
----------------解决方案--------------------------------------------------------
  相关解决方案