Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!

danesh far

Greenhorn
+ Follow
since Nov 25, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by danesh far

Hi
How can I make a pause in my program in java?Could you please give me an example.
13 years ago
Hi,I have a class and when I compile the class I get this message but I could not undrestand it :

Note: C:\j2\bin\BattleStar.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.

Tool completed successfully






public class BattleStar extends JFrame implements Runnable, MouseListener
{
//Data Fields

public void BattleStar( ){
...}
public void start( ){
...}

public void stop( ){
...}

public void run( ) {
... }

public void step( )
{..
repaint();
... }

public void mouseClicked (MouseEvent theEvent) {
...}

public void mouseEntered (MouseEvent theEvent) { }
public void mouseExited (MouseEvent theEvent) { }
public void mousePressed (MouseEvent theEvent) { }
public void mouseReleased(MouseEvent theEvent) { }

public final synchronized void update(Graphics g)
{
...}

public void paint(Graphics g)
{... }

}
13 years ago
Hi,could you please let me know what the following ststement says:

theDX = theDX > MAX_V ? MAX_V : theDX;
[ December 09, 2004: Message edited by: Ernest Friedman-Hill ]
13 years ago
Hi,
I am trying to simulate a footbal game which is a part of my project in the field of Opponent Modeling and its application in robocups.As you know we have 22 players and at any time they have to do something based on the their duty and position such as catch the ball ,shoot the ball and ...
How could I do that in JAVA.I already simulate a player and a goolkeeper is using Thread technic.In this simulation first goalkeeper moves and according to its position, the player move. What should I do if I have 23 different agents (22 players +ball)in a game and if everyone have to make a decision based on their mind (using some local information.Is there anyone who is interested to contribute in this project ?
13 years ago
Hi,two questions
Since I am writting an application ,need a place to send the output there to check the result and also scroll.I was trying to use a JTextArea object (some methods likebut append and insert)but it did not work because it does not append the outputs vertically.I need something like println which can send the output to it but able to scroll (vertically) there.
Does anybody know about a free JAVA debugger?
13 years ago
Hi,
I am writing an application to show a scroll panel attached to a text area
but it does not appear on the screen. If remove the lines

JScrollPane scrollText = new JScrollPane(textArea);
contentPane.add(scrollText);
and add
contentPane.add(textField)
It appears but without scroll?.


import javax.swing.*;
import java.awt.*;

class TestFrame extends JFrame {
private JTextArea textArea;

public static void main(String[] args) {
TestFrame frame = new TestFrame();
frame.setVisible(true);
}

public TestFrame( ) {

setSize ( 700, 400 );
setLocation ( 5, 5 );

Container contentPane = getContentPane();
contentPane.setBackground(Color.white);
contentPane.setLayout(null);

textArea = new JTextArea();
textArea.setEditable(false);
textArea.setBounds(350, 50, 100, 135);
textArea.setBorder(BorderFactory.createLineBorder(Color.red));
JScrollPane scrollText = new JScrollPane(textArea);
contentPane.add(scrollText);

}



}
13 years ago
Hi,
I am writing a simple animation application.It is supposed to countinuosly shows a word on the screen and every 30 ms change the location of the word according to a formula.
I thought that it had to worked automatically using Thread but after showing the word on the screen for the first time , it do not change the position of the word.Actually I was expected to have from Main() -> Start() -> Run() (updating position and also the screen using repant())if I add ex.start() at the end of the main() everything works but the background do not update.
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ November 28, 2004: Message edited by: Dirk Schreckmann ]
13 years ago
I am writing an application to show a text and measure different aspect of it as follows:

// Simple animation with Java
import java.awt.*;
import javax.swing.*;
public class AnimateEx extends JFrame {

String theString = "Boing!!!";
private int stringTop, stringBottom, stringWidth;


public void paint(Graphics g)
{
g.drawString(theString, 100,200);
}
public AnimateEx()
{
setSize(770,420);
setFont( new Font("TimesRoman", Font.BOLD+Font.ITALIC, 24));
setBackground(Color.yellow);
setForeground(Color.red);
Graphics g=this.getGraphics();
FontMetrics fm= g.getFontMetrics();
stringWidth = fm.stringWidth(theString);
stringTop = fm.getAscent();
stringBottom = fm.getDescent();

}

public static void main(String[] args){
AnimateEx ex= new AnimateEx();
ex.setVisible(true);
}
}

When I run the application without the followin lines in the constructor :
FontMetrics fm= g.getFontMetrics();
stringWidth = fm.stringWidth(theString);
stringTop = fm.getAscent();
stringBottom = fm.getDescent();


(which I add to get some text measure )it works well but after adding those lines I got this error (no error during compile but have it when run):

Exception in thread "main" java.lang.NullPointerException
at AnimateEx.<init>(AnimateEx.java:20)
at AnimateEx.main(AnimateEx.java:28)
13 years ago
An instance data value is used to maintain information specific to individual instances. For example, each Account object maintains its balance.
A class data value is used to maintain information shared by all instances or aggregate information about the instances.

For example, minimum balance is the information shared by all Account objects, whereas the average balance of all Account objects is aggregate information.
An example of an instance data value:
Three Account objects possess the same data value current balance, but the actual dollar amounts differ.

Classs Test {
private static int minimu_balance=100; //class data
private int current_Balance; //instance data
.
.
.
}


}
13 years ago
I�ve written the following class ShowImage to put image on the screen but what I got was a blank window.Why could not I see the image on the screen?



import javax.swing.*;
import java.awt.*;


public class ShowImage extends JFrame {

public static void main(String[ ] args) {

ShowImage si=new ShowImage();
Graphics g=si.getGraphics();
Image im;
Toolkit T=si.getToolkit();
im=T.getImage("Jumbo.jpg");
g.drawImage(im, 50,50,si);
}
public ShowIm(){
this.setSize(770, 420);
this.setVisible(true);
}
}
13 years ago
I�ve written the following class ShowImage to put image on the screen but what I got was a blank window.Why could not I see the image on the screen?


import javax.swing.*;
import java.awt.*;


public class ShowImage extends JFrame {

public static void main(String[ ] args) {

ShowImage si=new ShowImage();
Graphics g=si.getGraphics();
Image im;
Toolkit T=si.getToolkit();
im=T.getImage("Jumbo.jpg");
g.drawImage(im, 50,50,si);
}
public ShowIm(){
this.setSize(770, 420);
this.setVisible(true);
}
}
13 years ago
Hi,
We use a class to creat different objects.These objects have some common aspects which are same in all of the objects.For example the minimum amount of money for opening an account is same for all of the objects.This is an class varible but objects balance is a instance variable since it is different for different object so it is an instance variable.You can declear a class variable as a instance variable but when you want to change it you have to change it in all of objects.
13 years ago
I�ve written the following class ShowImage to put image on the screen but what I got was a blank window.Why could not I see the image on the screen?


import javax.swing.*;
import java.awt.*;


public class ShowImage extends JFrame {

public static void main(String[ ] args) {

ShowImage si=new ShowImage();
Graphics g=si.getGraphics();
Image im;
Toolkit T=si.getToolkit();
im=T.getImage("Jumbo.jpg");
g.drawImage(im, 50,50,si);
}
public ShowIm(){
this.setSize(770, 420);
this.setVisible(true);
}
}
13 years ago
Thank you for your answer but it is still unclear to me why we need a link between AWT components and native implementations of those components.
13 years ago
I am a java beginner.I am trying to write a program to show some images on the screen and found one but could not undrestand this line :

Toolkit T=this.getToolkit();

what is the role of T object?
13 years ago