Sabtu, 14 Maret 2026

My First Java - GTGE

 


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package gtge_test;
import com.golden.gamedev.Game;
import com.golden.gamedev.GameLoader;
import com.golden.gamedev.gui.TLabel;
import com.golden.gamedev.gui.toolkit.FrameWork;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.Color;
import java.awt.Dimension;



public class SimpleGTGEGame extends Game {

    // Main entry point for the game
    public static void main(String[] args) {
        GameLoader loader = new GameLoader();
        loader.setup(new SimpleGTGEGame(), new Dimension(300,200), false);
        loader.start();
    }

    // Initialize game resources (images, sounds, etc.)
    @Override
    public void initResources() {
        // Load an image, for example:
        // playerImage = bsLoader.get  Image("assets/player.png"); 
        // This is where you would load all your assets using bsLoader
        System.out.println("Initializing resources...");
    }

    // Update game logic (runs in a loop)
    @Override
    public void update(long elapsedTime) {
        // Handle input, move objects, check collisions here
        if (bsInput.isKeyDown(KeyEvent.VK_SPACE)) {
            System.out.println("Space key pressed!");
        }
    }

    // Render game elements to the screen
    @Override
    public void render(Graphics2D g) {
        // Draw the background
        g.setColor(Color.BLACK);
        g.fillRect(0, 0, getWidth(), getHeight());

        // Draw game objects
        g.setColor(Color.WHITE);
        g.drawString("Welcome to GTGE!", 100, 100);
    }
}



GTGE

 https://github.com/dveag/naveGame

https://janbakerblogs899.blogspot.com/2013/03/animated-sprite-2-dimensions-with-gtge.html?m=1


https://nwcourses.github.io/oop/topic5.html


// Conceptual example of animation in a GTGE game

// Note: This requires the GTGE library to run

import com.golden.gamedev.Game;

import com.golden.gamedev.object.Animation;

import com.golden.gamedev.object.Sprite;

import java.awt.Graphics2D;


public class MyGame extends Game {

    Animation anim;

    Sprite sprite;


    public void initResources() {

        // Load sprite sheet

        BufferedImage[] images = getImages("resources/player.png", 4, 1);

        // Create animation (4 frames, 100ms delay)

        anim = new Animation(images, 100);

        // Create sprite

        sprite = new Sprite(anim, 100, 100);

    }


    public void update(long elapsedTime) {

        // Update animation and sprite

        anim.update(elapsedTime);

        sprite.update(elapsedTime);

    }


    public void render(Graphics2D g) {

        // Draw sprite

        sprite.render(g);

    }

}


import com.golden.gamedev.Game;

import com.golden.gamedev.GameLoader;

import com.golden.gamedev.object.AnimatedSprite;

import com.golden.gamedev.object.SpriteGroup;

import java.awt.Graphics2D;

import java.awt.image.BufferedImage;


public class AnimasiGTGE extends Game {


    AnimatedSprite player;

    SpriteGroup playerGroup;


    @Override

    public void initResources() {

        // 1. Muat gambar animasi (contoh: walk1.png, walk2.png, walk3.png)

        BufferedImage[] images = new BufferedImage[]{

            getImage("images/walk1.png"),

            getImage("images/walk2.png"),

            getImage("images/walk3.png")

        };


        // 2. Buat AnimatedSprite dengan array gambar

        player = new AnimatedSprite(images, 100, 100);

        

        // 3. Atur kecepatan animasi (frame per detik)

        player.setAnimationTimer(100); 

        player.setLoopAnim(true); // Animasi berulang


        playerGroup = new SpriteGroup("Player Group");

        playerGroup.add(player);

    }


    @Override

    public void update(long elapsedTime) {

        // Update animasi

        player.update(elapsedTime);

    }


    @Override

    public void render(Graphics2D g) {

        // Gambar sprite

        playerGroup.render(g);

    }


    public static void main(String[] args) {

        GameLoader game = new GameLoader();

        game.setup(new AnimasiGTGE(), new java.awt.Dimension(640, 480), false);

        game.start();

    }

}

import com.golden.gamedev.Game;
import com.golden.gamedev.object.Sprite;
import com.golden.gamedev.object.AnimatedSprite;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

public class AnimasiGame extends Game {

    AnimatedSprite player;
    BufferedImage[] frames;

    @Override
    public void initResources() {
        // 1. Memuat gambar animasi (contoh: karakter berjalan)
        frames = getImages("resources/karakter.png", 3, 1); // 3 kolom, 1 baris
        
        // 2. Membuat AnimatedSprite
        player = new AnimatedSprite(frames, 100, 100);
        player.setAnimationFrame(0); // Mulai dari frame pertama
        player.setAnimationTimer(200); // Kecepatan animasi (milidetik)
    }

    @Override
    public void update(long elapsedTime) {
        // Logika pergerakan animasi
        player.update(elapsedTime);
        player.move(0.1); // Bergerak sedikit setiap frame
    }

    @Override
    public void render(Graphics2D g) {
        // Menggambar animasi ke layar
        player.render(g);
    }

    public static void main(String[] args) {
        // Menjalankan game
        // GameLoader game = new GameLoader();
        // game.setup(new AnimasiGame(), new Dimension(640,480), false);
        // game.start();
    }
}
3. Implementasi Animasi dengan Tlabel (Teks)
Jika yang dimaksud adalah animasi teks (misalnya teks berkedip), Anda bisa memanipulasi TLabel dalam metode update.
java
import com.golden.gamedev.object.font.SystemFont;
import com.golden.gamedev.object.TLabel;

// Di dalam kelas Game
TLabel titleLabel;
long timer;

public void initResources() {
    titleLabel = new TLabel("MENU UTAMA", new SystemFont());
    titleLabel.setLocation(100, 100);
}

public void update(long elapsedTime) {
    timer += elapsedTime;
    
    // Animasi teks berkedip setiap 500ms
    if (timer > 500) {
        if (titleLabel.getText().equals("")) {
            titleLabel.setText("MENU UTAMA");
        } else {
            titleLabel.setText("");
        }
        timer = 0;
    }
}

public void render(Graphics2D g) {
    titleLabel.render(g);
}
4. Poin Penting Penggunaan
getImages(String path, int col, int row): Digunakan untuk memecah gambar spritesheet menjadi array frame animasi.
AnimatedSprite: Subclass dari Sprite khusus untuk animasi yang memudahkan pengaturan frame dan kecepatan.
update(long elapsedTime): Harus memanggil update animasi agar frame berubah seiring waktu. 
jurnalmahasiswa.com
jurnalmahasiswa.com
 +1
GTGE sangat cocok untuk pemula yang ingin memahami konsep dasar pergerakan sprite dan animasi di Java. 
Neliti
Neliti
pembuatan game personal computer “wizan fighter” - Neliti
Java Programming Language with Library GTGE. The authors also use the Golden T. Game Engine (GTGE) a cross-platform game programming library using java.

Neliti
Animasi Objek 3D Bergerak Menggunakan Java
Abstrak − Artikel ini akan membahas hasil review kami mengenai Implementasi animasi objek bergerak berbasis Java. Penelitian ini mengeksplorasi teknik ...

jurnalmahasiswa.com
Java Game Development with GTGE in NetBeans | PDF - Scribd
Keyword: GTGE, Java Game, Sprite game, java2D, Animation Game. 3 1. PENDAHULUAN. Game-game Java yang beredar dimasyarakat belum begitu banyak hasil karya atau

Scribd

RANCANG BANGUN GAME COLLEGE STORY MENGGUNAKAN ...
Game Engine (GTGE). GTGE merupakan sebuah ... pemograman Java (Java Library). (c). Muchlas Iman ... animasi pembuka yang muncul. (3) Credits, maksud ...

ns1.unaki.ac.id
AI dapat membuat kesalahan, jadi periksa kembali responsnya


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

public class AnimatedButton extends JFrame {
    private JButton button;
    private int x = 0;
    private Timer timer;

    public AnimatedButton() {
        setTitle("Animated Button");
        setSize(400, 200);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLayout(null); // Used for absolute positioning

        button = new JButton("Move Me!");
        button.setBounds(x, 50, 100, 30);
        add(button);

        // Timer fires every 10ms to move the button
        timer = new Timer(10, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                x += 1;
                if (x > getWidth()) {
                    x = -100; // Reset position
                }
                button.setLocation(x, 50);
            }
        });
        timer.start();
        setVisible(true);
    }

    public static void main(String[] args) {
        new AnimatedButton();
    }
}


import com.golden.gamedev.Game;
import com.golden.gamedev.object.Animation;
import com.golden.gamedev.object.Sprite;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

public class AnimationExample extends Game {

    Sprite player;
    Animation playerAnimation;

    @Override
    public void initResources() {
        // 1. Load your frames (Assume player1.png, player2.png exist)
        BufferedImage[] frames = new BufferedImage[2];
        frames[0] = getImage("player1.png");
        frames[1] = getImage("player2.png");

        // 2. Create Animation (frames, delay/speed, repeat)
        playerAnimation = new Animation(frames, 100, true);

        // 3. Create Sprite
        player = new Sprite(playerAnimation);
        player.setLocation(100, 100);
    }

    @Override
    public void update(long elapsedTime) {
        // 4. Update the sprite/animation
        player.update(elapsedTime);
    }

    @Override
    public void render(Graphics2D g) {
        // 5. Render the sprite
        player.render(g);
    }
}


import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class OpeningLabelAnimation {
    public static void main(String[] args) {
        JFrame frame = new JFrame("Label Opening Animation");
        JPanel panel = new JPanel(null); // Null layout for manual positioning
        
        JLabel label = new JLabel("Opening...");
        label.setOpaque(true);
        label.setBackground(Color.CYAN);
        label.setHorizontalAlignment(SwingConstants.CENTER);
        
        // Initial state: small and invisible
        label.setBounds(100, 100, 0, 0); 
        panel.add(label);
        frame.add(panel);
        
        frame.setSize(400, 400);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);

        // Animation Timer: Increases size every 10ms
        Timer timer = new Timer(10, new ActionListener() {
            int width = 0;
            int height = 0;
            @Override
            public void actionPerformed(ActionEvent e) {
                if (width < 200) {
                    width += 2;
                    height += 1;
                    label.setSize(width, height);
                } else {
                    ((Timer)e.getSource()).stop(); // Stop when fully open
                }
            }
        });
        timer.start();
    }
}

// Conceptual example of animation in a GTGE game
// Note: This requires the GTGE library to run
import com.golden.gamedev.Game;
import com.golden.gamedev.object.Animation;
import com.golden.gamedev.object.Sprite;
import java.awt.Graphics2D;

public class MyGame extends Game {
    Animation anim;
    Sprite sprite;

    public void initResources() {
        // Load sprite sheet
        BufferedImage[] images = getImages("resources/player.png", 4, 1);
        // Create animation (4 frames, 100ms delay)
        anim = new Animation(images, 100);
        // Create sprite
        sprite = new Sprite(anim, 100, 100);
    }

    public void update(long elapsedTime) {
        // Update animation and sprite
        anim.update(elapsedTime);
        sprite.update(elapsedTime);
    }

    public void render(Graphics2D g) {
        // Draw sprite
        sprite.render(g);
    }
}

Kamis, 05 Maret 2026

Chinese song title

 #一笑江湖 #韓晴小可愛 #翻唱 #熱門歌曲 #shorts #戲腔 #聞人聽書 #科目三 - 韩晴小迷糊🦖 (1080p, h264)


《我們的邊緣》霧月 Xiaoloulou|愛在墜落之前 #霧月詞 - Xiaoloulou (1080p, h264)


《没出息》加长版,本来应该从从容容,游刃有余。。


《牵丝戏》无声卡宿舍演唱! - 浅影阿 (1080p, h264)


Yan Wu Xie 燕无歇  蒋雪儿 Jiang Xue Er - Chinese, Pinyin & English Translation - Tempest Jun (1080p, h264)


Zhi Xiang He Ni Dao Lao 只想和你到老  Lagu Mandarin Terbaru 2025  Lagu Mandarin Enak Didengar - Deja Music Mandarin (1080p, h264)


一笑江湖 - 姜姜 (1080p, h264)


七叔(葉澤浩) - 半生雪 半生風雪 吹不散歲月留下的眼淚  [動態歌詞 Lyric Video] - Moon Palace (1080p, h264)


光良 《童话》《第一次》《约定》《烟火》  听完耳朵怀孕了


光良 Michael Wong【童話】Official Music Video


