2017-04-22 432 views
1

我是這裏的新成員,所以如果我沒有列出任何需要您授予我回答的問題。Telnet vbs into Java

我的問題是,我做了一段時間的基礎類型所有telnet信息,需要通過telnet配置telewell調制解調器。

我想要做的是將其轉換成java並製作一個很好的框架,詢問什麼IP地址分配給調制解調器,而不使用vb​​s使用的笨重方法。 vbs停止在一個點上,並提供一個窗口,表明您應該在telnet命令窗口中寫入「xxx.xxx.xxx.xxx」代表您想要分配給調制解調器的IP地址,然後在它再次執行時斷開並嘗試再次連接。

在sub.pause彈出一個窗口後,它不幸在瑞典語中出現,但它轉換爲「在遠程登錄命令窗口中寫入所需的IP地址而不是xxx.xxx.xxx.xxx」。

希望有人爲可以給我一些還挺方向走,我就可以開始取得進展我的技能在Java :)

溴。 Shmooss

set cloner=createobject("WScript.shell") 
cloner.run"cmd" 
WScript.Sleep 500 
cloner.SendKeys"telnet 192.168.0.254" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"admin" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"admin" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"port s1 set 4WireEnable false" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"port s1 set 4WMode CO" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"port s1 set 4WType Annex_B" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"port s1 set 4WAutoStart true" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"port s1 set 4WConnected true" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"port s1 set BitRateMod Fixed" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"port s1 set FixedBitRate 2056kbps" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"port s1 set Mode CO" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"port s1 set FramerType Level2" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"port s1 set Whip Inactive" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"port s1 set ActivateLine true" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"port s1 set 4WActivateLine true" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"rfc1483 set transport wanlink vci 32" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"rfc1483 set transport wanlink vpi 0" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"ip set interface iplan ipaddress xxx.xxx.xxx.xxx" 
Pause 
Sub Pause() 
    WScript.Echo ("Ersätt xxx.xxx.xxx.xxx med den IP-ADRESS du vill att modemet skall ha. SEDAN TRYCK OK! OBS. Om du är osäker fråga någon vettigare :)") 
End Sub 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.run"cmd" 
WScript.Sleep 500 
cloner.SendKeys"telnet xxx.xxx.xxx.xxx" 
Pause 
Sub Pause() 
    WScript.Echo ("Ersätt xxx.xxx.xxx.xxx med den IP-ADRESS du vill att modemet skall ha. SEDAN TRYCK OK! OBS. Om du är osäker fråga någon vettigare :)") 
End Sub 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"admin" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"admin" 
cloner.SendKeys("{Enter}") 
WScript.Sleep 500 
cloner.SendKeys"system config save" 
cloner.SendKeys("{Enter}") 
Wscript.Sleep 500 

這是我迄今所做

import java.awt.BorderLayout; 
import java.awt.EventQueue; 

import javax.swing.JFrame; 
import javax.swing.JOptionPane; 
import javax.swing.JPanel; 
import javax.swing.JTextArea; 
import javax.swing.border.EmptyBorder; 
import javax.xml.ws.handler.MessageContext; 
import javax.swing.JTextField; 
import javax.swing.JButton; 
import javax.management.ImmutableDescriptor; 
import javax.swing.DropMode; 
import java.awt.Font; 
import java.awt.event.ActionListener; 
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.io.PrintStream; 
import java.io.PrintWriter; 
import java.net.Socket; 
import java.awt.event.ActionEvent; 
import javax.swing.JTextPane; 

public class Window extends JFrame { 

    private JPanel contentPane; 
    private JTextField txtNewadress; 
    private JTextField textFieldwriteip; 
    private JButton btnApply; 
    private JTextField textProgress; 

    /** 
    * Launch the application. 
    */ 
    public static void main(String[] args) { 
     EventQueue.invokeLater(new Runnable() { 
      public void run() { 
       try { 
        Window frame = new Window(); 
        frame.setVisible(true); 
       } catch (Exception e) { 
        e.printStackTrace(); 
       } 
      } 
     }); 
    } 

    /** 
    * Create the frame. 
    */ 
    public Window() { 
     setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
     setBounds(100, 100, 400, 148); 
     contentPane = new JPanel(); 
     contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 
     contentPane.setLayout(new BorderLayout(0, 0)); 
     setContentPane(contentPane); 

     txtNewadress = new JTextField(); 
     txtNewadress.setFont(new Font("Tahoma", Font.BOLD, 11)); 
     txtNewadress.setEditable(false); 
     txtNewadress.setText("IP-Adress for your modem, write below"); 
     contentPane.add(txtNewadress, BorderLayout.NORTH); 
     txtNewadress.setColumns(10); 

     textFieldwriteip = new JTextField(); 
     textFieldwriteip.setFont(new Font("Tahoma", Font.PLAIN, 20)); 
     contentPane.add(textFieldwriteip, BorderLayout.CENTER); 
     textFieldwriteip.setColumns(10); 

     btnApply = new JButton("SET/APPLY"); 
     btnApply.addActionListener(new ActionListener() { 
      public void actionPerformed(ActionEvent arg0) { 

       connect (textFieldwriteip.getText()); 
      } 
     }); 
     contentPane.add(btnApply, BorderLayout.EAST); 

     textProgress = new JTextField(); 
     textProgress.addActionListener(new ActionListener() { 
      public void actionPerformed(ActionEvent arg0) { 


      } 
     }); 
     contentPane.add(textProgress, BorderLayout.SOUTH); 
     textProgress.setColumns(10); 





    } 
    void connect (String ip) 
    { 
     Socket sock = null; 
     PrintWriter pw = null; 

     try 
     { 
     sock = new Socket(ip = "192.168.0.254", 23); 

     pw = new PrintWriter(sock.getOutputStream()); 


     System.out.println("Sending username"); 
     pw.println("admin"); 

     System.out.println("Sending password"); 
     pw.println("admin"); 

     System.out.println("Sending Configuration 1/15"); 
     pw.println("port s1 set 4WireEnable false"); 

     System.out.println("Sending Configuration 2/15"); 
     pw.println("port s1 set 4WMode CO"); 

     System.out.println("Sending Configuration 3/15"); 
     pw.println("port s1 set 4WType Annex_B"); 

     System.out.println("Sending Configuration 4/15"); 
     pw.println("port s1 set 4WautoStart true"); 

     System.out.println("Sending Configuration 5/15"); 
     pw.println("port s1 set 4WConnected true"); 

     System.out.println("Sending Configuration 6/15"); 
     pw.println("port s1 set BitRateMod Fixed"); 

     System.out.println("Sending Configuration 7/15"); 
     pw.println("port s1 set FixedBitRate 2056kbps"); 

     System.out.println("Sending Configuration 8/15"); 
     pw.println("port s1 set Mode CO"); 

     System.out.println("Sending Configuration 9/15"); 
     pw.println("port s1 set FramerType Leve12"); 

     System.out.println("Sending Configuration 10/15"); 
     pw.println("port s1 set Whip Inactive"); 

     System.out.println("Sending Configuration 11/15"); 
     pw.println("port s1 set ActivateLine true"); 

     System.out.println("Sending Configuration 12/15"); 
     pw.println("port s1 set 4WActivateLine true"); 

     System.out.println("Sending Configuration 13/15"); 
     pw.println("rfc1483 set transport wanlink vci 32"); 

     System.out.println("Sending Configuration 14/15"); 
     pw.println("rfc1483 set transport wanlink vpi 0"); 

     pw.close(); 

     sock.close(); 

     Thread.sleep(1000); 


     } catch (IOException | InterruptedException e) 
     { 
      e.printStackTrace(); 
      JOptionPane.showMessageDialog(this, "SPERMABÖG"); 
      } 
} 
} 

回答

0

所以我做了一個後一個星期又回到了我問的問題,如果人們會有任何想法如何做到這一點。但是,因爲沒有人能夠給我一個關於如何處理它或給我任何提示的答案。我自己搜索並且自己學會了如何去做。

,所以我想和你在一起我已經完成

這樣做是你可以在CO配置或CPE配置,以使您的telewell調制解調器的內側之間選擇共享(很可能與一些別的工作但沒有試過調制解調器)

import java.awt.BorderLayout; 
import java.awt.EventQueue; 
import java.io.OutputStream; 

