Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes Question on IDE? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question on IDE?" Watch "Question on IDE?" New topic
Author

Question on IDE?

Ed Stevens
Ranch Hand

Joined: May 06, 2008
Posts: 38
I have got codes that won't run on JDK.I don't think it can run GUI applications-so i need an IDE.Which one should i download that's versatile enough to support most of the GUI & Swing/AWT applications,for event driven programming,for USER INTERFACES etc etc..I think i will need either Netbeans or
IntelliJIDEA.Any suggestions and information is welcome..

THANK YOU- GOOD SAMARITANS!!!


<a href="http://foureyedmonsters.com/neutrality/" target="_blank" rel="nofollow">http://foureyedmonsters.com/neutrality/</a><br /><a href="http://www.netcharles.com/orwell/ctc/" target="_blank" rel="nofollow">http://www.netcharles.com/orwell/ctc/</a>
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8705
    
    6

Originally posted by Ed Stevens:
I have got codes that won't run on JDK.I don't think it can run GUI applications


If it is in the Java API, the JDK can run it. That includes Swing and AWT.
I'm curious to know exactly what problem you are having running your code.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Ed Stevens
Ranch Hand

Joined: May 06, 2008
Posts: 38
the codes compile fine but don't execute-they are part of a few study projects that i got ,but there was no mention of how to run them...
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.io.*;
import java.math.*;




public class Hill extends JApplet implements ActionListener
{
/** Initialization method that will be called after the applet is loaded
* into the browser.
*/
public void init () {
initComponents();
setSize(400, 600);
}

// Parameters Begin
private javax.swing.JTextField aTextField;
private javax.swing.JTextField bTextField;
private javax.swing.JTextField cTextField;
private javax.swing.JTextField dTextField;

// Parameters End

private javax.swing.JButton encryptButton;
private javax.swing.JButton decryptButton;
private javax.swing.JTextArea inputTextArea;
private javax.swing.JTextArea outputTextArea;
private javax.swing.JPanel parameterPanel;
private javax.swing.JPanel textPanel;
private javax.swing.JPanel inputPanel;
private javax.swing.JPanel outputPanel;
private javax.swing.JPanel topInputPanel;
private javax.swing.JPanel topOutputPanel;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private Container mainContainer;
private final int width=400, height=600;
private boolean casechange=false, clean=false;


private void initComponents() {
mainContainer = getContentPane();
mainContainer.setLayout(new BorderLayout(0,0));

// Parameter Panel Begin
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();

jLabel2.setText("a=");
jLabel3.setText("b=");
jLabel4.setText("c=");
jLabel5.setText("d=");
jLabel6.setText("Enter Text");
jLabel7.setText("or");

aTextField = new javax.swing.JTextField(3);
bTextField = new javax.swing.JTextField(3);
cTextField = new javax.swing.JTextField(3);
dTextField = new javax.swing.JTextField(3);

aTextField.setText("");
bTextField.setText("");
cTextField.setText("");
dTextField.setText("");

parameterPanel = new javax.swing.JPanel();
parameterPanel.add(jLabel2);
parameterPanel.add(aTextField);
parameterPanel.add(jLabel3);
parameterPanel.add(bTextField);
parameterPanel.add(jLabel4);
parameterPanel.add(cTextField);
parameterPanel.add(jLabel5);
parameterPanel.add(dTextField);


// Parameter Panel End / Input Panel Begin


topInputPanel = new javax.swing.JPanel();
topInputPanel.add(jLabel6);

inputTextArea = new javax.swing.JTextArea();
inputTextArea.setLineWrap(true);
inputTextArea.setText("");
inputPanel = new javax.swing.JPanel();
inputPanel.setLayout(new BorderLayout());

inputPanel.add(topInputPanel,BorderLayout.NORTH);
inputPanel.add(inputTextArea,BorderLayout.CENTER);

// Input Panel End / Output Panel Begin
encryptButton = new javax.swing.JButton();
decryptButton = new javax.swing.JButton();


encryptButton.setText("Encrypt");
encryptButton.addActionListener(this);
decryptButton.setText("Decrypt");
decryptButton.addActionListener(this);

topOutputPanel = new javax.swing.JPanel();
topOutputPanel.add(encryptButton);
topOutputPanel.add(jLabel7);
topOutputPanel.add(decryptButton);

outputTextArea = new javax.swing.JTextArea();
outputTextArea.setText("");
outputTextArea.setLineWrap(true);

outputPanel = new javax.swing.JPanel();
outputPanel.setLayout(new BorderLayout(0,0));

outputPanel.add(topOutputPanel,BorderLayout.NORTH);
outputPanel.add(outputTextArea, BorderLayout.CENTER);

// Output Panel End

textPanel = new javax.swing.JPanel();
textPanel.setLayout(new GridLayout(2,1));

textPanel.add(inputPanel);
textPanel.add(outputPanel);

mainContainer.add(parameterPanel, BorderLayout.NORTH);
mainContainer.add(textPanel, BorderLayout.CENTER);

}

public String cleanString(String toClean)
{
String returnString = new String();

for(int i=0;i<toClean.length();i++)
{
if (Character.isLetter(toClean.charAt(i)) == true)
returnString = returnString + toClean.charAt(i);
}

return returnString;
}
public void actionPerformed(ActionEvent e)
{

if (e.getSource()==encryptButton)
{
String toEncrypt = new String(inputTextArea.getText());
int a = Integer.parseInt(aTextField.getText()) % 26;
int b = Integer.parseInt(bTextField.getText()) % 26;
int c = Integer.parseInt(cTextField.getText()) % 26;
int d = Integer.parseInt(dTextField.getText()) % 26;

toEncrypt = cleanString(toEncrypt);
toEncrypt = toEncrypt.toLowerCase();

if (toEncrypt.length() % 2 == 1)
toEncrypt = toEncrypt + "x";

char charArray[] = toEncrypt.toCharArray();

for(int i=0;i<toEncrypt.length();i+=2)
{
char temp = charArray[i];
charArray[i] = (char)((((int)charArray[i] - 97)*a + ((int)charArray[i+1]-97)*b ) % 26 + 97);
charArray[i+1] = (char)((((int)temp - 97)*c + ((int)charArray[i+1]-97)*d ) % 26 + 97);
}

toEncrypt = new String(charArray);
toEncrypt = toEncrypt.toUpperCase();
outputTextArea.setText(toEncrypt);
}
else if (e.getSource()==decryptButton)
{
try{
String toDecrypt = new String(inputTextArea.getText());
int a = Integer.parseInt(aTextField.getText()) % 26;
int b = Integer.parseInt(bTextField.getText()) % 26;
int c = Integer.parseInt(cTextField.getText()) % 26;
int d = Integer.parseInt(dTextField.getText()) % 26;
int detA = (a*d-b*c)%26;
if (detA==0)
{
String error = new String("Matrix not invertible");
outputTextArea.setText(error);
}

BigInteger X = new BigInteger(""+detA);
BigInteger M = new BigInteger("26");
BigInteger R = X.modInverse(M);
int deta= R.intValue();

int w = (deta*d+676)%26;
int x = (deta*-b+676)%26;
int y = (deta*-c+676)%26;
int z = (deta*a+676)%26;
//System.out.println(w+","+x+","+y+","+z+",");

toDecrypt = cleanString(toDecrypt);
toDecrypt = toDecrypt.toLowerCase();

char charArray[] = toDecrypt.toCharArray();

for(int i=0;i<toDecrypt.length();i+=2)
{
char temp = charArray[i];
charArray[i] = (char)((((int)charArray[i] - 97)*w + ((int)charArray[i+1]-97)*x ) % 26 + 97);
charArray[i+1] = (char)((((int)temp - 97)*y + ((int)charArray[i+1]-97)*z) % 26 + 97);
}

toDecrypt = new String(charArray);

outputTextArea.setText(toDecrypt);
}
catch (Exception ex){}

}


}
}
Ed Stevens
Ranch Hand

Joined: May 06, 2008
Posts: 38
And here's another one - a part of the second project:


import java.awt.Color;
import java.awt.FlowLayout;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.*;
import javax.swing.JPanel;
import java.awt.event.*;
import java.net.Socket;
import java.net.UnknownHostException;
import java.io.ObjectInputStream;
import java.io.PrintWriter;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;


public class JVNCclient extends JFrame implements MouseWheelListener
{
private JLabel screen;
private ObjectInputStream in;
private PrintWriter out;
private ScreenThread screenThread;
private ImageIcon i;
private Socket s;
private boolean stopped = false;

public JVNCclient()
{
int WIDTH = Toolkit.getDefaultToolkit().getScreenSize().width;
int HEIGHT = Toolkit.getDefaultToolkit().getScreenSize().height;

setTitle("Virtual Network Computing");
setBackground(Color.white);
screen = new JLabel();
getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
getContentPane().add(screen);

resize(WIDTH,HEIGHT-10);

addMouseListener(new MyMouseAdapter(this));
addMouseMotionListener(new MyMouseMotionAdapter(this));
addKeyListener(new MyKeyAdapter(this));

addWindowListener(new WindowAdapter()
{

public void windowClosing(WindowEvent we)
{
stopped = true;
screenThread.stopRunning();
sendAndUpdate(JVNCconstant.CLOSE,0,0);
System.exit(0);
}

});


String serverName =JOptionPane.showInputDialog(this, "Enter Server name :", "Server", JOptionPane.INFORMATION_MESSAGE);

try
{
s = new Socket(serverName.trim(), 1166);
if (s==null)
{
System.out.println("No I/O");
System.exit(0);
}
else
{
in = new ObjectInputStream(s.getInputStream());
out = new PrintWriter(s.getOutputStream());

screenThread = new ScreenThread();
}
}

catch (Exception ex)
{
JOptionPane.showMessageDialog(null,"Server not found on PORT number 1166");
System.exit(0);
}

}

public void updateScreen(final ImageIcon i)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
screen.repaint();
screen.setIcon(i);
}
});
}


private void sendAndUpdate(int type,int arg1, int arg2)
{
String s = "" + type + "|" + arg1 + "|" + arg2;
out.println(s);
out.flush();
}



class MyMouseAdapter extends MouseAdapter
{
JVNCclient jvnc;

public MyMouseAdapter(JVNCclient jvnc)
{
this.jvnc = jvnc;
}
public void mousePressed(MouseEvent e)
{
sendAndUpdate(JVNCconstant.MOUSE_PRESS, e.getX(),e.getY());
}

public void mouseReleased(MouseEvent e)
{
sendAndUpdate(JVNCconstant.MOUSE_RELEASE,0,0);
}
}

class MyMouseMotionAdapter extends MouseMotionAdapter
{
JVNCclient jvnc;

public MyMouseMotionAdapter(JVNCclient jvnc)
{
this.jvnc = jvnc;
}

public void mouseDragged(MouseEvent e)
{
sendAndUpdate(JVNCconstant.MOUSE_MOVE, e.getX(), e.getY());
}

public void mouseMoved(MouseEvent e)
{
sendAndUpdate(JVNCconstant.MOUSE_MOVE,e.getX(), e.getY());
}
}

public void mouseWheelMoved(MouseWheelEvent e)
{
sendAndUpdate(JVNCconstant.MOUSE_WHEEL,e.getScrollAmount(),0);
}



class MyKeyAdapter extends KeyAdapter
{
JVNCclient jvnc;

public MyKeyAdapter(JVNCclient jvnc)
{
this.jvnc = jvnc;
}

public void keyPressed(KeyEvent ke)
{
int key;

key = ke.getKeyCode();

if(key==ke.VK_ENTER)
sendAndUpdate(JVNCconstant.KEY_PRESS_EVENTS,ke.VK_ENTER,0);
else if(key==ke.VK_F1)
sendAndUpdate(JVNCconstant.KEY_PRESS_EVENTS,ke.VK_F1,0);
else if(key==ke.VK_ESCAPE)
sendAndUpdate(JVNCconstant.KEY_PRESS_EVENTS,ke.VK_ESCAPE,0);
}
}

public static void main(String argv[])
{
JVNCclient f = new JVNCclient();
f.setVisible(true);
f.show();
}

private class ScreenThread implements Runnable
{
Thread t;
private boolean keepRunning;

ScreenThread()
{
keepRunning = true;
t = new Thread(this,"Screen Thread");
t.start();
}

public void run()
{
while (keepRunning)
{
try
{
if(stopped ==false)
{
if((i = (ImageIcon)in.readObject())!=null)
{
updateScreen(i);
Thread.sleep(1000);
i=null;
}
}
else
{
keepRunning = false;
in.close();
}
}
catch(InterruptedException e)
{
System.out.println("Thread Interrupted");
}
catch(OutOfMemoryError e)
{
e.toString();
JOptionPane.showMessageDialog(null,"JVM can not able to allocate Memory");
System.exit(0);
}
catch (ClassNotFoundException ex)
{
ex.printStackTrace();
}
catch (Exception ex)
{
ex.printStackTrace();
JOptionPane.showMessageDialog(null,"Server is stoped");
System.exit(0);
}
}
}

public void stopRunning()
{
keepRunning = false;
}
}

}
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8705
    
    6

When you say the examples "don't run" what do you mean? They do nothing? You get an error? Exactly what command did you give to run the examples?
Ed Stevens
Ranch Hand

Joined: May 06, 2008
Posts: 38
They compiled fine - but they won't produce an output..do nothing....
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8705
    
    6

Exactly what command did you give to run the examples?
Ed Stevens
Ranch Hand

Joined: May 06, 2008
Posts: 38
javac <filename>.java...<filename> was the name of the public class in the file..
:roll:
Ed Stevens
Ranch Hand

Joined: May 06, 2008
Posts: 38
is this what i have to do?
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/cl/runjva.htm
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8705
    
    6

javac is the java compiler. It takes Java code and turns it into a bytecode that the interpreter can understand. Not getting output from it is a good thing.
In order to actually execute the bytecode, you have to give the bytecode to the interpreter. Usually this the command to start the interpreter is "java <main class name>".
You should hit the Java Tutorial. It covers the basics on how to run Java apps and gives you some context with the examples.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8705
    
    6

Originally posted by Ed Stevens:
is this what i have to do?
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/cl/runjva.htm


If you are on an IBM iSeries 400, sure.
Ed Stevens
Ranch Hand

Joined: May 06, 2008
Posts: 38
Thank you ..... i am running them with your method ,but please tell me vis a vis these steps....

http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/cl/runjva.htm
Ed Stevens
Ranch Hand

Joined: May 06, 2008
Posts: 38
OK got it perfectly..thanks..
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8705
    
    6

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on IDE?
 
Similar Threads
difference between epocjava and midlets?
GUI Development?
Swing Redundant ?
server/alone command line
Why J2ME, when there is WML and WAP?