bibiki 18 Posting Whiz

I see the post is old already but I am sure info remains relevant so I wanted to add something: I absolutely agree with Smartx21 regarding MALWAREBYTES. I used it and it worked excelently - one can get it for free online. In addition, I used CCleaner. After having used these two, my computer started working very faster.

bibiki 18 Posting Whiz

@sergb, thanks a whole lot. that worked ideally.
@chrishea, thanks for taking your time. I do have the manual but find it difficult to understand. thanks anyways!

bibiki 18 Posting Whiz

what's up?

I have the following php code:

<?php

//chose the file
$file = 'C:\Program Files\EasyPHP-5.3.2i\www\test\dump.txt';

//open the file in writeable mode
$data = fopen($file, 'w');
//add the new element to it
fwrite($data, $data.'gagi');
//close the file
fclose($data);
?>

I expect it to keep whatever is in the file and add 'gagi' (without quotes) to the file i referenced in $file. however, what it does is: it deletes everything in the file and puts in it the following: "Resource id #3gagi".

specifically, what I am trying to do is build a script that keeps track of when people sign in on a site (or network) that I control. something like a log file.

any help is much appreciated!

P.S. I also tried reading the file as an array, and then use array_push(), but it aint worked either.

bibiki 18 Posting Whiz

quuba, I just tried your code. it works, but with a minor defect. teh ball moves too slowly. I set the Thread.sleep to 0 (Thread.sleep(0)) and it worked just fine. however, I tried removing entirely the try-catch and the app failed to work. I would appreciate some explanation on what makes the try-catch necessary and a little more insight onto what is going on 'under the hood'. if that's too much, never mind. thanks alot for your answer. I surely will analyze it further.

bibiki 18 Posting Whiz

@moutanna:
I copied and pasted your code. the ball remains static. it won't move. the class I posted above, with minor modifications (adding a repaint inside paintComponent), works fine. but if I build the app in a single file, it works fine without a repaint in paintcomponent. this is the problem.

bibiki 18 Posting Whiz

I do not get any error. The reults is not what I expect it to be. I expect to see a ball that moves up and down -- the lower down it is, it grows bigger, and the higher up it is, it grows smaller, thus looking as if it was bouncing and I was watching it from above. Instead, what I get is a ball that does not bounce. If you've copied the classes, you only need to do a few changes in your countroller class (Bully) to see the effect.

add a repaint(); statment in paintcomponent.
instatiate the following methods out of the paintcomponent:
Testi aa = new Testi();
Tooopi bb = new Tooopi();

however, in this case, the background of the picture you see is repainted all the time. I wonder if there is a way to reach the effect, using separate classes, without a repaint inside paintComponent.

on the other hand, when I built the application using one single class, I built it without a repaint inside my paintComponent, which I suppose is more efficient use of memory resources.

bibiki 18 Posting Whiz

@darkagn.
I added a System.out.println(variable); statment inside my Tooopi class and verified that the tupi class is only being ran once. which means that the variables inside the class remain the way they are when initialized resulting in a static ball.

bibiki 18 Posting Whiz

@zyaday:
I just posted my third class Testi, as well. it paints the squared bull's eye.

bibiki 18 Posting Whiz

hey there. I have been struggling with separating classes in java and figuring out what methods go in what classes. when i build my apps in one file, i do them right, but when i try to separate classes, i mess up. like for example:
I have these two classes:
1.

import javax.swing.*;
import java.awt.*;
    public class Bully extends JPanel{
       public Bully(){
         JFrame korniza = new JFrame();
         korniza.getContentPane().add(this);
         korniza.setSize(500, 500);
         korniza.setTitle("Bull's Eye");
         korniza.setVisible(true);
      }
   
       public void paintComponent(Graphics g){
 	      g.setColor(Color.yellow);
         g.fillRect(0, 0, 500, 500);
         //Rrathet(g);
			
			Testi aa = new Testi();
			aa.paintsquares(20, 20, 20, 400, g);
			Tooopi bb = new Tooopi(); 
			bb.tupi(g);
      }
   		
             }
   
       public static void main(String[] args){
         new Bully();
		
      }
   }

and 2.

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

public class Tooopi extends JPanel{
private int x_posita = 215;
private int y_posita = 215;
private int diametri = 10;
private int a = -1;
private int b = 3;
private int c = 2;

/*
public Tooopi(){
JFrame korniza = new JFrame();
korniza.getContentPane().add(this);
korniza.setSize(550, 550);
korniza.setVisible(true);
korniza.setTitle("toooopi");
}

public void paintComponent(Graphics g){
g.setColor(Color.white);
g.fillRect(0, 0, 550, 550);
toopi(g);
}*/
public void tupi(Graphics g){
g.setColor(Color.blue);
g.fillOval(x_posita, y_posita, diametri, diametri);
x_posita = x_posita + a;
y_posita = y_posita + b;
diametri = diametri + c;
if(y_posita == 215 || y_posita == 335){
a = -a;
b = - b;
c = -c;
}
 try { Thread.sleep(20);}
catch (InterruptedException e) { }
repaint();
}

/*public static void main(String[] args){
new Tooopi();
}
*/
}

my third class is Testi, it paints …

bibiki 18 Posting Whiz

eyah it does. thanks for your help. i have another problem now: my vcl plays movies in linux, but with no colors. do you have any idea what's wrong?

bibiki 18 Posting Whiz

@xlphos:
I already installed ubuntu. read on for what the roblem happened to be.
@areopaq: I installed it because I want to learn.
when I burned ubuntu iso file in a cd, I used infraRecorder, at the max speed... that's why it did not work. when I burned the file in another cd, using infraRecorder's 6x speed (it reported that it is using 8x speed) the cd worked fine. you might need this for advicing others. cheers!!!

bibiki 18 Posting Whiz

hey there,
I am trying to install ubuntu 9.10 in my pc. as instructed, I burned the iso file I took from ubuntu site into a cd and restarted my computer. after that, I was promted for the language I want to use. I chose english, then when offered four or five option, I chose Install Ubuntu. after this step, I wait for a while, and then I see a message saying I/O Error. when I view the content of the cd with windows, everything works just fine... so I guess my cd is not damaged. anyone have any idea what could be causing this. I also read that burning the iso file onto an 80-minute cd is preferable, so I complied with that too. any help is greatly appreciated.

bibiki 18 Posting Whiz

@BestJewSinceJC
I noticed that after I posted.

@HelloMe: it does matter. however, i got the code compiling leaving the main method empty, and rewriting brackets. try that!

bibiki 18 Posting Whiz

you have name = CharSet.next()
perhaps what you need is CharSet.nextInt()

bibiki 18 Posting Whiz

one thing you might want to consider is that when you built up the list of weather options from which to chose, you created two separate input lists. as a result, one may select both, bad and good wether. in that case, the isset($_GET would return true even if both are selected, which would, i assume, give out a result, and that's not what you want.

the form should rather have one input for weather, with two possible values. what you have is:

<input type="radio" name="good" />
Good Weather Condition<br />
<input type="radio" name="bad" />

note that you have two inputs, one good, one bad. you should have one input (one name for both), and two values (one for each).
then, when you do your if-test, do not use the isset(). rather, test whether $_GET equals one of the values. hope that helps!

bibiki 18 Posting Whiz

try this: string convert_uuencode ( the coded version of your pic/text )

I took from php.net manual. I hope that to be of any help!

update: my bed!!

bibiki 18 Posting Whiz

I am new to this forum, and out of desire to contribute, I want to let you know that the best way to ask help is providing some code you have written. otherwise, you won't get other people do it for you. I wrote the code for two people and I was advised not to do that anymore, so I dont do it. but, write some code, do your best, and Im sure you will get help. I know I did get some very valuable help here.

bibiki 18 Posting Whiz

@gerbil
I wrote both files. in the first file, I put spaces between "-" and "s" (or c). soon as I removed the spaces, the code worked. But, hovering over the little System Shutdown window made the countdown stop. otherwise, I took the code from some videos in youtube; I wrote the code, but took it from different people.

@Glenn:
I did the shutdown/? in cmd. I got the usage info. that means the shutdown is available through the path, then.
after that, I replaced "-" with "/" as I think you suggested I do. The behaviour of the file was the same. It would start, but hovering over it would make the countdown stop. I guess the problem that persists is how to make sure the countdown does not stop after my sister tries to close the little window :)

