📄 simpletable.java.svn-base
字号:
package jm.framework.gui.module.jmtable;
import java.awt.Color;
import jm.framework.gui.ReLoad;
import jm.framework.gui.module.JMItemCode;
import jm.framework.gui.module.JMScrollPane;
import jm.util.JM2DArray;
public class SimpleTable extends JMScrollPane implements ReLoad {
/**
*
*/
private static final long serialVersionUID = 8866972076276444668L;
public static final String CLASS_NAME = "SimpleTable";
private JMTable jmtable = null;
public SimpleTable (String[] col, int[] width) {
try {
jmtable = new JMTable(new JM2DArray());
jbInit();
jmtable.setColNames(col);
setColWidth(width);
} catch (Exception ex) {
ex.printStackTrace();
}
}
public SimpleTable (JM2DArray datasSource) {
try {
jmtable = new JMTable(datasSource);
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public SimpleTable (JM2DArray datasSource, String[] col) {
try {
jmtable = new JMTable(datasSource);
jbInit();
jmtable.setColNames(col);
} catch (Exception ex) {
ex.printStackTrace();
}
}
public SimpleTable (JM2DArray datasSource, String[] col, int[] width) {
try {
jmtable = new JMTable(datasSource);
jbInit();
jmtable.setColNames(col);
setColWidth(width);
} catch (Exception ex) {
ex.printStackTrace();
}
}
public boolean deleterow (int selectrow) {
jmtable.getModel().removeRow(selectrow);
return true;
}
public boolean deletecol (int selectcol) {
return jmtable.removeColumn(selectcol);
}
public void setColWidth (int[] Width) {
for (int i = 0; i < jmtable.getColumnNumber(); i++) {
jmtable.setColWidth(i, Width[i]);
}
}
public void setData (JM2DArray datasSource) {
jmtable.getModel().setRowData(datasSource);
}
public void setBackgroundColor (Color[] background) {
jmtable.setBackgroundColor(background);
}
public int getSelectLine () {
return jmtable.getSelectedRow();
}
public void clearSelection () {
jmtable.getSelectionModel().clearSelection();
}
public JMTable getJMTable () {
return jmtable;
}
public boolean isSelected () {
try {
if (jmtable.getSelectedRow() >= 0) {
return true;
} else {
return false;
}
} catch (Exception ex) {
return false;
}
}
public void init () {
try {
jmtable.init();
jmtable.setRowHeight(20);
jmtable.getTableHeader().setReorderingAllowed(false);
// jmtable.setColResizable(false);
jmtable.getTableHeader().setFont(JMItemCode.FT_TABLE);
jmtable.showHorScroll(false);
// jmtable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
jmtable.setSelectionBackground(new Color(160, 200, 255));
jmtable.setSelectionForeground(Color.red);
jmtable.setBackgroundColor(null);
jmtable.setShowHorizontalLines(false);
jmtable.setShowVerticalLines(false);
jmtable.setSelectionMode(JMTable.SELECTION_SINGLE);
} catch (Exception e) {
e.printStackTrace();
}
}
private void jbInit () throws Exception {
this.getViewport().add(jmtable);
}
public boolean reLoad () {
jmtable.updateUI();
updateUI();
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -