⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newjframe.java

📁 基于netbeans的java桌面应用程序合集
💻 JAVA
字号:
/*
 * NewJFrame.java
 *
 * Created on 2007年11月30日, 下午4:49
 */

package org.Adam;


import java.util.Date;
/**
 *
 * @author  Administrator
 */
public class NewJFrame extends javax.swing.JFrame {
    String msg="这是一个跑马灯效果的JavaScript";

    int interval = 100;

    int spacelen = 120;

    String space10=" ";

    int  seq=0;
    Time ttt=new Time();
    /** Creates new form NewJFrame */
    public NewJFrame() {
        initComponents();
        this.setLocationRelativeTo(this);
        Scroll();
        Scroll2();
        Scroll();
    }
    
private void Scroll() {
    
    int len = msg.length();

    this.jLabel1.setText(msg.substring(0, seq+1));

    seq++;

    if ( seq >= len ) { 

    seq = spacelen; 

    ttt.setTime(interval);
    Scroll2();

    }

    else

    ttt.setTime( interval );
    Scroll();
} 

private void Scroll2() {

    String out="";

    for (int i=1; i<=spacelen/space10.length(); i++) 

   out=out+space10;

    out = out + msg;

    int len=out.length();

    this.jLabel1.setText(out.substring(seq, len));

    seq++;

    if ( seq >= len ) { seq = 0; };

    ttt.setTime( interval );
    //Scroll2();
} 
    
//Scroll();
    /** 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=" 生成的代码 ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap(426, Short.MAX_VALUE)
                .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewJFrame().setVisible(true);
            }
        });
    }
    
    // 变量声明 - 不进行修改//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    // 变量声明结束//GEN-END:variables
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -