Menu

#5 final interface is complete

open
nobody
None
5
2015-02-14
2008-08-14
No

hi final interface is ready

its code is:

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;

public class JFrameWindow extends JFrame{
JFrameWindow()
{

    setLocation\(300,300\);
    setSize\(600,500\);
    setTitle\("MultiThreadedHTTPServer"\);
    setResizable\(false\);

\}

void addComponents\(\)
\{
    addTopPanel\(\);
    addBottomPanel\(\);
    addHBOX1\(\);
    addHBOX2\(\);
    addHBOX3\(\);
    addHBOX4\(\);
    addHBOX5\(\);
    addHBOX6\(\);
    addInVBOX\(\);
    addCentrePanel\(\);
\}

void makeVisibleTrue\(\)
\{
    setVisible\(true\);
    setDefaultCloseOperation\(JFrame.EXIT\_ON\_CLOSE\);
\}

private void addTopPanel\(\)
\{
topPanel.setBackground\(Color.CYAN\)    ;
topLabel.setFont\(new Font\("Times Roman", Font.BOLD,18 \)\);   
topPanel.add\(topLabel\);   
getContentPane\(\).add\(topPanel,BorderLayout.NORTH\);  
\}
private void addBottomPanel\(\)
\{
serverLabel.setFont\(threadFont\);
logLabel.setFont\(threadFont\);
serverLabel.setForeground\(Color.RED\);
logLabel.setForeground\(Color.RED\);
bottomPanel.setBackground\(Color.CYAN\) ;
Box hbox = Box.createHorizontalBox\(\);
hbox.add\(serverStatusLabel\);
hbox.add\(Box.createHorizontalStrut\(10\)\);
hbox.add\(serverLabel\);
hbox.add\(Box.createHorizontalStrut\(200\)\);
hbox.add\(logFilelabel\);
hbox.add\(Box.createHorizontalStrut\(10\)\);
hbox.add\(logLabel\);
bottomPanel.add\(hbox\);    
getContentPane\(\).add\(bottomPanel,BorderLayout.SOUTH\);   
\}

private void addHBOX1\(\)
\{
    portField.setMaximumSize\(portField.getPreferredSize\(\)\);
    hbox1.add\(portLabel\);
    hbox1.add\(Box.createHorizontalStrut\(72\)\);
    hbox1.add\(portField\);
    portField.setText\("80"\);
    hbox1.add\(Box.createHorizontalStrut\(10\)\);
    hbox1.add\(egportLabel\);   
    hbox1.add\(Box.createVerticalStrut\(50\)\);
\}
private void addHBOX2\(\)
\{
    workerThreadField.setMaximumSize\(workerThreadField.getPreferredSize\(\)\);
    hbox2.add\(workerThreadLabel\);
    hbox2.add\(Box.createHorizontalStrut\(24\)\);
    hbox2.add\(workerThreadField\);
    workerThreadField.setText\("25"\);
    hbox2.add\(Box.createHorizontalStrut\(10\)\);
    hbox2.add\(egworkerThreadLabel\);   
    hbox2.add\(Box.createVerticalStrut\(50\)\);
\}
private void addHBOX3\(\)
\{
    timeOutField.setMaximumSize\(timeOutField.getPreferredSize\(\)\);
    hbox3.add\(timeOutForclients\);
    hbox3.add\(Box.createHorizontalStrut\(4\)\);
    hbox3.add\(timeOutField\);
    timeOutField.setText\("4000"\);
    hbox3.add\(Box.createHorizontalStrut\(10\)\);
    hbox3.add\(egtimeOUtLabel\);    
    hbox3.add\(Box.createVerticalStrut\(50\)\);
\}
private void addHBOX4\(\)
\{
    rootDirectoryField.setMaximumSize\(rootDirectoryField.getPreferredSize\(\)\);
    hbox4.add\(rootDirectoryLabel\);
    hbox4.add\(Box.createHorizontalStrut\(20\)\);
    hbox4.add\(rootDirectoryField\);
    hbox4.add\(Box.createHorizontalStrut\(10\)\);
    hbox4.add\(rootDirectoryBrowseButton\);
    hbox4.add\(Box.createVerticalStrut\(50\)\);
\}

private void addHBOX5\(\)
\{
    threadLabel.setForeground\(Color.RED\);
    threadLabel.setFont\(threadFont\);
    threadCounter.setFont\(threadFont\);
    threadCounter.setForeground\(Color.RED\);
    hbox5.add\(threadLabel\);
    hbox5.add\(Box.createHorizontalStrut\(80\)\);
    hbox5.add\(threadCounter\);
    hbox5.add\(Box.createVerticalStrut\(100\)\);
\}
private void addHBOX6\(\)
\{

    hbox6.add\(startServer\);
    hbox6.add\(Box.createHorizontalStrut\(230\)\);
    hbox6.add\(stopServer\);
    hbox6.add\(Box.createVerticalStrut\(50\)\);

\}
private void addInVBOX\(\)
\{
    vbox.add\(hbox1\);
    vbox.add\(hbox2\);
    vbox.add\(hbox3\);
    vbox.add\(hbox4\);
    vbox.add\(hbox5\);
    vbox.add\(hbox6\);
\}
private void addCentrePanel\(\)
\{
    centerPanel.add\(vbox\);
    getContentPane\(\).add\(centerPanel,BorderLayout.CENTER\);

\}

   private JPanel bottomPanel = new JPanel\(\);
   private JPanel topPanel = new JPanel\(\);    
   private JPanel centerPanel= new JPanel\(\);
   private JLabel topLabel = new JLabel\("MultiThreaded  HTTP  Server"\);
   private JLabel portLabel         = new JLabel\("Port  Number :"\);
   private JTextField portField = new JTextField\(15\);
   private JLabel egportLabel= new JLabel\("\(e.g. 80\)"\);
   private JLabel workerThreadLabel = new JLabel\("Total Worker Threads :"\);
   private Font threadFont = new Font\("Times Roman",Font.ITALIC,12\);
   private JTextField workerThreadField= new JTextField\(15\);
   private JLabel egworkerThreadLabel = new JLabel\("\(e.g. 25 \(in thread pool\) \)"\);
   private JLabel timeOutForclients = new JLabel\("Timeout for Clients\(in ms\):"\);
   private JTextField timeOutField= new JTextField\(15\);
   private JLabel egtimeOUtLabel=new JLabel\("\(e.g. 4000 \(it is in milliseconds\) \)"\);
   private JLabel rootDirectoryLabel= new JLabel\("Root Serving Directory :"\);
   private JTextField rootDirectoryField= new JTextField\(15\);
   private JButton rootDirectoryBrowseButton= new JButton\("Browse"\);
   private JLabel threadLabel = new JLabel\("Current worker thread is : "\);
   private JLabel threadCounter= new JLabel\("Server is stopped."\);
   private JButton startServer= new JButton\("Start Server"\);
   private JButton stopServer = new JButton\("Stop Server"\);
   private JLabel serverStatusLabel= new JLabel\("Server Status :"\);
   private JLabel serverLabel = new JLabel\("Server is stopped "\);
   private JLabel logFilelabel= new JLabel\("Log Information : "\);
   private JLabel logLabel= new JLabel\("logs "\);
   private Box hbox1= Box.createHorizontalBox\(\);
   private Box hbox2= Box.createHorizontalBox\(\);
   private Box hbox3= Box.createHorizontalBox\(\);
   private Box hbox4= Box.createHorizontalBox\(\);
   private Box hbox5= Box.createHorizontalBox\(\);
   private Box hbox6= Box.createHorizontalBox\(\);
   private Box vbox = Box.createVerticalBox\(\);

}

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.