Help on coding my Program

Asked By 7060 points N/A Posted on -
qa-featured

import java.awt.*; import javax.swing.* ; import java.awt.event.*; import java.net.*; import java.io.*; public class Client extends JApplet implements ActionListener, ItemListener { Container contentPane; JButton butcipher,butquit,butsend; JLabel lbl1,lbl2,lbl3,lbl4,lbl5,lbl6,lbl7; JRadioButton chksub,chktrans; ButtonGroup bgroup; JTextArea txtplanetxt,txtciphertxt; JTextField txtsubkey,txttranskey,txtipadd; JScrollPane jscrollpane1,jscrollpane2; String cryptmeth="Substitution"; String subciphertxt,transciphertxt,ptxt,subkeytxt,transkeytxt; int subkey=0; Socket sc; PrintStream out=null; BufferedReader in=null; public void init() { this.setSize(790,600); contentPane=getContentPane(); //obtain content pane contentPane.setBackground(new Color(135,162,252)); contentPane.setLayout(null); lbl6=new JLabel("Cryptography"); lbl6.setBounds(325,15,200,30); lbl6.setFont(new Font("Monotype Corsiva",Font.BOLD,30)); lbl6.setForeground(new Color(255,255,255)); contentPane.add(lbl6); lbl7=new JLabel("(Client)"); lbl7.setBounds(500,15,200,30); lbl7.setFont(new Font("",Font.BOLD,14)); contentPane.add(lbl7); lbl1=new JLabel("Enter Plane Text – "); lbl1.setBounds(75,40,200,30); lbl1.setFont(new Font("",Font.BOLD,14)); contentPane.add(lbl1); txtplanetxt=new JTextArea(5,25); JScrollPane jscrollpane1=new JScrollPane(txtplanetxt, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); jscrollpane1.setBounds(75,75,650,100); txtplanetxt.setFont(new Font("",Font.BOLD,14)); contentPane.add(jscrollpane1); chksub=new JRadioButton("Substitution Method", true); chksub.setBounds(170,190,200,30); chksub.setFont(new Font("",Font.BOLD,14)); contentPane.add(chksub); chksub.addItemListener(this); chktrans=new JRadioButton("Transposition Method"); chktrans.setBounds(480,190,200,30); chktrans.setFont(new Font("",Font.BOLD,14)); contentPane.add(chktrans); chktrans.addItemListener(this); bgroup=new ButtonGroup(); bgroup.add(chksub); bgroup.add(chktrans); lbl2=new JLabel("Enter Key – "); lbl2.setBounds(75,230,100,20); lbl2.setFont(new Font("",Font.BOLD,14)); contentPane.add(lbl2); txtsubkey=new JTextField(15); txtsubkey.setBounds(170,230,200,30); txtsubkey.setFont(new Font("",Font.BOLD,14)); contentPane.add(txtsubkey); lbl3=new JLabel("Enter Key – "); lbl3.setBounds(390,230,100,20); lbl3.setFont(new Font("",Font.BOLD,14)); contentPane.add(lbl3); txttranskey=new JTextField(15); txttranskey.setBounds(480,230,200,30); txttranskey.setFont(new Font("",Font.BOLD,14)); contentPane.add(txttranskey); lbl4=new JLabel("Cipher Text – "); lbl4.setBounds(75,270,200,30); lbl4.setFont(new Font("",Font.BOLD,14)); contentPane.add(lbl4); txtciphertxt=new JTextArea(5,25); txtciphertxt.enable(false); JScrollPane jscrollpane2=new JScrollPane(txtciphertxt, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); jscrollpane2.setBounds(75,300,650,100); txtciphertxt.setFont(new Font("",Font.BOLD,14)); contentPane.add(jscrollpane2); lbl5=new JLabel("Enter Server – "); lbl5.setBounds(230,420,200,20); lbl5.setFont(new Font("",Font.BOLD,14)); contentPane.add(lbl5); txtipadd=new JTextField(15); txtipadd.setBounds(390,420,150,30); txtipadd.setFont(new Font("",Font.BOLD,14)); contentPane.add(txtipadd); butcipher=new JButton("Cipher"); butcipher.setBounds(200,480,90,30); butcipher.addActionListener(this); contentPane.add(butcipher); butsend=new JButton("Send") ; butsend.setBounds(350,480,90,30); butsend.addActionListener(this); contentPane.add(butsend); butquit=new JButton("Quit") ; butquit.setBounds(500,480,90,30); butquit.addActionListener(this); contentPane.add(butquit); txtplanetxt.setFocusable(true); try { sc=new Socket("localhost",4444); System.out.println("Connected to server"); out = new PrintStream(sc.getOutputStream()); in = new BufferedReader(new InputStreamReader(sc.getInputStream())); } catch(Exception e) { System.out.print("Error :- " e); } } public void itemStateChanged(ItemEvent ie) { if(ie.getItemSelectable()==chksub) cryptmeth="Substitution"; if(ie.getItemSelectable()==chktrans) cryptmeth="Transposition"; } public void actionPerformed(ActionEvent ae) { if(ae.getActionCommand()=="Cipher") { txtciphertxt.setText(""); ptxt=new String(txtplanetxt.getText()); if(ptxt.length()<1) { JOptionPane.showMessageDialog((Component)null, "Please Enter Plain Text", "Input Message", JOptionPane.WARNING_MESSAGE); return ; } if(cryptmeth.equals("Substitution")) { subkeytxt=txtsubkey.getText(); try { subkey=Integer.parseInt(subkeytxt); if(subkey>=0

SHARE
Best Answer by Lesten Pasio
Answered By 563040 points N/A #80376

Help on coding my Program

qa-featured

These are codes that I did not understand what are you implying. First of, I don't see the header of all the standard programming.

In Visual Basic, Fox Pro and or HTML codes must have header to begin the program.

In that area is where I pin-point the issue. I'm not sure what you are trying to do with this, what software program your working on but you have the knowledge of a junior programmer.

Do practice more and study the more on codes to create software, then one day you'll be the best programmer out there.

Best Answer
Best Answer
Answered By 0 points N/A #80377

Help on coding my Program

qa-featured

Hi there  , 

The above are some extreme codes which I think no one can read it. For the header files it clear that it is a JAVA GUI program. 

You haven't specified absolutely nothing . Which error you received ?? What is the problem you faced which you need a solution from us etc. Etc.  

Repost with necessary details regarding this and please format it into a readable format. This is important , Please try yourself to read what you have posted . Its very hard and consumes a gigantic amount of time.

SO to be clear , copy paste this into a wordpad or MS word , format it with necessary lines and spacing and repost it with including the problems you are facing with this.

Hope that helps you to solve.

Login/Register to Answer

Related Questions