Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-25-2008, 10:15 AM
Floetic's Avatar
Member
 
Join Date: Feb 2008
Location: Belfast, Northern Ireland, UK
Posts: 7
Floetic is on a distinguished road
Send a message via MSN to Floetic
Problem With RSA Interface
Program complies and the interface shows up but there is no output
after pressing run button. How come this is happening?

Thanks.

Code:
package newpackage4; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*; import java.io.*; public class NewClass5 extends JFrame{ public NewClass5() { initiateComponents(); } private JLabel TitleLabel; private JPanel innerPanel; private JLabel StringInputLabel; private JTextField InputStringTextField; private JButton RunButton; private JButton SaveButton; private JButton ResetButton; private JButton ExitButton; private JTextArea OutputWindow; private char[] plainText; private void initiateComponents() { getContentPane().setLayout(null); setTitle("Simplified Simulation: RSA Security Algorithm"); setSize(new Dimension(1025, 703)); setLocation(0,0); setResizable(false); setDefaultCloseOperation(EXIT_ON_CLOSE); getContentPane().setBackground(new Color(100,200,200)); getContentPane().add(getInnerPanel()); getContentPane().add(getTitleLabel()); populateInnerPanel(); } private JLabel getTitleLabel() { TitleLabel = new JLabel(); TitleLabel.setFont(new Font("Arial",1,44)); TitleLabel.setText(" RSA Algorithm"); TitleLabel.setBackground(new Color(255,255,255)); TitleLabel.setBorder(new EtchedBorder()); TitleLabel.setBounds(300,40,500,60); return TitleLabel; } private JPanel getInnerPanel() { innerPanel = new JPanel(); innerPanel.setLayout(null); innerPanel.setBackground(new Color(190,255,255)); innerPanel.setBorder(new TitledBorder( new TitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Times New Roman", 1, 12)))); innerPanel.setBounds(40,160,930,460); return innerPanel; } private void populateInnerPanel() { StringInputLabel = new JLabel(); StringInputLabel.setFont(new Font("Bookman Old Style",0,13)); StringInputLabel.setText("Enter in a word:"); innerPanel.add(StringInputLabel); StringInputLabel.setBounds(65,20,110,20); InputStringTextField = new JTextField(); InputStringTextField.setText(" "); innerPanel.add(InputStringTextField); InputStringTextField.setBounds(180,20,220,20); RunButton = new JButton(); RunButton.setFont(new Font("Bookman Old Style",1,13)); RunButton.setText("Run"); innerPanel.add(RunButton); RunButton.setBounds(65,420,70,20); SaveButton = new JButton(); SaveButton.setFont(new Font("Bookman Old Style",1,13)); SaveButton.setText("Save"); innerPanel.add(SaveButton); SaveButton.setBounds(305,420,70,20); ResetButton = new JButton(); ResetButton.setFont(new Font("Bookman Old Style",1,13)); ResetButton.setText("Reset"); innerPanel.add(ResetButton); ResetButton.setBounds(555,420,80,20); ExitButton = new JButton(); ExitButton.setFont(new Font("Bookman Old Style",1,13)); ExitButton.setText("Exit"); innerPanel.add(ExitButton); ExitButton.setBounds(794,420,70,20); OutputWindow = new JTextArea(); Font equalSpacedFont = new Font("Monospaced",Font.PLAIN,14); OutputWindow.setFont(equalSpacedFont); OutputWindow.setEditable(false); JScrollPane scrollPane = new JScrollPane(OutputWindow); scrollPane.setBounds(65,70,800,330); innerPanel.add(scrollPane); } public void actionPerformed(ActionEvent event) { String arg = event.getActionCommand(); if(arg.equals("Run")) { try { int plainTextLength = plainText.length; String inputString = InputStringTextField.getText(); int inputStringLength = inputString.length(); char[] result = new char[inputStringLength]; //char currentSource = inputString.charAt(i); } catch (Exception e) { } int [] cipherText = new int[plainText.length]; System.out.print("\nPlaintext:\t "); for(int i = 0; i < plainText.length; i++) { int tmp = (int)plainText[i]-64; cipherText[i] = (tmp*tmp*tmp)%33; System.out.print("\t"+plainText[i]); } System.out.print("\nCiphertext:\t"); for(int i = 0; i < cipherText.length; i++) { System.out.print("\t"+cipherText[i]); } } } public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JFrame.setDefaultLookAndFeelDecorated(true); NewClass5 nc5 = new NewClass5(); nc5.setVisible(true); } }); }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-25-2008, 12:06 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,592
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
I have not tested your code, but seems to me you don't set the action command on your buttons.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 03-25-2008, 12:31 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,592
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Ok here is the corrected code. I have done the exit part of the application, see what I have done changes in ExitButton.

Code:
package newpackage4; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*; import java.io.*; public class NewClass5 extends JFrame implements ActionListener{ public NewClass5() { initiateComponents(); } private JLabel TitleLabel; private JPanel innerPanel; private JLabel StringInputLabel; private JTextField InputStringTextField; private JButton RunButton; private JButton SaveButton; private JButton ResetButton; private JButton ExitButton; private JTextArea OutputWindow; private char[] plainText; private void initiateComponents() { getContentPane().setLayout(null); setTitle("Simplified Simulation: RSA Security Algorithm"); setSize(new Dimension(1025, 703)); setLocation(0,0); setResizable(false); setDefaultCloseOperation(EXIT_ON_CLOSE); getContentPane().setBackground(new Color(100,200,200)); getContentPane().add(getInnerPanel()); getContentPane().add(getTitleLabel()); populateInnerPanel(); } private JLabel getTitleLabel() { TitleLabel = new JLabel(); TitleLabel.setFont(new Font("Arial",1,44)); TitleLabel.setText(" RSA Algorithm"); TitleLabel.setBackground(new Color(255,255,255)); TitleLabel.setBorder(new EtchedBorder()); TitleLabel.setBounds(300,40,500,60); return TitleLabel; } private JPanel getInnerPanel() { innerPanel = new JPanel(); innerPanel.setLayout(null); innerPanel.setBackground(new Color(190,255,255)); innerPanel.setBorder(new TitledBorder( new TitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Times New Roman", 1, 12)))); innerPanel.setBounds(40,160,930,460); return innerPanel; } private void populateInnerPanel() { StringInputLabel = new JLabel(); StringInputLabel.setFont(new Font("Bookman Old Style",0,13)); StringInputLabel.setText("Enter in a word:"); innerPanel.add(StringInputLabel); StringInputLabel.setBounds(65,20,110,20); InputStringTextField = new JTextField(); InputStringTextField.setText(" "); innerPanel.add(InputStringTextField); InputStringTextField.setBounds(180,20,220,20); RunButton = new JButton(); RunButton.setFont(new Font("Bookman Old Style",1,13)); RunButton.setText("Run"); innerPanel.add(RunButton); RunButton.setBounds(65,420,70,20); SaveButton = new JButton(); SaveButton.setFont(new Font("Bookman Old Style",1,13)); SaveButton.setText("Save"); innerPanel.add(SaveButton); SaveButton.setBounds(305,420,70,20); ResetButton = new JButton(); ResetButton.setFont(new Font("Bookman Old Style",1,13)); ResetButton.setText("Reset"); innerPanel.add(ResetButton); ResetButton.setBounds(555,420,80,20); ExitButton = new JButton(); ExitButton.setFont(new Font("Bookman Old Style",1,13)); ExitButton.setText("Exit"); innerPanel.add(ExitButton); ExitButton.setBounds(794,420,70,20); ExitButton.addActionListener(this); // Newly added code segment OutputWindow = new JTextArea(); Font equalSpacedFont = new Font("Monospaced",Font.PLAIN,14); OutputWindow.setFont(equalSpacedFont); OutputWindow.setEditable(false); JScrollPane scrollPane = new JScrollPane(OutputWindow); scrollPane.setBounds(65,70,800,330); innerPanel.add(scrollPane); } public void actionPerformed(ActionEvent event) { String arg = event.getActionCommand(); if(arg.equals("Run")) { try { int plainTextLength = plainText.length; String inputString = InputStringTextField.getText(); int inputStringLength = inputString.length(); char[] result = new char[inputStringLength]; //char currentSource = inputString.charAt(i); } catch (Exception e) { } int [] cipherText = new int[plainText.length]; System.out.print("\nPlaintext:\t "); for(int i = 0; i < plainText.length; i++) { int tmp = (int)plainText[i]-64; cipherText[i] = (tmp*tmp*tmp)%33; System.out.print("\t"+plainText[i]); } System.out.print("\nCiphertext:\t"); for(int i = 0; i < cipherText.length; i++) { System.out.print("\t"+cipherText[i]); } } if("Exit".equals(event.getActionCommand())){ // Newly added code segment System.exit(0); } } public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JFrame.setDefaultLookAndFeelDecorated(true); NewClass5 nc5 = new NewClass5(); nc5.setVisible(true); } }); } }
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ActionListener interface tsantana New To Java 2 03-31-2008 12:24 AM
An interface extending an interface(II) JavaForums Java Blogs 0 03-12-2008 05:00 PM
An interface extending an interface(I) JavaForums Java Blogs 0 03-12-2008 05:00 PM
interface Comparable<T> problem Lennon-Guru New To Java 3 03-05-2008 02:17 AM
Interface extending Interface JavaForums Java Blogs 0 12-04-2007 03:20 PM


All times are GMT +3. The time now is 01:14 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org