📄 stockeditor.java
字号:
// Tina POS is a point of sales application designed for touch screens.
// Copyright (C) 2005 Adrian Romero Corchado.
// http://sourceforge.net/projects/tinapos
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package net.adrianromero.tpv.inventory;
import java.awt.Component;
import javax.swing.DefaultCellEditor;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableColumnModel;
import javax.swing.table.TableColumn;
import net.adrianromero.data.user.BrowsableData;
import net.adrianromero.format.Formats;
import net.adrianromero.tpv.forms.AppLocal;
public class StockEditor extends javax.swing.JPanel {
/** Creates new form StockEditor */
public StockEditor() {
initComponents();
DefaultTableColumnModel columns = new DefaultTableColumnModel();
TableColumn c;
c = new TableColumn(0, 20
, new DataCellRenderer(javax.swing.SwingConstants.LEFT)
, new DefaultCellEditor(new JTextField()));
c.setHeaderValue("");
columns.addColumn(c);
c = new TableColumn(1, 200
, new DataCellRenderer(javax.swing.SwingConstants.LEFT)
, new DefaultCellEditor(new JTextField()));
c.setHeaderValue(AppLocal.getIntString("label.warehouse"));
columns.addColumn(c);
c = new TableColumn(3, 75
, new DataCellRenderer(javax.swing.SwingConstants.RIGHT)
, new DefaultCellEditor(new JTextField()));
c.setHeaderValue(AppLocal.getIntString("label.units"));
columns.addColumn(c);
c = new TableColumn(4, 75
, new DataCellRenderer(javax.swing.SwingConstants.RIGHT)
, new DefaultCellEditor(new JTextField()));
c.setHeaderValue(AppLocal.getIntString("label.minimum"));
columns.addColumn(c);
c = new TableColumn(5, 75
, new DataCellRenderer(javax.swing.SwingConstants.RIGHT)
, new DefaultCellEditor(new JTextField()));
c.setHeaderValue(AppLocal.getIntString("label.maximum"));
columns.addColumn(c);
m_jStockTable.setColumnModel(columns);
}
public void writeValueStock(BrowsableData stock) {
m_jStockTable.setModel(new StockModel(stock, new Formats[] {Formats.INT, Formats.STRING, Formats.STRING, Formats.DOUBLE, Formats.DOUBLE, Formats.DOUBLE}, new boolean[]{false, false, false, false, true, true}));
}
private static class DataCellRenderer extends DefaultTableCellRenderer {
private int m_iAlignment;
public DataCellRenderer(int align) {
m_iAlignment = align;
}
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column){
JLabel aux = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
//aux.setVerticalAlignment(javax.swing.SwingConstants.TOP);
aux.setHorizontalAlignment(m_iAlignment);
if (!isSelected) {
aux.setBackground(javax.swing.UIManager.getDefaults().getColor("TextField.disabledBackground"));
}
return aux;
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane2 = new javax.swing.JScrollPane();
m_jStockTable = new javax.swing.JTable();
setLayout(new java.awt.BorderLayout());
m_jStockTable.setAutoCreateColumnsFromModel(false);
m_jStockTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
jScrollPane2.setViewportView(m_jStockTable);
add(jScrollPane2, java.awt.BorderLayout.CENTER);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTable m_jStockTable;
// End of variables declaration//GEN-END:variables
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -