Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6796541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:30:04+00:00 2026-05-26T18:30:04+00:00

server.java ok, so the problem is: When I hit the start button, the gui

  • 0

server.java

ok, so the problem is: When I hit the start button, the gui “froze”, but the server is working, I have an output in console. I think I should use threads for it, but I don’t know how to implement it = /

void Runer() throws Exception
{
    ServerSocket welcomeSocket = new ServerSocket(6789);
    System.out.println("welcome into server");
    while(true)
    {

        Socket connectionSocket = welcomeSocket.accept();
        if (connectionSocket != null)
        {
            System.out.println(connectionSocket);
            Client client = new Client(connectionSocket);
            client.start();
        }
    }
}

}

class Client extends Thread
{
private Socket connectionSocket;
private String pozX;
private String ans;
private String pozY;
private String capitalizedSentence;
private BufferedReader inFromClient;
private DataOutputStream outToClient;

public Client(Socket c) throws IOException
{
    connectionSocket = c;
}

public void run() 
{
    try
    {    
        inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
        outToClient = new DataOutputStream(connectionSocket.getOutputStream());

        pozX = inFromClient.readLine();
        pozY = inFromClient.readLine();
        System.out.println(pozX);
        System.out.println(pozY);
        capitalizedSentence = pozX.toUpperCase() + '\n';
          BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in));

       outToClient.writeBytes(capitalizedSentence);

    }
    catch(IOException e)
    {
        System.out.println("Errore: " + e);
    }
}

gui.java

JPanel GuiServera(){
    JPanel panel = new JPanel();
    area = new JTextArea();
    area.setColumns(20);
    area.setRows(10);
    area.setText("The log is logging injoy");
    panel.setLayout(null);
    start = new JButton("Start");
    start.addActionListener(list);
    panel.add(start);
    stop = new JButton("Stop");
    stop.addActionListener(list);
    pane = new JButton("Admin Panel");
    panel.add(stop);

    panel.add(pane);
     scrolled = new JScrollPane(area);
     panel.add(scrolled);
    Insets insets = panel.getInsets();
    Dimension size = start.getPreferredSize();
    start.setBounds(40 + insets.left, 20 + insets.top,
    size.width, size.height);

    size = stop.getPreferredSize();
    stop.setBounds(40 + insets.left, 60 + insets.top,
    size.width, size.height);

    size = pane.getPreferredSize();
    pane.setBounds(40 + insets.left, 100 + insets.top,
    size.width, size.height);

    size = scrolled.getPreferredSize();
    scrolled.setBounds(160 + insets.left, 20 + insets.top,
    size.width, size.height);
    return panel;
}
class Nasluchiwacz implements ActionListener{

    @Override
    public void actionPerformed(ActionEvent e) {
        if(e.getSource()==start){
            System.out.println("start");
            area.append("start button\n");
            try {
                inzServer.Runer();
            } catch (Exception ex) {
                Logger.getLogger(Gui.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
        else if (e.getSource()==stop){
            area.setText(area.getText()+"\nstop\n");
        }
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:30:04+00:00Added an answer on May 26, 2026 at 6:30 pm

    You are almost doing it correct.
    Instead of runner extending thread. Make it implement runnable.

    Then in your guiclass. you can either to new Thread(inserver).start();
    Or take a look at Executorservice or Swingworkers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem POSTing data via HTTPS in Java. The server response is
I have a problem with my android application which should connect to java tcp
I have a standalone Java problem running in a linux server. I started the
im coming from unix / server / c++ /java background with no GUI experience
I have created a java server, which takes screenshots, resizes them, and sends them
I have a Java based web-application using Java Server Faces and Facelets. I am
So I'm running a Java server and in one class I have a static
I think this is a pretty simply problem but I do not seem to
Hi I have very ugly problem with: java.net.SocketException: No buffer space available (maximum connections
I'm creating a small server using java.nio , but when trying to stress test

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.