and lastly, a few years ago, I would have this system shutdown message appear around 20 minutes after each time I'd turn my computer on, and it would shut down in four minutes. a friend at the time told me that my hard disk had some deffect cuasing that to happen. now I think he was wrong. I must have had some batch file somehwere installed, right? although, he kept formmatting the disk continuously, but the problem persisted!!!

bibiki 18 Posting Whiz

@JavaAddict:
I shall not give complete codes anymore. I did the same in another post and I was told not to do that anymore. accept my appolagy.
@Aisha:
you are welcome, although you won't get hat anymore from me :P

bibiki 18 Posting Whiz

@BestJewSinceOJ
I'm sorry. I shall refrain from solving other people's problems in the future. yuo are right, I did not help the person learn I helped him do the homework.

bibiki 18 Posting Whiz
int x = (int)(Math.random()*4) + 104;[

i forgot to declare the x variable in the previous post.
I just discovered the edit button. i won't post no more twice per answer.

bibiki 18 Posting Whiz

use this for generating a random integer between 104 qand 108:

x = (int)(Math.random()*4) + 104;

explanation: the Math.randon() generates a number between 0 and one (including 0 excluding 1). when you multiply the rezult by four, you get any number between zero (inclusive) and four (exclusive). Add to that 1004, and you get a number between 104 and 108. the (int) makes the random to be an int between 0 and 4.

bibiki 18 Posting Whiz

that code is for three months. where you have four, put in 7, and you'll be told the amount after six months.

bibiki 18 Posting Whiz

you can do that without a loop. there is a formula I dont remember. however, here you have the code with the loop.

public class Interest{

public static void main(String[] args){
double x = 0;
for(int i = 1; i<4; i++){
x = (x +100) * 1.00417;
}

System.out.println(x);

}
}
javaAddict commented: Giving code is against the rules -1
masijade commented: The formula doesn't matter as the assignment was, probably, specifically for a loop. That said, what does the OP learn when you do the work. -2
bibiki 18 Posting Whiz

I have the code that works:

//I took out your first line as it seems unnecessary. plus, it did not work with the line in the code
//package windchilltemperature;

import java.util.Scanner;


public class WindChillTemp {

    public static void main(String[] args) {
        double OutsideTemperature = -58;
//here, in the following two lines, I converted the first and second
//arguments to integers and then I multiplied them with 1.0 to get doubles
        double ta = new Integer(args[0]).intValue()*1.0;
        double v = new Integer(args[0]).intValue()*1.0;
        //double speed; this variable is unneccesary as you do not us it anywhere

        double WindChillTemperature = 35.74 + (0.6215 * ta) - 35.75 *Math.pow(v,0.16) + 0.4275 * ta * Math.pow(v, 0.16);

//        Scanner input = new Scanner(System.in);
        System.out.print("Enter a temperature in F between -58F and 41F");
        System.out.print("Enter Wind Speed greater or equal to 2");
        System.out.println("The Wind Chill Temperature is" + WindChillTemperature);

}
}

the code i provided works, but only if you run it through command line.
you had excess lines that stopped the code from working, in addition, when you get input through command line, they are initially in the form of string. to manipulate them, you need to convert them in numbers, which is what i did and explained where i did so. I hope you can make any use out of the code!

bibiki 18 Posting Whiz

hey there. first off, i hope i posted my question in the right forum. second, i thank you in advance for an answer.

i have two short batch files:

1. shutdown - s - c "my message" - t 20

i expect this to shut down my computer in twenty seconds, but the file actually does absolutely nothing. i can't figure out what the problem is. i tried to rearrange the order of s, c and t, but nothing happens. even if i add -f, the file won't work.

2. shutdown -s -f

this file does work, but not the way i expected it would. note that i did not specify the time it should wait before it shuts down my pc but it set the time before shutdown to 30 seconds. ok, i guess there is a default value for it but my greater problem is that if i start the file, the usual little System Shutdown window appears telling me that the system is shutting down. however, if i hover over it with my cursor, the countdown stops, and it never dose its job. besides, i cannot close the little window neither clicking the X button nor throught task manager after hovering over it.

i am aware there are many questions i posed; whatever you answer, i'll learn something as i am very new to these types of things. i am trying to build a shutdown prank to mess with my family …

bibiki 18 Posting Whiz

i shall do that. thanks again. at school, we did not learn about the invokeLater() method, but I shall just copy the code you wrote eariler and study it. take care!

bibiki 18 Posting Whiz

amazing. you seem to be right Ibarowski. I switched the order of my methods inside my constructor method and they now behave properly everytime i run the code. thanks a lot.

bibiki 18 Posting Whiz

i see the frame every time i run the code. but, on some occasions i only see the frame without it's content (in this case the four by four, red and black, chess board painted on a white background). when i say only the frame, i mean a window with gray field in it instead of the content inside paintComponent.

bibiki 18 Posting Whiz

i used eclipse initially, but it crashed... i need to reinstall it. jgrasp is an ide. anyways, don't let me take more of your time. i think ima just switch to a more reliable ide and see if it works better. thanks anyways. take care!

bibiki 18 Posting Whiz

you are most likely right. but, would it be the version of jGRASP i am using. or could it be me computer? and if it is my ide, how do i know that?

bibiki 18 Posting Whiz

oh thanks, but i remain unaware of the reason why it won't work everytime i run it.

bibiki 18 Posting Whiz

hey there, I have the following code:

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

public class TabelaEShahut extends JPanel{
public static void main(String[] args){
new TabelaEShahut();
}
public TabelaEShahut(){
JFrame f = new JFrame();
f.setSize(500, 500);
f.setVisible(true);
f.setTitle("shah");
f.getContentPane().add(this);
}

public void paintComponent(Graphics g){
g.setColor(Color.white);
g.fillRect(0, 0, 700, 700);
g.setColor(Color.red);
g.fillRect(50, 50, 400, 400);
g.setColor(Color.black);
g.fillRect(150, 50, 100, 100);
g.fillRect(350, 50, 100, 100);
g.fillRect(50, 150, 100, 100);
g.fillRect(250, 150, 100, 100);
g.fillRect(150, 250, 100, 100);
g.fillRect(350, 250, 100, 100);
g.fillRect(50, 350, 100, 100);
g.fillRect(250, 350, 100, 100);
}

}

I expected this code to work properly and display a four by four chess board on my screen... and it did, indeed, but the problem is that it does not do so everytime i run the code. i can never know if it is going to output the result or not when i run it. initially, it refused to show the board like twenty times but i kept comparing the code with other files i have that i know to have worked and comipling and running the file in question and it suddenly started working - but not everytime i run it. i was wondering what would the problem be and if there is any way i can prevent such unpredictabilities from occuring. you might need to know that i used jGRASP to compile and run the file.

thanks a lot to anybody that replies and accept my apology for my long explanations.

bibiki 18 Posting Whiz

I see. thanks a lot man. I appreciate your help very much. Have fun and take care.

bibiki 18 Posting Whiz

thanks a lot man. i'm impressed AND confused. the book i am studying with insists that it has a well thought programing style, yet it does have multiple mistakes. and now that you solved my problems, i trust you more than the book i am reading.. i was just wondering if you could direct me on what book should i study with for a better understanding of java.
thanks again.

bibiki 18 Posting Whiz

I have the two following classes (copied from the book i study with):

import java.awt.*; import javax.swing.*;
/** MyWriter creates a graphics window that displays a sentence */
public class MyWriter extends JPanel
{ private int width; // the frame's width
private int height; // the frame's height
private String sentence = ""; // holds the sentence to be displayed
private int x_position; // x-position of sentence
private int y_position; // y-position of sentence
/** Constructor MyWriter creates the Panel
* @param w - the window's width
* @param h - the window's height */
public MyWriter(int w, int h)
{ 
RepaintManager.currentManager(this).setDoubleBufferingEnabled(false);
width = w;
height = h;
x_position = width / 5; // set the sentence's position
y_position = height / 2;
JFrame my_frame = new JFrame();
my_frame.getContentPane().add(this);
my_frame.setTitle("MyWriter");
my_frame.setSize(width, height);
my_frame.setVisible(true);
}
/** paintComponent paints the panel
* @param g - the ``graphics pen'' that draws the items */
public void paintComponent(Graphics g)
{ g.setColor(Color.red);
g.drawString(sentence, x_position, y_position);
}
/** writeSentence displays a new string in the window
* @param s - the sentence to be displayed */
public void writeSentence(String s)
{ sentence = s;
this.repaint(); // indirectly forces paintComponent to execute
}
/** positionSentence redisplays the existing sentence in a new position
* @param new x - the new horizontal starting position
* @param new y - the new vertical starting position */
public void positionSentence(int new_x, int new_y)
{ x_position = new_x;
y_position = new_y;
this.writeSentence(sentence); // force a rewrite of the existing sentence …
bibiki 18 Posting Whiz

Ibarowsky, I've got another question: is it ok if i ask you?

bibiki 18 Posting Whiz

thanks again. it worked. i inserted your line inside my constructor method. thanks a lot.

bibiki 18 Posting Whiz

pardon me. thanks a lot.

i guess i should just add that line, but where? inside the main method, inside paintComponent? where?

bibiki 18 Posting Whiz

thanks for the reply, it is ok as it does compile, but it won't output what i intend it to output. i hope you or someone else come up with the solution.

bibiki 18 Posting Whiz

Hey there,
I have the following code:

public void paintComponent(Graphics d){
                  int gjeresia_e_kornizes = 800;
                  int lartesia_e_kornizes = 800;
                  d.setColor(Color.white);
                  d.fillRect(0, 0, gjeresia_e_kornizes, lartesia_e_kornizes);
                  d.setColor(Color.red);
                                    
						d.fillOval(105, 70, 250, 350);
try { Thread.sleep(2000); }
catch (InterruptedException e) { }
                  d.setColor(Color.blue);
                  d.fillOval(150, 170, 50, 20);
                  d.fillOval(270, 170, 50, 20);
try { Thread.sleep(2000); }
catch (InterruptedException e) { }
                  d.setColor(Color.black);
                  d.drawLine(235, 200, 210, 310);
try { Thread.sleep(2000); 
catch (InterruptedException e) { }
                  d.drawLine(210, 310, 270, 310);
                  d.drawLine(270, 310, 250, 290);}
try { Thread.sleep(2000); 
catch (InterruptedException e) { }
                  d.drawLine(205, 340, 275, 340);
                  d.drawLine(205, 340, 190, 360);
                  d.drawLine(275, 340, 290, 360);
                }

I expect the code above to draw lines and ovals with 2-second interuptions for each time the try-catch part appears in the code. However, what I get is:
first the frame object appears with nothing in it (i see my jGRASP behind the frame). after 8 seconds (that is four times two seconds - 2 seconds for each try-catch), all the lines and ovals, which make a face, appear at once.

I am really curious to know if there is any way to reach the effect I am aming at using this kind of simple code. besides, there is a similar assignment in a java book. the only difference is the types of shapes I am supposed to use. thanks in advance for any eventual help.

bibiki 18 Posting Whiz

hey Atli,
thanks man. that was awsome. as I said in the first post, I am only exercising, and in an actual project I would take your advice and use the for loop. thank you very much.

bibiki 18 Posting Whiz

thanks darkgan for your reply.
however, the code ought to work without the body tags. what the problem seems to be is that the while loop is a test on a boolean variable, which causes the inner (nested) while loop run only once... thank's for your reply, anyways.

bibiki 18 Posting Whiz

hey there. I am new to php and just out of curiosity I am trying to build an html table using nested while loops. I expect the following code to produce a table, but it is not doing so.

<html>
<table border="1">
<?php
$r=1;
$rows = 5;

$c = 1;
$columns = 5;

while ($r <= $rows) {
	echo "<tr>";
		while ($c<=$columns) {
			echo "<td>d</td>";
			$c++;}
	echo "</tr>";
	$r++;
	}

?>
</table>
</html>

I wondered if anyone would know what's the problem with this code. Otherwise, when I substitute for loops in each case of while loops I get tables but with only reduced number of rows and columns. if I ask it to give out 5 rows, for example, it only returns 3.

Remember, I am only interested in using a while loop inside another while loop... just for exercising... any help is much appreciated.