import javax.swing.JFrame; 
import javax.swing.JOptionPane; 
import javax.swing.JPanel; 
import javax.swing.JTextArea; 
import javax.swing.border.EmptyBorder; 
import javax.xml.ws.handler.MessageContext; 
import javax.swing.JTextField; 
import javax.swing.JButton; 
import javax.management.ImmutableDescriptor; 
import javax.swing.DropMode; 
import java.awt.Font; 
import java.awt.event.ActionListener; 
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.io.PrintStream; 
import java.io.PrintWriter; 
import java.net.Socket; 
import java.awt.event.ActionEvent; 
import javax.swing.JTextPane; 
import java.awt.Window.Type; 
import javax.swing.SwingConstants; 
import javax.swing.JMenuBar; 
import javax.swing.JCheckBoxMenuItem; 
import javax.swing.JMenu; 
import javax.swing.ButtonGroup; 

public class Window extends JFrame { 

    private JPanel contentPane; 
    private JTextField txtInfo; 
    private JTextField textFieldwriteip; 
    private JButton btnSet; 
    private JTextField textProgress; 
    private JButton btnHelp; 
    private final ButtonGroup buttonGroup = new ButtonGroup(); 

    /** 
    * Launch the application. 
    */ 
    public static void main(String[] args) { 
     EventQueue.invokeLater(new Runnable() { 
      public void run() { 
       try { 
        Window frame = new Window(); 
        frame.setVisible(true); 
       } catch (Exception e) { 
        e.printStackTrace(); 
       } 
      } 
     }); 
    } 

    /** 
    * Create the frame. 
    */ 
    public Window() { 
     setTitle("Telewell Modem Config"); 
     setResizable(false); 
     setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
     setBounds(100, 100, 439, 166); 

     JMenuBar menuBar = new JMenuBar(); 
     setJMenuBar(menuBar); 

     btnHelp = new JButton("Help"); 
     btnHelp.addActionListener(new ActionListener() { 
      public void actionPerformed(ActionEvent arg0) { 

       new HelpWindow().setVisible(true); 
      } 
     }); 
     menuBar.add(btnHelp); 

     JCheckBoxMenuItem chckbxmntmCPE = new JCheckBoxMenuItem("CPE (Slave)"); 
     buttonGroup.add(chckbxmntmCPE); 
     chckbxmntmCPE.setSelected(true); 
     menuBar.add(chckbxmntmCPE); 

     JCheckBoxMenuItem chckbxmntmCO = new JCheckBoxMenuItem("CO (Master)"); 
     buttonGroup.add(chckbxmntmCO); 
     menuBar.add(chckbxmntmCO); 
     contentPane = new JPanel(); 
     contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 
     setContentPane(contentPane); 
     contentPane.setLayout(null); 

     txtInfo = new JTextField(); 
     txtInfo.setBounds(0, 0, 434, 25); 
     txtInfo.setFont(new Font("Tahoma", Font.BOLD, 11)); 
     txtInfo.setEditable(false); 
     txtInfo.setText("Press SET to start process"); 
     contentPane.add(txtInfo); 
     txtInfo.setColumns(10); 

     textFieldwriteip = new JTextField(); 
     textFieldwriteip.setBounds(0, 25, 284, 58); 
     textFieldwriteip.setFont(new Font("Tahoma", Font.PLAIN, 30)); 

     contentPane.add(textFieldwriteip); 
     textFieldwriteip.setColumns(10); 

     btnSet = new JButton("SET"); 
     btnSet.setBounds(284, 25, 75, 58); 
     btnSet.setFont(new Font("Lucida Console", Font.BOLD, 11)); 
     btnSet.addActionListener(new ActionListener() { 
      public void actionPerformed(ActionEvent arg0) { 

       boolean ok=false; 


       if (!textFieldwriteip.getText().isEmpty()){ 
        if (chckbxmntmCO.isSelected()){ 
       ok= connect ("192.168.0.254"); 
        } else { if (chckbxmntmCPE.isSelected()) { 
         ok= connect3 ("192.168.0.254");} 
        } 
       if(ok) JOptionPane.showMessageDialog(null, "Configuration Set"); 
       } else { 
        JOptionPane.showMessageDialog(null, "Write the wanted IP-adress for your modem");} 
      } 
     }); 
     contentPane.add(btnSet); 

     textProgress = new JTextField(); 
     textProgress.setBounds(0, 84, 434, 27); 
     textProgress.setText("-- Not Connected --"); 
     textProgress.setEditable(false); 
     contentPane.add(textProgress); 
     textProgress.setColumns(10); 

     JButton buttonApply = new JButton("APPLY"); 
     buttonApply.addActionListener(new ActionListener() { 
      public void actionPerformed(ActionEvent e) { 

       boolean ok=false; 

       if (!textFieldwriteip.getText().isEmpty()){ 
       ok= connect2 (textFieldwriteip.getText()); 
       if(ok) JOptionPane.showMessageDialog(null, "Configuration Saved"); 
       if(ok) txtInfo.setText("Press APPLY to save configuration"); 
       } else { 
        JOptionPane.showMessageDialog(null, "Write the wanted IP-adress for your modem");} 
      } 
     }); 
     buttonApply.setFont(new Font("Lucida Console", Font.BOLD, 11)); 
     buttonApply.setBounds(359, 25, 75, 58); 
     contentPane.add(buttonApply); 




    } 



