Ezzaral commented: hehe - I was thinking the same thing! +0
jonsca commented: 0 rep to counter your other 0 rep :) +0
Don't use Eclipse's auto complete as a substitute for documentation and research. For example, did you read this?
Nice first post. Hope you have a good time with that program that the OP said doesn't work that was written years ago.
what are they focusing on ccna this time ??? i heard its about subbneting this time in the exam !! im planin to do it tomrw though ...let me know ...anyone anyone
It's purely focused on grammar. You don't stand a chance.
Write a scheduling algorithm for the OS.
Down vote my post all you want, but you shouldn't expect hand holding - being pointed towards the thousands of resources available online about remainders should have been enough. And next time you get help, please be considerate enough to follow our rules, such as posting in code tags and marking the thread solved when you solve your problem.
Look up what a remainder is on google. Our job isn't to teach basic math.
I don't know why your call to super.paintComponent(g) is the second call in your method; I was always taught that a call to super has to be the first call in your method as it says here. I could be wrong and this might be a special case, but I don't think so. And you don't need to be constantly adding the JPanel back; add it once, then simply clear the screen when you need to (which is what super.paintComponent(g) does if I remember correctly). Anyway, the code you gave me wouldn't compile or even come close, but this small sample works:
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class SectionPage extends JPanel implements MouseListener{
JFrame tempComponent;
boolean colorWhite;
public static void main(String[] args){
new SectionPage();
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
if (colorWhite){
g2.setColor(Color.WHITE);
} else g2.setColor(Color.BLACK);
g2.fillRect(100, 100, 50, 50);
}
public void display( Graphics2D g ) {
}
public SectionPage() {
tempComponent = new JFrame("Test Graphics");
tempComponent.add(this);
tempComponent.setSize(500,500);
tempComponent.setVisible(true);
this.addMouseListener(this);
colorWhite=true;
setBackground(Color.white);
}
@Override
public void mouseClicked(MouseEvent arg0) {
// TODO Auto-generated method stub
if (colorWhite) colorWhite=false;
else colorWhite=true;
repaint();
}
@Override
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method …
CODE TAGS. Use them. Read the rules.
If you want to read from a file and count how many characters are in it, use FileReader or FileInputStream, not InputStream, since you cannot open a File with InputStream. Then use a while loop like they said, incrementing a counter for each byte you read. The final value of the counter is how many characters were in the file.
Also, note that FileInputStream is not recommended for reading characters. I'm not sure why, but a wild guess would be that it deals with the fact that chars in Java are 16 bits, but chars on your computer might be represented as 8 bits. This might be completely wrong, feel free to do some research on your own.
[FileReader] Convenience class for reading character files. The constructors of this class assume that the default character encoding and the default byte-buffer size are appropriate. To specify these values yourself, construct an InputStreamReader on a FileInputStream.
http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html
Read through that tutorial, it should be helpful to you. Courtesy of a post by peter budo that I found by searching daniweb.