⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 doublerender.java

📁 参考了JAVA方面MIS系统开发的书籍做的一个 电力收费的系统,包里面是可以直接运行的JAR文件了...SRC是源文件可一些需要的包...数据库是用的MSQLserver2000,"java程序数据
💻 JAVA
字号:
import java.text.*;
import javax.swing.*;     
import java.awt.*;
import javax.swing.table.*;class DoubleRender extends JLabel  implements TableCellRenderer{
	NumberFormat nf = NumberFormat.getNumberInstance();
	DecimalFormat df= (DecimalFormat)nf;  //和读数的精确到小数点后3位	public DoubleRender(){
		super();
		setOpaque(true); 		df.applyPattern("##########0.00");
		this.setHorizontalAlignment(SwingConstants.RIGHT);		setHorizontalTextPosition(SwingConstants.RIGHT);
	}
	public Component getTableCellRendererComponent(
								JTable table, Object str,                                 boolean isSelected, boolean hasFocus,                                int row, int column) 	{
		if (isSelected){			this.setForeground(table.getSelectionForeground());
			this.setBackground(table.getSelectionBackground());
		}
		else{			this.setForeground(table.getForeground());
			this.setBackground(table.getBackground());		}
		Object value=table.getModel().getValueAt(row,column);		String display="";
		if(value!=null)	display=df.format(value);
		this.setText(display);		
		return this;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -