|
how can i play sound in jfram using java
|
|
|
|
|
Have you searched in google[^]?
Excuse me for my improper grammar and typos.
It's because English is my primary language, not my first language.
My first languages are C# and Java.
VB, ASP, JS, PHP and SQL are my second language.
Indonesian came as my third language.
My fourth language? I'm still creating it, I'll let you know when it's done!
|
|
|
|
|
Is there a way to list the CPU usage per process of all the processes that are currently running in the system. What I mean is CPU % usage as is shown in the Taskmanager.
I have tried a few API like sigar and JavaSysMon but am not able to get accurate values of the %'s.
|
|
|
|
|
I would guess that the only way to get reasonable data if the JavaSysMon() method does not do it, is to use the native process and thread functions[^], using C/C++. This would mean you will have to write JNI[^] or JNA[^] code to act as the interface between C++ and Java.
|
|
|
|
|
Steps.
1. Find or create a command line tool that does that.
2. Use java Runtime.exec() to run it and get the results.
|
|
|
|
|
These days you should probably prefer ProcessBuilder to Runtime for executing external processes. ProcessBuilder does everything Runtime.exec does and more, so it's probably worth getting into the habit of using it. After all it has been around since 1.5 which came in years ago.
|
|
|
|
|
hey anyone can give some idea about stegnography coding in java???
|
|
|
|
|
Google "java steganography". You will get over 700,000 results. Maybe some of them might be useful, who knows?
|
|
|
|
|
You've already received some help, but instead of reacting in a sensible fashion you just decided to delete the whole question including my answer.
No help for your here, Sorry!
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
Here is my Applet code. It does not draw to the applet screen! I have tested that it loops, but nothing appears! Can i have some help figuring out this?
package net.petterroea;
import java.applet.Applet;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
public class TheBox extends Applet implements Runnable{
Input input;
Screen screen;
boolean running;
Thread thisThread;
Image backBuffer;
public TheBox()
{
thisThread = new Thread(this);
input = new Input(this);
this.setPreferredSize(new Dimension(640, 480));
this.addKeyListener(input);
this.addFocusListener(input);
this.addMouseListener(input);
Media.loadImages();
screen = new MainMenuScreen();
}
@Override
public void start()
{
running = true;
thisThread.run();
}
@Override
public void stop()
{
running = false;
}
@Override
public void run()
{
Graphics realg = null;
Graphics g = null;
while(running)
{
synchronized(this)
{
System.out.println(this.getWidth() + " " + this.getHeight());
realg = this.getGraphics();
if(backBuffer == null)
{
backBuffer = createImage(this.getWidth(), this.getHeight());
}
else if(backBuffer.getWidth(null) != this.getWidth() || backBuffer.getHeight(null) != this.getHeight())
{
backBuffer = createImage(this.getWidth(), this.getHeight());
}
g = backBuffer.getGraphics();
screen.tick(g);
realg.drawImage(backBuffer, 0, 0, null);
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
modified on Saturday, August 20, 2011 10:47 AM
|
|
|
|
|
See here[^], you need a paint() method to do the painting. Applets have a different life-cycle than normal Java apps.
|
|
|
|
|
Still does not work
public void paint(Graphics g) {
System.out.println("asd");
g.drawRect(0, 0,
getWidth() - 1,
getHeight() - 1);
}
...
...
...
...
repaint();
|
|
|
|
|
Try this:
g.drawRect(0, 0, getSize().width - 1, getSize().height - 1);
|
|
|
|
|
|
How to pass hashmap between (signed) applets?
My problem is that one applet scans for some data on a client PC. Then I need to display some text and components on that webpage (where the applet is) after the scan is completed.
One way to do the task is to move the applet component to new coordinates (position) with CSS but if I do this the applet reloads and starts the scan again.
Another way is to pass the hashmap data to another applet and make it visible.
And the last way is to store the hashmap data to some place (like RAM or smth. else) and then read it on relaunch of the applet. (is it possible to do wiht signed applet?)
I'd be really grateful for any working suggestions.
Thanks.
|
|
|
|
|
This article[^] shows how to access the DOM from the applet. You can put your hashmap in the document (make it invisible, of course.) If you use the 'second applet' approach, it can then retrieve your haskmap from the DOM. If you use the 'relaunch' approach, then you can go back to where you put it the first time. (As a bonus, you get to see if it's a first launch or relaunch simply by testing if your data exists.)
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Dear Reader,
I have been busy with building a java webserver.
the server can handle the basic HTML GET requests and serve some simple html files.
Now i want to serve Java Applets in a website.
i added the line
<applet code=Testapp width=512 height=512> </applet>
to the HTML file
The Testapp is a .class file and the server can find the file and sends it.
When i open the file locally it works without errors.
but when i open it through the java webserver it gives me a strange error.
"Exception: java.lang.ClassFormatError: Unknown constant tag 101 in class file Testapp"
These are the tests i have done but didnt work:
-->Created another app. This one also works perfect local, but through the server it gives an Unknown constant tag 13 error. At that point i kinda had my head upside down :P
-->captured a header from a site that had an applet buildt in. Took over some parts of the header but that didnt work.
Im desperate! i am stuck for like 2 weeks now. I tried a lot but it all didnt got better. thank god it didnt got worse.
I did found out the error has something to do with a corrupted jar / class file. I exported it again and again and again...
Thanks in advance
|
|
|
|
|
Is your code written as an Applet? (i.e. your main class extends java.applet.Applet or javax.Swing.JApplet ?) If not, it won't work as an applet. Google java applet for more information.
Peter
[edit] corrected typo - Swing is in javax not java [/edit]
Software rusts. Simon Stephenson, ca 1994.
modified on Wednesday, August 17, 2011 9:51 PM
|
|
|
|
|
Well, the class extends an applet, but could you check it for me ? its pretty short.
import java.applet.*;
import java.awt.*;
public class Testapp extends Applet {
public String hdr = "abcd";
public void init() {
super.init();
}
public void paint(Graphics g) {
super.paint(g);
g.drawString(hdr, 5, 15);
}
}
Could it be that i have to make a Main and then create a new object? would be silly if u ask me
|
|
|
|
|
Roysten1818 wrote:
Could it be that i have to make a Main and then create a new object? would be silly if u ask me No. your code looks fine from that aspect.
Roysten1818 wrote: could you check it for me ? Sorry, don't have the resources right now.
jschell's suggestions are good - have a look at what is getting delivered from the server.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Roysten1818 wrote: to the HTML file The Testapp is a .class file and the server can find the
file and sends it.
To verify.
1. The client requests the html.
2. The server sends it.
3. The client requests that applet
4. The server sends it.
If so I would guess the problem is the content of 4.
Simple way to figure out what is really in there.
1. Get another http server.
2. Set it up to send the applet.
3. Verify everything works.
4. Run with a network sniffer in place to see what the client/server traffic looks like.
You will find a difference. Once you find the difference then go track down the relevant RFCs and read them to understand what it is doing.
|
|
|
|
|
Oeh! thats a neat idea, will do it first thing in the morning! will edit this post with the result...
i hope its a problem with the header or else it would a lot more work!
thanks already
|
|
|
|
|
hi there i am working on a project that my goal is when i run my code it will create another file(classes) (exp: personalList.java) and user must associate with second file. for example;
i have a file "PersonalDatabaseCreator.java" and this file creates "Person.java" (which is my object and includes properties getters setters etc.) and "PersonalList.java" which user will interact. (PersonalList.java ask the location of the text file which contains people to add into a LinkedList. Therefore, user will do add search remove etc. operations). but the problem it only works when i create classes in IDE myself and copying the code into them and run them. so i need a code which will do it itself!. you will say i am working on a silly project : D. but i wonder if is there any code samples like this_?. and i hope i explained my problem correctly. so thanks anyway : ).
|
|
|
|
|
quartaela wrote: you will say i am working on a silly project
No, you said that.
|
|
|
|
|
well ok you are right : ). i will delete the topic .
|
|
|
|