Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help creating this java GUI like the ones i provided in the examples., I provided my code to help. Might have to space

I need help creating this java GUI like the ones i provided in the examples., I provided my code to help. Might have to space it out, it was too long to put in line by line. Thank youimage text in transcribedimage text in transcribedimage text in transcribed

import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener;import javax.swing.GroupLayout;import javax.swing.JButton;import javax.swing.JLabel;import javax.swing.JScrollPane;import javax.swing.JTextArea;import javax.swing.JTextField;import javax.swing.LayoutStyle;import javax.swing.WindowConstants;public class ServerGUI extends javax.swing.JFrame { private JButton btnClose; private JButton btnListen; private JButton btnQuit; private JButton btnStop;private JScrollPane jScrollPane1;private JLabel lblCliendID;private JLabel lblServerData; private JLabel lblServerURL; private JLabel lblStatus; private JLabel lblStatusConnectDisconnect; private JTextArea txtAreaClientData1; private JTextField txtClientID; private JTextField txtClientID1; public ServerGUI(String title) { this.setTitle("Server"); //set the title lblStatusConnectDisconnect = new JLabel(); lblCliendID = new JLabel(); btnQuit = new JButton();btnClose = new JButton(); btnStop = new JButton();lblStatus = new JLabel(); lblServerURL = new JLabel(); lblServerData = new JLabel(); txtClientID = new JTextField();txtClientID1 = new JTextField(); jScrollPane1 = new JScrollPane(); txtAreaClientData1 = new JTextArea();btnListen = new JButton(); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); lblStatusConnectDisconnect.setBackground(Color.RED); lblStatusConnectDisconnect.setText("Not Connected"); lblCliendID.setText("Port #"); btnQuit.setText("Quit"); btnQuit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { btnQuitActionPerformed(evt);}}); btnClose.setText("Close"); btnClose.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { btnCloseActionPerformed(evt);}}); btnStop.setText("Stop"); btnStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { btnStopActionPerformed(evt);}});btnListen.setText("Listen"); btnListen.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnListenActionPerformed(evt);}}); lblStatus.setText("Status"); lblServerURL.setText("Time Out"); lblServerData.setText("Server Log Below"); txtAreaClientData1.setColumns(20); txtAreaClientData1.setRows(5); jScrollPane1.setViewportView(txtAreaClientData1); GroupLayout layout = new GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout .createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout .createSequentialGroup().addGap(188, 188, 188) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout .createParallelGroup(GroupLayout.Alignment.TRAILING, false) .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addComponent(lblServerURL, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(txtClientID1, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE) .addGap(0, 90, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(lblCliendID, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE) .addGap(10, 10, 10).addComponent(txtClientID, GroupLayout.PREFERRED_SIZE, 162, GroupLayout.PREFERRED_SIZE))) .addComponent(lblServerData, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup().addGap(169, 169, 169).addComponent(lblStatus) .addGap(11, 11, 11) .addComponent(lblStatusConnectDisconnect, GroupLayout.PREFERRED_SIZE, 185, GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup().addGap(17, 17, 17).addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 459, GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup().addGap(45, 45, 45).addComponent(btnListen) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnClose) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnStop, GroupLayout.PREFERRED_SIZE, 97, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnQuit, GroupLayout.PREFERRED_SIZE, 97, GroupLayout.PREFERRED_SIZE))) .addContainerGap(24, Short.MAX_VALUE))); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(lblStatus).addComponent(lblStatusConnectDisconnect)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addGap(10, 10, 10).addComponent(lblCliendID)) .addComponent(txtClientID, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(lblServerURL) .addComponent(txtClientID1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(66, 66, 66).addComponent(lblServerData) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 128, GroupLayout.PREFERRED_SIZE) .addGap(2, 2, 2) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(btnStop).addComponent(btnClose).addComponent(btnQuit) .addComponent(btnListen)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));pack(); setLocationRelativeTo(null);} private void btnQuitActionPerformed(ActionEvent evt) { lblStatusConnectDisconnect.setText("Quit Button pressed"); //System.exit(0); //exit application } private void btnCloseActionPerformed(ActionEvent evt) { lblStatusConnectDisconnect.setText("Close Button Pressed"); } private void btnStopActionPerformed(ActionEvent evt) { lblStatusConnectDisconnect.setText("Stop Button Pressed");} private void btnListenActionPerformed(ActionEvent evt) { lblStatusConnectDisconnect.setText("Listen Button Pressed"); } public static void main(String args[]) { ServerGUI sg = new ServerGUI("Server"); sg.setVisible(true);}}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions

Question

Explain the need for a new field of financial therapy.

Answered: 1 week ago

Question

=+1. What is a stakeholder? Define the term in your own words.

Answered: 1 week ago