package frame;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.*;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.RowFilter;
import javax.swing.SpringLayout;
import javax.swing.SwingConstants;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
import utils.ImageEditorUtil;
import utils.MaterailTableModel;
public class DisplayFrame extends BasicFrame implements ActionListener,MouseListener{
private MaterailTableModel myModel;
private JTable jTable;
private JScrollPane scrollPane;
private JMenuItem refresh;
private JMenuItem sell;
private JMenuItem changePrice;
private JMenuItem buy;
private MainFrame frame;
private Thread myThread;
private JTextField filterText;
private JTextField statusText;
private TableRowSorter<TableModel> sorter;
public DisplayFrame(String title,MainFrame frame) {
super(title);
this.frame = frame;
myModel = new MaterailTableModel();
sorter = new TableRowSorter<TableModel>(myModel);
jTable = new JTable(myModel);
jTable.setRowSorter(sorter);
jTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
jTable.setFillsViewportHeight(true);
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
scrollPane = new JScrollPane(jTable);
jTable.addMouseListener(this);
JPanel form = new JPanel(new GridLayout());
JLabel l1 = new JLabel(" 石材:");
form.add(l1);
filterText = new JTextField();
form.add(filterText);
// Whenever filterText changes, invoke newFilter.
filterText.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
newFilter();
}
public void insertUpdate(DocumentEvent e) {
newFilter();
}
public void removeUpdate(DocumentEvent e) {
newFilter();
}
});
JPanel main = new JPanel();
main.setLayout(new BorderLayout());
main.add(form,BorderLayout.NORTH);
main.add(scrollPane, BorderLayout.CENTER);
add(main);
}
public DisplayFrame(String title,String length,String width,MainFrame frame) {
super(title);
this.frame = frame;
jTable.setRowSorter(sorter);
jTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
jTable.setFillsViewportHeight(true);
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
scrollPane = new JScrollPane(jTable);
jTable.addMouseListener(this);
JPanel form = new JPanel(new GridLayout());
JLabel l1 = new JLabel("石材:");
form.add(l1);
filterText = new JTextField();
form.add(filterText);
// Whenever filterText changes, invoke newFilter.
filterText.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
newFilter();
}
public void insertUpdate(DocumentEvent e) {
newFilter();
}
public void removeUpdate(DocumentEvent e) {
newFilter();
}
});
JPanel main = new JPanel();
main.setLayout(new BorderLayout());
main.add(form,BorderLayout.NORTH);
main.add(scrollPane, BorderLayout.CENTER);
add(main);
}
/**
* Update the row filter regular expression from the expression in the text
* box.
*/
private void newFilter() {
RowFilter<TableModel, Object> rf = null;
// If current expression doesn't parse, don't update.
try {
rf = RowFilter.regexFilter(filterText.getText(), 0);
} catch (java.util.regex.PatternSyntaxException e) {
return;
}
sorter.setRowFilter(rf);
}
public void mouseClicked(MouseEvent e) {
int selectRom = jTable.getSelectedRow();
if (e.getButton() == MouseEvent.BUTTON3) {
if (selectRom >= 0 && selectRom < jTable.getRowCount()) {// 判断选中行是否有效
JPopupMenu popup = new JPopupMenu();
refresh = new JMenuItem("刷新");
refresh.setIcon(ImageEditorUtil.createIcon("refresh.png"));
refresh.addActionListener(this);
popup.add(refresh);
sell = new JMenuItem("售出");
sell.setIcon(ImageEditorUtil.createIcon("sell.png"));
sell.addActionListener(this);
popup.add(sell);
changePrice = new JMenuItem("更改价格");
changePrice.setIcon(ImageEditorUtil.createIcon("change.png"));
changePrice.addActionListener(this);
popup.add(changePrice);
buy = new JMenuItem("购进");
buy.setIcon(ImageEditorUtil.createIcon("buy.png"));
buy.addActionListener(this);
popup.add(buy);
popup.show(e.getComponent(), e.getX(), e.getY());
}
}
}
@Override
public void actionPerformed(ActionEvent e) {
Object o = e.getSource();
if(o.equals(refresh)) {
this.dispose();
if(myThread!=null && myThread.isAlive()) {
myThread.notify();
}
myThread = new Thread() {
public void run() {
frame.addIFrame(new DisplayFrame("石材列表",frame));
}
};
myThread.start();
}else if(o.equals(sell)) {
UpdateFrame up = new UpdateFrame("售出");
up.set_toName((String)jTable.getValueAt(jTable.getSelectedRow() , 0));
frame.addIFrame(up);
}else if(o.equals(changePrice)) {
UpdateFrame up = new UpdateFrame("更改价格");
up.set_toName((String)jTable.getValueAt(jTable.getSelectedRow() , 0));
frame.addIFrame(up);
}else if(o.equals(buy)) {
UpdateFrame up = new UpdateFrame("购进");
up.set_toName((String)jTable.getValueAt(jTable.getSelectedRow() , 0));
frame.addIFrame(up);
}
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
建筑材料管理系统java版 (102个子文件)
UserMIS.class 7KB
DisplayFrame.class 6KB
Calculater.class 6KB
LoginFrame.class 6KB
MainFrame.class 5KB
UpdateFrame.class 4KB
DBConnectionUtil.class 4KB
UpdateAction.class 4KB
EnteringFrame.class 4KB
UserAction.class 3KB
CheckAction.class 2KB
OptionFrame.class 2KB
LoginAction.class 2KB
JProgressFrame.class 2KB
MainFrame$1.class 2KB
MyList.class 1KB
MaterailTableModel.class 1KB
ImageEditorUtil.class 1KB
AboutFrame.class 1KB
UserTableModel.class 1KB
TranslucentButton.class 1KB
JScroll.class 977B
DisplayFrame$2.class 949B
DisplayFrame$1.class 913B
Frame_Middle.class 911B
BasicFrame.class 885B
JBar.class 814B
Main.class 811B
DisplayFrame$3.class 797B
UserMIS$1.class 762B
JMenuBars.class 755B
LoginFrame$1.class 617B
Main$1.class 570B
.classpath 455B
.fatjar 334B
sqljdbc4.jar 525KB
DisplayFrame.java 6KB
UserMIS.java 6KB
Calculater.java 6KB
LoginFrame.java 5KB
UpdateFrame.java 4KB
MainFrame.java 4KB
EnteringFrame.java 3KB
UpdateAction.java 3KB
DBConnectionUtil.java 3KB
UserAction.java 2KB
OptionFrame.java 2KB
JProgressFrame.java 2KB
LoginAction.java 2KB
CheckAction.java 1KB
MaterailTableModel.java 874B
UserTableModel.java 865B
MyList.java 828B
TranslucentButton.java 756B
JScroll.java 648B
BasicFrame.java 611B
Frame_Middle.java 571B
JBar.java 568B
ImageEditorUtil.java 566B
AboutFrame.java 556B
JMenuBars.java 506B
Main.java 457B
main.jpg 193KB
main.jpg 193KB
login.jpg 161KB
login.jpg 161KB
userMIS.jpg 119KB
userMIS.jpg 119KB
1.mdb 200KB
storage.png 13KB
storage.png 13KB
Login.png 9KB
Login.png 9KB
change.png 6KB
change.png 6KB
Exit.png 5KB
Exit.png 5KB
link.png 5KB
link.png 5KB
check.png 5KB
check.png 5KB
detial.png 5KB
detial.png 5KB
enter.png 5KB
enter.png 5KB
delete.png 5KB
delete.png 5KB
buy.png 5KB
buy.png 5KB
calculator.png 5KB
calculator.png 5KB
refresh.png 3KB
refresh.png 3KB
about.png 2KB
about.png 2KB
sell.png 2KB
sell.png 2KB
org.eclipse.jdt.core.prefs 629B
.project 386B
user.properties 60B
共 102 条
- 1
- 2
资源评论
lanmukeyu
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功