KidsLovePC Contact Us
  Home   PHP  Graphics ASP  JavaScript   HTML  JAVA   Swing   Webtip  Lyric  Free sheet music  Ringtones

Best books about JAVA programming:

JAVA JSlide Color

The following code adds color to JSlide. User may customize the color showing on JSlide. This example has following Java files:


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

public class MThumbSlider extends JSlider {
protected int thumbNum;
protected BoundedRangeModel[] sliderModels;
protected Icon[] thumbRenderers;
protected Color[] fillColors;
protected Color trackFillColor;

private static final String uiClassID = "MThumbSliderUI";

public MThumbSlider(int n) {
createThumbs(n);
updateUI();
}

protected void createThumbs(int n) {
thumbNum = n;
sliderModels = new BoundedRangeModel[n];
thumbRenderers = new Icon[n];
fillColors = new Color[n];
for (int i=0;i<n;i++) {
sliderModels[i] = new DefaultBoundedRangeModel(50, 0, 0, 100);
thumbRenderers[i] = null;
fillColors[i] = null;
}
}


public void updateUI() {
AssistantUIManager.setUIName(this);
super.updateUI();

}

public String getUIClassID() {
return uiClassID;
}


public int getThumbNum() {
return thumbNum;
}

public int getValueAt(int index) {
return getModelAt(index).getValue();
}

public void setValueAt(int n, int index) {
getModelAt(index).setValue(n);
// should I fire?
}

public int getMinimum() {
return getModelAt(0).getMinimum();
}

public int getMaximum() {
return getModelAt(0).getMaximum();
}

public BoundedRangeModel getModelAt(int index) {
return sliderModels[index];
}

public Icon getThumbRendererAt(int index) {
return thumbRenderers[index];
}

public void setThumbRendererAt(Icon icon, int index) {
thumbRenderers[index] = icon;
}

public Color getFillColorAt(int index) {
return fillColors[index];
}

public void setFillColorAt(Color color, int index) {
fillColors[index] = color;
}

public Color getTrackFillColor() {
return trackFillColor;
}

public void setTrackFillColor(Color color) {
trackFillColor = color;
}
}

 


Sponsored link
Java JTabbedPane
JTabbedPane Preview List
Java JComboBox
JComboBox Preview List
Java JTooltip
JTooltip Preview List
Java JList
JList Preview List
Java JTree
JTree Preview List 1
JTree Preview List 2
JAVA JTable
JTable Preview List 1
JTable Preview List 2
JTable Preview List 3
JTable Preview List 4
JTable Preview List 5
JTable Preview List 6
JTable Preview List 7
JAVA Jslide
JSlide Preview List

 

 

Best books about JAVA programming from Amazon
Professional Java, JDK 5 Edition (Paperback Simply Java Programming: An Application-Driven Tutorial Approach (Paperback) Effective Java Programming Language Guide (Paperback) Head First Java, 2nd Edition (Paperback) Java : An Introduction to Problem Solving and Programming (4th Edition)

 

Printer Inkjet A Z lyricsLearn ChineseHome|PHP|Swing|HTML|JavaScript|ASP|JAVA|Forum|WebTip|Contact Us
Copyright © kidslovepc.com All rights reserved(new). Privacy|Copyright
designed by info@kidslovepc.com

Please help us cover the web site maintenance fee.
barcode scanner Thermal Printer credit card machine bar code printer