再见只是陌生人|我唱到哽咽停了3次,你敢听完吗?


听古风?你总绕不过这首歌 ! - 咻咻满 (1080p, h264)


天上月 人间雪


天上月 人间雪 (伴奏)


宇多田ヒカル「First Love」Music Video(4K UPGRADE)


室友:爱情来得太快就像龙卷风~ - 浅影阿 (1080p, h264)


將進酒 李白| 古風歌曲 |治癒睡前詩詞BGM|水墨動畫版|人生得意須盡歡 莫使金樽空對月 - 清音有夢 (1080p, h264)


想飞的水 Xiang fei de shui (Bagaikan air yang ingin terbang) translate Indonesia


戴佩妮 Penny Tai - 你要的愛 The Love You Want (官方完整KARAOKE版MV) - Timeless Music (480p, h264)


新白娘子傳奇-片尾曲


李嘉嘉 - 天上月 人間雪 (越南鼓版)  天上月 人間雪 歲歲年年不相逢  [動態歌詞 Lyric Video] - Moon Palace (1080p, h264)


桃花笑 Tao Hua Xiao Peach Blossom Smile  小女花不棄 Opening Song - Chinese, Pinyin & English Translation - Tempest Jun (1080p, h264)


梁靜茹 Fish Leong【分手快樂(獨唱版) Break Up Happily (Solo Version)】台視「吐司男之吻2─愛情本事」片尾曲 Official Music Video - 滾石唱片 ROCK RECORDS (1080p, h264)


没出息 (改编版) - 网络歌手 _ Mei Chu Xi - Wang Luo Ge Shou『本来应该从从容容 游刃有余,现在是匆匆忙忙 连滚带爬。』【動態歌詞MV】♪


洛南·仓颉颂 (洛南县仓颉文化推广宣传曲) - 聞人聽書_ (1080p, h264)


洛南·仓颉颂 (洛南县仓颉文化推广宣传曲) - 聞人聽書_ (1080p, h264) (1)


温奕心 - 一路生花 MV OFFICIAL - HAOXIANGNI MUSIC Channel  音樂是我的世界 (720p, h264)


王世堅神曲-沒出息加長版(完整版MV)-王世堅 ft.王搏《2025年最佳洗腦金曲》


科目三,启动!! - 浅影阿 (1080p, h264)


美人画卷 - 聞人聽書_ (1080p, h264)


聞人聽書_ - 虞兮嘆  醉裡挑燈看劍 妾舞闌珊垓 下一曲離亂 楚歌聲四方  [動態歌詞 Lyric Video] - Moon Palace (1080p, h264)


肉麻的调调,你不会知道 - 浅影阿 (1080p, h264)


肖战超燃演绎《天下》 玉树临风本人了《快乐大本营》 Happy Camp【湖南卫视官方频道】 - 湖南卫视芒果TV官方频道  China HunanTV Official Channel (720p, h264)


蔣雪兒Snow.J - 落了白『黃粱一夢 只怕此生難再逢』【Lyrics Video】 - Boba Beats (720p, h264)


虞兮叹 - 聞人聽書_ (1080p, h264)


虞兮叹 (DJ版) - 聞人聽書_ (1080p, h264)


让你从头high到尾的百大神曲!


鄧倫 - 癡情冢丨電影【晴雅集】片尾曲|官方MV - LoveSimple (720p, h264)


阿YueYue - 叹云兮『这是缘,亦是命中最美的相见。』【动态歌词MV】 - 彩云音乐 (1080p, h264)


青城山下白素贞 MV Qingcheng shan Xia Bai Su zhen translate Indonesia


龙醒东方 - 姜姜 (1080p, h264)

Senin, 09 Februari 2026

Minggu, 01 Februari 2026

Python Console Animation


 



lines = ["You have woken up in a mysterious maze",

         "The building has 5 levels",

         "Scans show that the floors increase in size as you go down"]


from time import sleep

import sys


for line in lines:          # for each line of text (or each message)

    for c in line:          # for each character in each line

        print(c, end='')    # print a single character, and keep the cursor there.

        sys.stdout.flush()  # flush the buffer

        sleep(0.1)          # wait a little to make the effect look good.

    print('')               # line break (optional, could also be part of the message)


Senin, 19 Januari 2026

Calculator year 2000

 





 

<form name="Calc">




<table border="4">

<tr>

<td>

<input type="text" name="Input" size="16">

<br>

</td>

</tr>

<tr>

<td>

<input type="button" name="one" value="  1  " onclick="Calc.Input.value += '1'">

<input type="button" name="two" value="  2  " onclick="Calc.Input.value += '2'">

<input type="button" name="three" value="  3  " onclick="Calc.Input.value += '3'">

<input type="button" name="plus" value="  +  " onclick="Calc.Input.value += ' + '">

<br>

<input type="button" name="four" value="  4  " onclick="Calc.Input.value += '4'">

<input type="button" name="five" value="  5  " onclick="Calc.Input.value += '5'">

<input type="button" name="six" value="  6  " onclick="Calc.Input.value += '6'">

<input type="button" name="minus" value="  -  " onclick="Calc.Input.value += ' - '">

<br>

<input type="button" name="seven" value="  7  " onclick="Calc.Input.value += '7'">

<input type="button" name="eight" value="  8  " onclick="Calc.Input.value += '8'">

<input type="button" name="nine" value="  9  " onclick="Calc.Input.value += '9'">

<input type="button" name="times" value="  x  " onclick="Calc.Input.value += ' * '">

<br>

<input type="button" name="clear" value="  c  " onclick="Calc.Input.value = ''">

<input type="button" name="zero" value="  0  " onclick="Calc.Input.value += '0'">

<input type="button" name="DoIt" value="  =  " onclick="Calc.Input.value = eval(Calc.Input.value)">

<input type="button" name="div" value="  /  " onclick="Calc.Input.value += ' / '">

<br>

</td>

</tr>

</table>

</form>


Minggu, 18 Januari 2026

Color Picker HTML Component (.htc) JScript


 


<html>

<head>

<title>SMA INFORMATIKA CIAMIS</title>


<style>

    .colorpick    {behavior: url(ColorPick.htc)}

     H1              {

                    font: bold 18pt verdana;

                    color: navy

                    }

                    

    P               {

                    font: 10pt verdana;

                    }

    A:link { color:#003399; text-decoration:none; }

    A:visited { color:#6699CC; text-decoration:none; }

    A:hover { text-decoration:underline; }

</style>


</head>


<body bgcolor="TAN" text="#000000">

<!--TOOLBAR_START--><!--TOOLBAR_EXEMPT--><!--TOOLBAR_END-->


<MARQUEE WIDTH="400"><h1 id=theHead>SMA INFORMATIKA 


CIAMIS</h1></MARQUEE><BR>

<hr>


<p>Use the color picker to set color values visually.</p>

<br>

<input ID=cp type="text" class="colorpick" value="#fFFf00" onchange="fnColorChange()" 


style="cp--grid-size:2">

<br>

<br>


<script>

function fnColorChange()

{

theHead.style.color = cp.value;

}

</script>


<p>

<hr>

<font FACE="MS SANS SERIF" SIZE="1" COLOR="BLACK">

&copy; <a HREF="http://msdn.microsoft.com/isapi/gomscom.asp?


TARGET=/misc/cpyright.htm" TARGET="_top">2000 Microsoft Corporation. All rights 


reserved. Terms of use</a>.

</font>

<p>


</body>

</html>

================================

ColorPick.htc

<!-- ---------------------------------------------------------------------

//

//  Copyright 2000 Microsoft Corporation.  All Rights Reserved.

//

//  File: colorpick.htc

//

//  Description: This behavior allows web authors add a visual control

// for assigning color values to elements to a web page.

//

//

//-------------------------------------------------------------------- -->



<PROPERTY NAME="name"         />


<METHOD   NAME="DoMouseOn"   />

<METHOD   NAME="DoMouseOff"   />

<METHOD   NAME="DoClick"   />


<EVENT    NAME="onchange"   ID="change" />

<EVENT    NAME="onerror"    ID="error"  />

   

<ATTACH   EVENT="ondocumentready" HANDLER="DoInit"        />

<ATTACH   EVENT="onselectstart"   HANDLER="DoSelectStart" />


<SCRIPT LANGUAGE="jscript">


//+----------------------------------------------------------------------------

//

//  Global Variables

//

//-----------------------------------------------------------------------------

var zColor = new Array();

var oCurr = null;

var bValueExists = false;



//+----------------------------------------------------------------------------

//

//  Function:       DoInit

//

//  Description:    Calls functions, set variables, and attaches events to

//                  initialize behavior

//

//  Arguments:      none

//

//  Returns:        nothing

//

//-----------------------------------------------------------------------------


function DoInit()

{

style.display = "none";


    SetDefaults();

    SetColor();

    AddTable();

    MakeGrid();

    SetValue();


    attachEvent("onpropertychange", DoPropChange);

    

}



//+----------------------------------------------------------------------------

//

//  Function:       AddTable

//

//  Description:    

//

//  Arguments:      none

//

//  Returns:        nothing

//

//-----------------------------------------------------------------------------


function AddTable()

{

    var sTab = '<TABLE ID="' + uniqueID + 'tab" BORDER="1" '

+ 'STYLE="background:silver; cursor:default"></TABLE>';



insertAdjacentHTML("AfterEnd", sTab);

}



//+----------------------------------------------------------------------------

//

//  Function:       SetColor

//

//  Description:    

//

//  Arguments:      none

//

//  Returns:        nothing

//

//-----------------------------------------------------------------------------


function SetColor()

{

//var iFactor = parseInt(255/(parseInt(style.cpGridSize)-1));

var iFactor = 255/(parseInt(style.cpGridSize)-1);

var iColors = 0;

var iRed, iGreen, iBlue;

for(r=0; r<parseInt(style.cpGridSize); r++)

{

for(g=0; g<parseInt(style.cpGridSize); g++)

{

for(b=0; b<parseInt(style.cpGridSize); b++)

{

iRed = parseInt(iFactor*r);

iGreen = parseInt(iFactor*g);

iBlue = parseInt(iFactor*b);

iRed = iRed.toString(16);

iGreen = iGreen.toString(16);

iBlue = iBlue.toString(16);

if(iRed=="0") iRed = "00";

if(iGreen=="0") iGreen = "00";

if(iBlue=="0") iBlue = "00";

zColor[iColors] = iRed + iGreen + iBlue;

iColors++;

}

}

}

}



//+----------------------------------------------------------------------------

//

//  Function:       DeleteGrid

//

//  Description:    

//

//  Arguments:      none

//

//  Returns:        nothing

//

//+----------------------------------------------------------------------------


function DeleteGrid()

{

var oTab = eval(uniqueID + "tab");

while(oTab.rows.length>0)

{

oTab.deleteRow();

}

}



//+----------------------------------------------------------------------------

//

//  Function:       MakeGrid

//

//  Description:    

//

//  Arguments:      none

//

//  Returns:        nothing

//

//+----------------------------------------------------------------------------


function MakeGrid()

{

//the number of cells that will be created

var iNumCells = Math.pow(style.cpGridSize,3);


//track the number of color cells that have been created

var iNumCellsCreated = 0;

//what is grid width minimum?  Depends on how many cells there are, and how wide

//each cell is.  first, determine how many cells across we will have in our table

var iCellsAcross = parseInt(parseInt(style.cpGridWidth)/parseInt(style.cpCellWidth));

if(iCellsAcross==0) iCellsAcross = 1;

var iCellsDown = parseInt(Math.ceil(iNumCells/iCellsAcross));

if(iCellsDown==0) iCellsDown = 1;


//then, determine height.  If the given height is too short, force a height that will

//contain all the cells

//ISSUE:  Should the grid be forced into a fixed height, with a scrollbar, if the cells

//won't all fit?

if((iCellsDown*parseInt(style.cpCellHeight))>parseInt(style.cpGridHeight)) 

{

style.cpGridHeight = iCellsDown*parseInt(style.cpCellHeight);

}

var oTab = eval(uniqueID + "tab");

oTab.attachEvent("onclick", DoClick);

oTab.attachEvent("onmouseover", DoMouseOn);

oTab.attachEvent("onmouseout", DoMouseOff);

oTab.attachEvent("onselectstart", DoSelectStart);

oTab.height = style.cpGridHeight;


for(i=0; i<iCellsDown; i++)

{

var oRow = oTab.insertRow();

for(j=0; j<iCellsAcross; j++)

{

var oCell = oRow.insertCell();

oCell.style.width = style.cpCellWidth;

oCell.style.height = style.cpCellHeight;

oCell.style.border = style.cpGridStyle;

oCell.style.fontSize = 0;

iCellCount = (i*iCellsAcross) + j;

oCell.title = oCell.style.color = oCell.style.backgroundColor = zColor[iCellCount];

oCell.innerText = ".";

iNumCellsCreated++;

if(iNumCellsCreated==iNumCells) break;

}

}

//add one more row to keep from vertically stretching our color rows if 

//grid is taller than all cells

var oRow = oTab.insertRow();

oRow.style.height = 0;

oRow.style.fontSize = "0";

}



//+----------------------------------------------------------------------------

//

//  Function:       DoPropChange

//

//  Description:    Handles property changes on CSS and regular property/

//                  attributes.

//

//  Arguments:      none

//

//  Returns:        nothing

//

//-----------------------------------------------------------------------------


function DoPropChange()

{

    var propertyName = window.event.propertyName;


    if (propertyName.substring(0,5) == "style")

    {

        switch (propertyName)

        {

            case "style.cpGridSize"       :

DeleteGrid();

SetColor();

MakeGrid();

                break;


            case "style.cpGridStyle"      :

            DeleteGrid();

MakeGrid();

                break;


            case "style.cpSelectedStyle"  :

            DeleteGrid();

MakeGrid();

            

                break;


            case "style.cpHoverStyle"     :

            

                break;


            case "style.cpGridWidth"      :

                DeleteGrid();

MakeGrid();

                break;


            case "style.cpGridHeight"     :

                DeleteGrid();

MakeGrid();

                break;


            case "style.cpCellWidth"      :

                DeleteGrid();

MakeGrid();

                break;


            case "style.cpCellHeight"     :

                DeleteGrid();

MakeGrid();

                break;

        }

    }

    else

    {

        detachEvent("onpropertychange", DoPropChange);

        

        switch(propertyName)

        {

            case "name"                     :

                break;

                

            case "value"                     :

                break;

                

            default                         :

                ReturnError(propertyName + " not a valid property");

                break;

        }

        

        attachEvent("onpropertychange", DoPropChange);

    }

}



//+----------------------------------------------------------------------------

//

//  Function:       SetValue

//

//  Description:    

//

//  Arguments:      none

//

//  Returns:        nothing

//

//-----------------------------------------------------------------------------


function SetValue()

{

var oTab = eval(uniqueID + "tab");


if (value == null)

{

value = oTab.rows(0).cells(0).style.backgroundColor;

}


for(i=0; i<oTab.rows.length; i++)

{

for(j=0; j<oTab.rows(i).cells.length; j++)

{

if(oTab.rows(i).cells(j).style.backgroundColor.toLowerCase() == value.toLowerCase())

{

bValueExists = true;

oCurr = oTab.rows(i).cells(j);

oCurr.style.border = style.cpSelectedStyle;

value = oCurr.style.backgroundColor;

}

}

}

if(bValueExists==false) value = oTab.rows(0).cells(0).style.backgroundColor;

}



//+----------------------------------------------------------------------------

//

//  Function:       SetDefaults

//

//  Description:    Called during the initialization of the behavior.  Sets

//                  the defaults for custom CSS properties (calls the

//                  CustomDefault() function), regular CSS properties (the

//                  NormalDefault() function), and attribute/properties.

//

//  Arguments:      none

//

//  Returns:        nothing

//

//-----------------------------------------------------------------------------


function SetDefaults()

{

//store value to be passed for all three border styles

var sBorderDefault = style['cp--grid-style'];

if(sBorderDefault==null) sBorderDefault = '1px inset activeborder';

//store value to be passed for cpGridWidth

var iGridWidthDefault = '90px';

if(style['cp--cell-width']==null)

{

if(style['cp--grid-width']==null)

{

switch(style['cp--grid-size'])

{

case '2': iGridWidthDefault = '54px';

break;

case '3': iGridWidthDefault = '90px';

break;

case '4': iGridWidthDefault = '144px';

break;

}

}

}

    // Custom CSS Property Defaults

    CustomDefault('cp--grid-size', 'cpGridSize', '3');

    CustomDefault('cp--grid-style', 'cpGridStyle', sBorderDefault);

    CustomDefault('cp--selected-style', 'cpSelectedStyle', sBorderDefault);

    CustomDefault('cp--hover-style', 'cpHoverStyle', sBorderDefault);

    CustomDefault('cp--grid-width', 'cpGridWidth', iGridWidthDefault);

    CustomDefault('cp--grid-height', 'cpGridHeight', '1px');

    CustomDefault('cp--cell-width', 'cpCellWidth', '18px');

    CustomDefault('cp--cell-height', 'cpCellHeight', '18px');

    

    //  Attribute | Property Defaults

    if (value == null) value = "#000000";

}



//+----------------------------------------------------------------------------

//

//  Function:       CustomDefault

//

//  Description:    Sets the defaults for custom CSS properties and establishes

//                  a scriptable name for the property

//

//  Arguments:      sCSSName - the CSS name of the property

//                  sScriptName - the desired Scriptable name of the property

//                  sDefault - the desired default value

//

//  Returns:        nothing

//

//-----------------------------------------------------------------------------


function CustomDefault(sCSSName, sScriptName, sDefault)

{

    if (currentStyle[sCSSName] == null)

    {

        style[sCSSName] = sDefault;

    }

    else style[sCSSName] = currentStyle[sCSSName];

    

    style[sScriptName] = style[sCSSName];

}



//+----------------------------------------------------------------------------

//

//  Function:       NormalDefault

//

//  Description:    Sets the defaults for CSS properties by checking the

//                  currentStyle and style of the object against the IE

//                  default.

//

//  Arguments:      sCSSName - the CSS name of the property

//                  sIEDefault - the IE standard default of the property

//                  sDefault - the desired default of the property

//

//  Returns:        nothing

//

//-----------------------------------------------------------------------------


function NormalDefault(sCSSName, sIEDefault, sDefault)

{

    if (currentStyle[sCSSName] == sIEDefault 

        && (style[sCSSName] == "" || style[sCSSName] == null))

    {

        style[sCSSName] = sDefault;

    }

}



//+----------------------------------------------------------------------------

//

//  Function:       DoMouseOn

//

//  Description:    

//

//  Arguments:      none

//

//  Returns:        false if the srcElement is not the slider piece.

//

//+----------------------------------------------------------------------------


function DoMouseOn()

{

var e = window.event.srcElement;


if(e.tagName.toLowerCase()=="td" && e != oCurr)

{

e.style.border = style.cpHoverStyle;

}

}



//+----------------------------------------------------------------------------

//

//  Function:       DoMouseOff

//

//  Description:    

//

//  Arguments:      none

//

//  Returns:        nothing

//

//+----------------------------------------------------------------------------


function DoMouseOff()

{

var e = window.event.srcElement;


if(e.tagName.toLowerCase()=="td" && e != oCurr)

{

e.style.border = style.cpGridStyle;

}

}



//+----------------------------------------------------------------------------

//

//  Function:       DoClick

//

//  Description:    

//

//  Arguments:      none

//

//  Returns:        nothing

//

//+----------------------------------------------------------------------------


function DoClick()

{

var e = window.event.srcElement;


if(e.tagName.toLowerCase()=="td" && e != oCurr)

{

oCurr.style.border = style.cpGridStyle;

oCurr = e;

e.style.border = style.cpSelectedStyle;

value = e.style.backgroundColor;

}

change.fire();

}



//+----------------------------------------------------------------------------

//

//  Function:       DoSelectStart

//

//  Description:    Cancels the onselectstart event to prevent user from

//                  selecting text in the slider.

//

//  Arguments:      none

//

//  Returns:        false (returnValue)

//

//+----------------------------------------------------------------------------


function DoSelectStart()

{

    window.event.returnValue = false;

    window.event.cancelBubble = true;

}



//+----------------------------------------------------------------------------

//

//  Function:       ReturnError

//

//  Description:    Fires the error event, along with a descriptive text

//                  message.

//

//  Arguments:      sMsg - descriptive text message

//

//  Returns:        nothing

//

//-----------------------------------------------------------------------------


function ReturnError(sMsg)

{

    var oEvent = createEventObject();

    oEvent.setAttribute("error", sMsg);

    error.fire(oEvent);

}


</SCRIPT>