Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860
Hogwarts School Of Computer Science - Huben's Wiki

Hogwarts School Of Computer Science

From Huben's Wiki
Jump to: navigation, search
Line 91: Line 91:
 
* Bonus if you can find how to make it hop instead of smooth scrolling.
 
* Bonus if you can find how to make it hop instead of smooth scrolling.
 
* Double bonus if you can do it the right way.
 
* Double bonus if you can do it the right way.
 +
 +
Here is another incantation:
 +
 +
<pre>
 +
//  This program shows simple graphics in a window.
 +
 +
import java.awt.*;
 +
import javax.swing.*;
 +
 +
public class HelloGraphics extends JPanel
 +
{
 +
public void paintComponent(Graphics g)
 +
{
 +
super.paintComponent(g);  // Call JPanel's paintComponent method
 +
                          //  to paint the background
 +
g.setColor(Color.RED);
 +
 +
// Draw a 150 by 45 rectangle with the upper-left
 +
// corner at x = 25, y = 40:
 +
g.drawRect(20, 40, 150, 45);
 +
 +
g.setColor(Color.BLUE);
 +
 +
// Draw a string of text starting at x = 60, y = 25:
 +
g.drawString("Hello, Graphics!", 55, 65);
 +
}
 +
 +
public static void main(String[] args)
 +
{
 +
JFrame window = new JFrame("Graphics Demo");
 +
// Set this window's location and size:
 +
// upper-left corner at 300, 300; width 200, height 100
 +
window.setBounds(300, 300, 200, 150);
 +
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 +
 +
HelloGraphics panel = new HelloGraphics();
 +
panel.setBackground(Color.WHITE);  // the default color is light gray
 +
Container c = window.getContentPane();
 +
c.add(panel);
 +
 +
window.setVisible(true);
 +
}
 +
}
 +
</pre>
 +
 +
This incantation has not followed the rules of the curly braces, but will still work.

Revision as of 15:48, 10 September 2012

Personal tools
translate