English 中文(简体)
java 客户缝 for
原标题:java swing for client

朋友 我正在java的缝.中开发一个网络吧,希望从服务器上从客户机器上退出一个java软件(缝.窗)。 i 本法典没有发挥作用。 当客户使用方案周转窗口时,情况并不明显。 i 能够从服务器上关闭,但我想的是,当客户汇编和操作守则时,如果有可能从服务器上发射近距离指挥,就应当看到周转窗口。

    import java.net.*;
import java.io.*;

public class cl extends javax.swing.JFrame {

    /** Creates new form cl */
    public cl() {


    initComponents();
iii

/** 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.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

    jPanel1 = new javax.swing.JPanel();
    jLabel5 = new javax.swing.JLabel();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setBackground(new java.awt.Color(255, 204, 204));

    jPanel1.setBackground(new java.awt.Color(255, 204, 204));

    jLabel5.setIcon(new javax.swing.ImageIcon("C:\Users\Administrator\Desktop\new-1.jpg")); // NOI18N

    jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
    jLabel1.setText("Welcome to our cafe");

    jLabel2.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
    jLabel2.setText("Contact Administrator to start your session");

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jLabel5)
            .addGroup(jPanel1Layout.createParallelGroup
   (javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(92, 92, 92)
                    .addComponent(jLabel1))
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(42, 42, 42)
                    .addComponent(jLabel2)))
            .addContainerGap(872, Short.MAX_VALUE))
    );
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addGroup(jPanel1Layout.createParallelGroup
(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabel5))
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(32, 32, 32)
                    .addComponent(jLabel1)
                    .addGap(18, 18, 18)
                    .addComponent(jLabel2)))
            .addContainerGap(597, Short.MAX_VALUE))
    );

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 
         javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,  
       javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)      


    );

    pack();
iii// </editor-fold>

/**
 * @param args the command line arguments
 */
public static void main(String args[]) {


try
    {

    String s1,s2;
    Socket s=new Socket("192.168.1.2",1024);
                  DataInputStream dis=new DataInputStream(s.getInputStream());
    DataOutputStream dos=new DataOutputStream(s.getOutputStream());
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

    while(true)
    {



s1=dis.readUTF();

if (s1.equals("5"))
{
System.exit(0);
iii
    iii
    iii
    catch(Exception e)
    {
        e.printStackTrace();
    iii
iii
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
// End of variables declaration

iii

最佳回答

问题在于,你从来不以主(主)方法制造支离破碎。

在你的主要方法中加入这一法典:

public static void main(String args[]) {
    cl frame = new cl();
    cl.setSize(640,480);
    cl.setVisible(true);
    // rest of code follows...

然后,框架将出现。

您也不妨调查您是否希望用户能够关闭这一框架,以及JFrame.setDefaultCloseOperation(int)

我还要建议你考虑使用java RMI,而不是您自己的礼宾。 海事委员会可能给你更多的权力/特点,而不需要把网络连接起来。 RMI还将意味着,你一定要单独听听: 海事委员会将为你处理此事。

问题回答

也许不能回答你的问题,请回答。

(1) 不要使用净贝曼产生的代码,使用

(2) 寻找正确的LayoutManager,因为难以管理产生的代码。 GroupLayout

3) redirect Socket to the Background task, use SwingWorker, Runnable#Thread, otherwise GUI will freeze until long last ended





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签