|
I cannot advise better than the other answer you got. to me, Eclipse is the best IDE for Java/J2EE I know...
|
|
|
|
|
Hello! I need to make some search in the registry...
I need to find all the keys and the values that include some word, and to
delete them... I know there is a class Registry, but I don't know how to
do what I need.
Maybe someone could help me? (in Java)
if someone could show me an example code it will be great!!!
Thanks!
Raz.
|
|
|
|
|
need help in writng a class WordStore in order to compile WordTest1, WordTest2, WordTest3 and WordTest4. Need to create some sort of data structure to store words in WordStore. must have methods
public void add(String word)
Adds a String to the collection
public int count(String word)
Returns the number of times a String is in the collection
public void remove(String word)
Removes one occurrence of a String from the collection, or leaves the collection unchanged if the String does not occur in it.
code for WordTest1:
import java.util.Scanner;
class WordTest1
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
WordGen.initialise(input);
System.out.print("Enter the number of words you wish to generate: ");
int n = input.nextInt();
WordStore words = new WordStore(n);
for(int i=0; i<n;> words.add(WordGen.make());
String line = input.nextLine();
System.out.println("Enter words to test, empty line to exit");
line = input.nextLine();
while(!line.equals(""))
{
String[] wordlist = line.split(" ");
for(int i=0; i<wordlist.length;> {
int count = words.count(wordlist[i]);
System.out.print("\""+wordlist[i]+"\" ");
if(count==0)
System.out.println("NOT generated");
else if(count==1)
System.out.println("generated once");
else
System.out.println("generated "+count+" times ");
}
line = input.nextLine();
}
}
}
code for WordTest2:
import java.util.*;
class WordTest2
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
WordGen.initialise(input);
System.out.print("Enter the number of words you wish to generate initially: ");
int n = input.nextInt();
WordStore words = new WordStore(n);
for(int i=0; i<n;> words.add(WordGen.make());
System.out.print("Enter number of words you wish to test: ");
n = input.nextInt();
String[] testWords = new String[n];
for(int i=0; i<n;> testWords[i]=WordGen.make();
long time1,time2;
int count;
time1 = new Date().getTime();
for(int i=0; i<n;> count=words.count(testWords[i]);
time2 = new Date().getTime();
System.out.print("Time taken to test membership of "+n+" words ");
System.out.println("is "+(time2-time1)+"ms");
}
}
code for WordTest3:
import java.util.*;
class WordTest3
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
WordGen.initialise(input);
System.out.print("Enter the number of words you wish to generate initially: ");
int n = input.nextInt();
WordStore words = new WordStore(n);
for(int i=0; i<n;> words.add(WordGen.make());
System.out.print("Enter number of words you wish to add: ");
n = input.nextInt();
String[] testWords = new String[n];
for(int i=0; i<n;> testWords[i]=WordGen.make();
long time1,time2;
int count;
time1 = new Date().getTime();
for(int i=0; i<n;> words.add(testWords[i]);
time2 = new Date().getTime();
System.out.print("Time taken to add "+n+" more words ");
System.out.println("is "+(time2-time1)+"ms");
}
}
code for WordTest4:
import java.util.*;
class WordTest3
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
WordGen.initialise(input);
System.out.print("Enter the number of words you wish to generate initially: ");
int n = input.nextInt();
WordStore words = new WordStore(n);
for(int i=0; i<n;> words.add(WordGen.make());
System.out.print("Enter number of words you wish to add: ");
n = input.nextInt();
String[] testWords = new String[n];
for(int i=0; i<n;> testWords[i]=WordGen.make();
long time1,time2;
int count;
time1 = new Date().getTime();
for(int i=0; i<n;> words.add(testWords[i]);
time2 = new Date().getTime();
System.out.print("Time taken to add "+n+" more words ");
System.out.println("is "+(time2-time1)+"ms");
}
}
|
|
|
|
|
hi
my problem is that im trying to build a one armed bandit using Java but i carnt figure out the If statement that lets you get:-
3 shapes of the same type win £1
2 shapes of the same type win 50p
one particular shape, say a apple win 20p
my coding that i have already should be below
any help with this problem would be great
thanks
Adam
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.Timer;
public class ConcentricCirclesWithTimer extends JFrame implements ActionListener
{
private JPanel panelDraw;
private JButton btnDraw, btnBye;
private Random random;
private Timer timer;
int width = 10;
int height = 10;
int x= 100;
int y = 100;
int timerCounter = 0;
public static void main(String[] args)
{
ConcentricCirclesWithTimer drawConcentCirc = new
ConcentricCirclesWithTimer();
}
public ConcentricCirclesWithTimer()
{
setLayout(new FlowLayout());
random = new Random();
panelDraw = new JPanel();
panelDraw.setPreferredSize(new Dimension(200, 200));
panelDraw.setBackground(Color.GRAY);
btnBye = new JButton("Bye!!");
btnDraw = new JButton("Draw.. .");
add(panelDraw); add(btnDraw); add(btnBye);
btnDraw.addActionListener(this);
btnBye.addActionListener(this);
setTitle("Using Pannel to Draw . . . .");
setSize(300, 300);
setVisible(true);
}
public void actionPerformed(ActionEvent event){
if (event.getSource()== btnDraw) {
timer = new Timer(400, this);
timer.start();
}// end of if
if (event.getSource() == timer ){
drawConcentricCircles() ;
}
if (event.getSource()== btnBye) {
System.exit(0);
}
}// end of actionPerformed
private void drawConcentricCircles(){
// x, y, height and width need to be declared globally?? Why??
// declare them here and run program!!
timerCounter = timerCounter + 1;
Graphics drawOnPanel = panelDraw.getGraphics();
drawOnPanel.setColor(new Color(random.nextInt(255),
random.nextInt(255), random.nextInt(255)));
drawOnPanel.drawOval(x, y, width, height);
width = width+20;
height = height+20;
x = x - 10;
y = y-10;
if (timerCounter>11){
timer.stop();
JOptionPane.showMessageDialog(null,"Timer stopped!!");
}
}
}
|
|
|
|
|
I assume this is a standard 3-wheel slot machine?
You should have a "slot" object defined somewhere, or at least some member variables to hold the "shape" and "color" values of each slot wheel.
The "if" statements aren't writable until we know what to compare them with.
For example, would it be "if (slot1Color == 0)" or "if (slot1.color == Color.RED)" or something else?
All you have written is a skeleton application. None of that concerns the question you wanted help with.
Don't let my name fool you. That's my job.
|
|
|
|
|
hi,
I had developed a chat application it is running well on a single system.I want this chat appl. to be communicated with other system like normal chatting. Plz help me out vth this issue.
thank u.
|
|
|
|
|
How You developed the Code?Is it developed by JAVA Threading?
Please let me know the code so that i can give you the exact way to do it.
thanks
Apurba
|
|
|
|
|
hi apurba,
s i had developed using threading concept.my chatserver is working on a default ip-address .0.0.0.what i want is my chatserver must start by picking up my systems Ip-address.here is the code m using.
protected void start_iChatServer(){
try{
iPortNo=Integer.parseInt(iAcquirePortNo.getText());
System.out.println("Port No." + iPortNo +"/n");
}catch(NumberFormatException e){
System.out.println("\n"+e);
System.out.println("Starting at default port : 1664...");
iPortNo=1664;
}
try{
iChatServer=new ServerSocket(iPortNo);
Int=iChatServer.getInetAddress();
i=iChatServer.getLocalPort();
sad=iChatServer.getLocalSocketAddress();
System.out.println("inetaddress=" + Int+ "localport="+i+ "getlocalsocketaddress="+sad);
isServerRunning=true;
System.out.println("\nServer set up and running at port "+iPortNo+"...\nWelcome to iChat Server v1.0...");
System.out.println("ichatserver=" +iChatServer);
iAcquirePortNo.setEnabled(false);
srtServer.setEnabled(false);
stpServer.setEnabled(true);
iClientList=new ArrayList();
iMainThread=new Thread(this,"iChat Server v1.0");
iMainThread.start();
}catch(IOException e){
System.out.println("\n"+e);
System.out.println("Error occured while setting up the server...\nTry another port...");
}
}
public void run(){
while(iMainThread!=null){
try{
Socket iNewClient=iChatServer.accept();
InfiniteChatClientHandler iNewClientHandle=new InfiniteChatClientHandler(this,iNewClient);
Thread.sleep(1000);
}catch(InterruptedException e){
}catch(IOException e){
}
}
}
Thank u
have a nice day.
|
|
|
|
|
I have 5 java classes and I want make them an executable one.
I use Netbeans IDE.
|
|
|
|
|
With Java you create JARs instead. Google that phrase and that should help. I think there are ways to turn Java apps into .exe files, but I have never done it, and that completely destroys most pros of Java.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Pls help me when to use these technologies in any kind of business application.........
|
|
|
|
|
This is more like a general rant, but the problem I'm facing right now is with Java update, so here goes.
I have a Japanese Win XP computer because I work in a Japanese company. I cannot read Japanese. I specifically downloaded the English version of Java and installed it so I would be able to read the messages.
Now that it wants to update, it only does so in Japanese. That means the screens with all the prompting are in Japanese, and the buttons labeled "okay" or "no, this will wipe your hard disk, don't do it!" are also unreadable.
Can someone explain to me why Sun, in their infinite wisdom, decided users shouldn't be able to easily override their default computer settings so that the user can decide what language he wants to read? I already know why Microsoft does it, but "for the money" doesn't seem appropriate for Java.
Also, I realize that sometimes they say "just change your locale settings", but that isn't good enough. In XP, there are about 5 different locale-related items I can change, and at least two of them force me to reboot my computer. I want something to affect the Java update, and only the Java update (and possibly other Java settings). I don't want to reboot my computer just for one program, then reboot again when it's finished. That is a BAD SOLUTION.
*breathes*
Okay, I'm just going to go wipe my hard disk now. Thanks for listening.
|
|
|
|
|
I need an applet where a user enters (or cut-n-pastes) a UTF-8 string into a TextField. Then the user presses a button, and the UTF-8 text is copied into a string.
|
|
|
|
|
Then write one?
What is your specific question/problem?
Don't let my name fool you. That's my job.
|
|
|
|
|
I figured it out shortly after creating this post. I'm using JavaCC to parse my UTF8 inputs, and it's working fine! Thanks for your reply.
|
|
|
|
|
Hello folks,
i'm searching for a class or any sample code to organize a graph (map or network).
I try to explain better, i just want to display a graph in a fine way, clear and well spaced.
Thanks in advance
Program your life ^^
|
|
|
|
|
dear master,,,
I plan to make GPS application in Hand Phone (SE C702) using J2ME,,,
until know, I still confuse about step by step to build this application,,,,
I hope anyone can help to save me from this problem,,,
Cry
thanks,,,,
|
|
|
|
|
Hi guys if any one could help me out with this would be appriciated
I m using servlet as a controller and I have a following html tag and href to pass clicked text to servlet using javascript for further processing. I m not getting it right.
Please look at the code snippet
|
|
|
|
|
can any one help in creating a unstructered p2p n/w.......
|
|
|
|
|
I was wondering if anyone could help me. I have a number of .JAR files which I want to be able to access from VB. I have downloaded a utility which converts the .JAR file into a .DLL which means I can access it using VB code. Unfortunately the software was evaluation only and very expensive. Does anyone know of a free utility that does this or another solution ? The software was from the following site:
http://www.ezjcom.com
Thanks,
Raj
|
|
|
|
|
Thank U Mr.RaJ...........
By Ramesh (GNIIT)
|
|
|
|
|
Dear All,
I've been trying to display the Tif image into the WebBrowser with the help of Applet embedded into a JSP through NetBeans IDE.
To achieve this goal, I've created 2 projects "NewApplet" which contains the Applet class and "WebApplication1" which has "Index.JSP" which embeds the Applet.
If i execute Only the Applet, it displays the TIF. But if i execute the JSP, it fires the following error:
"URL Scheme is not "file" http://localhost:8084/WebApplication1/alpesh.tif""
Following is the code written NewApplet.Java:
package display;
import javax.swing.JApplet;
import java.awt.BorderLayout;
import java.awt.image.RenderedImage;
import java.io.IOException;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.JScrollPane;
import com.sun.media.jai.codec.ImageCodec;
import com.sun.media.jai.codec.ImageDecoder;
import com.sun.media.jai.codec.TIFFDecodeParam;
import com.sun.media.jai.widget.DisplayJAI;
import java.io.File;
import java.io.FileInputStream;
import java.net.URI;
import javax.swing.JOptionPane;
public class NewApplet extends JApplet {
@Override
public void init() {
URI FileName = URI.create(getCodeBase().toString().concat(getParameter("imageSource")));
try
{
File f = new File(FileName);
FileInputStream stream = new FileInputStream(f);
// Create a decoder using that stream.
TIFFDecodeParam tiff = new TIFFDecodeParam();
ImageDecoder dec = ImageCodec.createImageDecoder("tiff", stream, tiff);
// Get the number of pages.
int pages;
pages = dec.getNumPages();
// Set the application title.
setTitle(pages+" pages in "+filename);
// Create a JDesktop to hold the pages in internal frames.
JDesktopPane desktop = new JDesktopPane();
//getContentPane().add(desktop,BorderLayout.CENTER);
desktop.setSize(400,400);
add(desktop,BorderLayout.CENTER);
// Open all images in the TIFF into the desktop pane.
for(int i=0;i<pages;i++)
{
// Get the image.
RenderedImage ri = dec.decodeAsRenderedImage(i);
// Create and set the user interface of an internal frame.
JInternalFrame jif = new JInternalFrame("Page "+i,true,true,true,true);
jif.getContentPane().add(new JScrollPane(new DisplayJAI(ri)));
jif.setSize(400,400);
jif.pack();
jif.setVisible(true);
// Add the internal frame to the JDesktop.
desktop.add(jif);
}
// Set the application closing behaviour, frame size, and show it.
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400,400);
setVisible(true);
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this, e.getMessage(), "alert", JOptionPane.ERROR_MESSAGE);
}
}
}
Following is the code written Index.JSP:
<APPLET code="display.NewApplet" ARCHIVE="NewApplet.jar" width=350 height=200>
<param name ="imageSource" value="alpesh.tif"/>
</APPLET>
Any Guesses?
I've added the "dist/NewApplet.jar" in WebApplication1 through the option of "Properties->Build->Packaging" in NetBeans.
Please help!
- Alpesh
- Alpesh Khunt
|
|
|
|
|
that doesn't to be reposted
|
|
|
|
|
Dear All,
I've been trying to display the Tif image into the WebBrowser with the help of Applet embedded into a JSP through NetBeans IDE.
To achieve this goal, I've created 2 projects "NewApplet" which contains the Applet class and "WebApplication1" which has "Index.JSP" which embeds the Applet.
If i execute Only the Applet, it displays the TIF. But if i execute the JSP, it fires the following error:
"URL Scheme is not "file" http://localhost:8084/WebApplication1/alpesh.tif""
Following is the code written NewApplet.Java:
package display;
import javax.swing.JApplet;
import java.awt.BorderLayout;
import java.awt.image.RenderedImage;
import java.io.IOException;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.JScrollPane;
import com.sun.media.jai.codec.ImageCodec;
import com.sun.media.jai.codec.ImageDecoder;
import com.sun.media.jai.codec.TIFFDecodeParam;
import com.sun.media.jai.widget.DisplayJAI;
import java.io.File;
import java.io.FileInputStream;
import java.net.URI;
import javax.swing.JOptionPane;
public class NewApplet extends JApplet {
@Override
public void init() {
URI FileName = URI.create(getCodeBase().toString().concat(getParameter("imageSource")));
try
{
File f = new File(FileName);
FileInputStream stream = new FileInputStream(f);
// Create a decoder using that stream.
TIFFDecodeParam tiff = new TIFFDecodeParam();
ImageDecoder dec = ImageCodec.createImageDecoder("tiff", stream, tiff);
// Get the number of pages.
int pages;
pages = dec.getNumPages();
// Set the application title.
setTitle(pages+" pages in "+filename);
// Create a JDesktop to hold the pages in internal frames.
JDesktopPane desktop = new JDesktopPane();
//getContentPane().add(desktop,BorderLayout.CENTER);
desktop.setSize(400,400);
add(desktop,BorderLayout.CENTER);
// Open all images in the TIFF into the desktop pane.
for(int i=0;i<pages;i++)>
{
// Get the image.
RenderedImage ri = dec.decodeAsRenderedImage(i);
// Create and set the user interface of an internal frame.
JInternalFrame jif = new JInternalFrame("Page "+i,true,true,true,true);
jif.getContentPane().add(new JScrollPane(new DisplayJAI(ri)));
jif.setSize(400,400);
jif.pack();
jif.setVisible(true);
// Add the internal frame to the JDesktop.
desktop.add(jif);
}
// Set the application closing behaviour, frame size, and show it.
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400,400);
setVisible(true);
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this, e.getMessage(), "alert", JOptionPane.ERROR_MESSAGE);
}
}
}
Following is the code written Index.JSP:
<applet code="display.NewApplet" archive="NewApplet.jar" width="350" height="200">
<param name="imageSource" value="alpesh.tif" />
</applet>
Any Guesses?
I've added the "dist/NewApplet.jar" in WebApplication1 through the option of "Properties->Build->Packaging" in NetBeans.
Please help!
Ritesh
|
|
|
|
|
i am using vector data structure in my code
1- i create the following vector of vector:
Vector<vector><integer>> dataVector= new Vector<vector><integer>>();</integer></vector></integer></vector>
and i need to do the following if some condition is true , create new vector and add to the dataVector
maybe somthing like this
if (condition==turu)
then creat new vector
dataVector.add(new vector)
can any one help me
|
|
|
|
|