    boolean connect (String ip) 
    { 
     Socket sock = null; 
     PrintWriter pw = null; 


     try 
     { 
     textProgress.setText("Connecting to 192.168.0.254");   
     sock = new Socket(ip, 23); 

     pw = new PrintWriter(sock.getOutputStream()); 

     Thread.sleep(500); 

     textProgress.setText("Sending username"); 
     pw.println("admin"); 

     Thread.sleep(500); 

     textProgress.setText("Sending password"); 
     pw.println("admin"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 1/15"); 
     pw.println("port s1 set 4WireEnable false"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 2/15"); 
     pw.println("port s1 set 4WMode CO"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 3/15"); 
     pw.println("port s1 set 4WType Annex_B"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 4/15"); 
     pw.println("port s1 set 4WautoStart true"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 5/15"); 
     pw.println("port s1 set 4WConnected true"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 6/15"); 
     pw.println("port s1 set BitRateMod Fixed"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 7/15"); 
     pw.println("port s1 set FixedBitRate 2056kbps"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 8/15"); 
     pw.println("port s1 set Mode CO"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 9/15"); 
     pw.println("port s1 set FramerType Leve12"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 10/15"); 
     pw.println("port s1 set Whip Inactive"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 11/15"); 
     pw.println("port s1 set ActivateLine true"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 12/15"); 
     pw.println("port s1 set 4WActivateLine true"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 13/15"); 
     pw.println("rfc1483 set transport wanlink vci 32"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 14/15"); 
     pw.println("rfc1483 set transport wanlink vpi 0"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 15/15"); 
     pw.println("ip set interface iplan ipaddress " + textFieldwriteip.getText()); 

     pw.close(); 

     sock.close(); 

     Thread.sleep(1000); 


     } catch (IOException | InterruptedException e) 
     { 
      e.printStackTrace(); 
      JOptionPane.showMessageDialog(this, "NO CONNECTION"); 
      return false; 
      } 
     return true; 
    } 

    boolean connect2 (String ip) { 


     Socket sock = null; 
     PrintWriter pw = null; 


     try 
     { 
     textProgress.setText("Connecting " + textFieldwriteip.getText()); 


     sock = new Socket(ip, 23); 

     pw = new PrintWriter(sock.getOutputStream()); 

     Thread.sleep(500); 

     textProgress.setText("Sending username"); 
     pw.println("admin"); 

     Thread.sleep(500); 

     textProgress.setText("Sending password"); 
     pw.println("admin"); 

     Thread.sleep(500); 

     textProgress.setText("Saving System Config"); 
     pw.println("system config save"); 

     pw.close(); 

     sock.close(); 

     Thread.sleep(1000); 


     } catch (IOException | InterruptedException e) 
     { 
      e.printStackTrace(); 
      JOptionPane.showMessageDialog(this, "Could not save config to modem"); 
      return false; 
      } 
    return true; 
     } 

    boolean connect3 (String ip) 
    { 
     Socket sock = null; 
     PrintWriter pw = null; 


     try 
     { 
     textProgress.setText("Connecting to 192.168.0.254");   
     sock = new Socket(ip, 23); 

     pw = new PrintWriter(sock.getOutputStream()); 

     Thread.sleep(500); 

     textProgress.setText("Sending username"); 
     pw.println("admin"); 

     Thread.sleep(500); 

     textProgress.setText("Sending password"); 
     pw.println("admin"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 1/15"); 
     pw.println("port s1 set 4WireEnable false"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 2/15"); 
     pw.println("port s1 set 4WMode CPE"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 3/15"); 
     pw.println("port s1 set 4WType Annex_B"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 4/15"); 
     pw.println("port s1 set 4WautoStart true"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 5/15"); 
     pw.println("port s1 set 4WConnected true"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 6/15"); 
     pw.println("port s1 set BitRateMod Fixed"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 7/15"); 
     pw.println("port s1 set FixedBitRate 2056kbps"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 8/15"); 
     pw.println("port s1 set Mode CPE"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 9/15"); 
     pw.println("port s1 set FramerType Leve12"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 10/15"); 
     pw.println("port s1 set Whip Inactive"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 11/15"); 
     pw.println("port s1 set ActivateLine true"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 12/15"); 
     pw.println("port s1 set 4WActivateLine true"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 13/15"); 
     pw.println("rfc1483 set transport wanlink vci 32"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 14/15"); 
     pw.println("rfc1483 set transport wanlink vpi 0"); 

     Thread.sleep(500); 

     textProgress.setText("Sending Configuration 15/15"); 
     pw.println("ip set interface iplan ipaddress " + textFieldwriteip.getText()); 

     pw.close(); 

     sock.close(); 

     Thread.sleep(1000); 


     } catch (IOException | InterruptedException e) 
     { 
      e.printStackTrace(); 
      JOptionPane.showMessageDialog(this, "NO CONNECTION"); 
      return false; 
      } 
     return true; 
    } 

} 

和幫助窗口

import java.awt.BorderLayout; 
import java.awt.EventQueue; 

import javax.swing.JFrame; 
import javax.swing.JPanel; 
import javax.swing.border.EmptyBorder; 
import javax.swing.JTextPane; 
import javax.swing.JButton; 
import java.awt.event.ActionListener; 
import java.awt.event.ActionEvent; 
import java.awt.Font; 

public class HelpWindow extends JFrame { 

    private JPanel contentPane; 

    /** 
    * Launch the application. 
    */ 
    public static void main(String[] args) { 
     EventQueue.invokeLater(new Runnable() { 
      public void run() { 
       try { 
        HelpWindow frame = new HelpWindow(); 
        frame.setVisible(true); 
       } catch (Exception e) { 
        e.printStackTrace(); 
       } 
      } 
     }); 
    } 

    /** 
    * Create the frame. 
    */ 
    public HelpWindow() { 
     setResizable(false); 
     setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 
     setBounds(100, 100, 450, 300); 
     contentPane = new JPanel(); 
     contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 
     setContentPane(contentPane); 
     contentPane.setLayout(null); 
     setLocation(520 + 20 , 80 + 20); 

     JTextPane txtpnAsdasd = new JTextPane(); 
     txtpnAsdasd.setFont(new Font("Calibri", Font.PLAIN, 12)); 
     txtpnAsdasd.setEditable(false); 
     txtpnAsdasd.setText("Help\r\n- The configuration will be set through factory settings IP-Adress of the modem (\"192.168.0.254\") so remember to change your pc to the same network with the modem\r\n- Choose the wanted configuration to set for your modem (CO/CPE)\r\n- Write the wanted IP-Adress for your modem\r\n- Press \"SET\" -----> Wait for \"Configuration set\"\r\n- If using different IP-Adress for your modem than your current network is. Remember to change your computers IP-Adress before pressing \"APPLY\"\r\n-Press \"APPLY\" ----> Wait for \"Configuration saved\"\r\n\r\nCongrats your modem is ready to be used    /// Created by: \u00D6s M J ///"); 
     txtpnAsdasd.setBounds(10, 11, 414, 198); 
     contentPane.add(txtpnAsdasd); 

     JButton btnNewButton = new JButton("RETURN TO THE CONFIG WINDOW"); 
     btnNewButton.addActionListener(new ActionListener() { 
      public void actionPerformed(ActionEvent e) { 
       setVisible(false); 

      } 
     }); 
     btnNewButton.setBounds(10, 209, 414, 51); 
     contentPane.add(btnNewButton); 
    } 
} 

感謝您讀這篇文章,希望有人爲能給米e關於如何構建TI外觀和如何編碼的反饋:)

Br。 Shmooss