?? thermometerrenderer.java
字號(hào):
/* * This source code is part of TWaver 1.3.1 * * SERVA Software PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * Copyright 2000-2005 SERVA Software, Inc. All rights reserved. */package demo.network.customui;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.table.TableCellRenderer;
public class ThermometerRenderer extends JComponent implements TableCellRenderer {
protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
protected static Border focusBorder = UIManager.getBorder("Table.focusCellHighlightBorder");
private boolean hasFocus;
private Integer value;
public ThermometerRenderer() {
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (hasFocus) {
this.setBorder(focusBorder);
} else {
this.setBorder(noFocusBorder);
}
Dimension size = this.getSize();
g.setColor(Color.BLACK);
g.fillRect(0, 0, size.width, size.height);
if (value != null) {
g.setColor(Color.GREEN);
double r = (size.height - 4) / 2.0;
int centerX = (int) (size.width * (20 - value.intValue()) / 20.0);
int centerY = (int) r;
( (Graphics2D) g).fill(new Ellipse2D.Double(centerX - r, centerY - r + 2, r * 2, r * 2));
}
}
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column) {
this.hasFocus = hasFocus;
this.value = (Integer) value;
this.setToolTipText(value + "");
return this;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -