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

📄 btnjianzhuframe.java

📁 长沙公交查询管理系统,主要实现对人员资料的管理以及车辆的分配路线。
💻 JAVA
字号:
/*此类实现建筑查询的界面与功能*/
package pro;
import java.awt.*;
import java.awt.Event;
import javax.swing.*;
import javax.swing.table.*;
import java.util.*;

public class BtnJianZhuFrame extends JDialog implements java.awt.event.ActionListener//,MouseListener
{
  Vector vec=new Vector();
	//new出所需组键
  private DefaultTableModel mDtm;
  private JTable tabShow=new JTable();
  JLabel lblTitle = new JLabel();
  JScrollPane Spn = new JScrollPane();
  private JPanel pnlSouth=new JPanel();
  private Selebus sel = new Selebus();

  private PnlCha pnl;

  
  
  JButton btnClose = new JButton();
  JButton btnHuanHui=new JButton();
  public BtnJianZhuFrame(MainFrame mf,DefaultTableModel dtm)
  {
  	super(mf,true);
  	mDtm=dtm;
  	vec.add(mDtm);
  	/*为组键定位*/
  	
  	this.getContentPane().setLayout(null);
  	//this.getContentPane().setLayout(new BorderLayout());
  	pnlSouth.setLayout(null);
  	lblTitle.setFont(new java.awt.Font("Dialog", Font.BOLD | Font.ITALIC, 18));
    lblTitle.setForeground(new Color(0, 210, 46));
    lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
    lblTitle.setText("建筑查询结果");
    lblTitle.setBounds(new Rectangle(86, 7, 460, 33));
    Spn.setBounds(new Rectangle(15, 36, 610,440));
 	tabShow.setColumnSelectionAllowed(true);
// 	tabShow.getIntercellSpacing(java.awt.Dimension.);
 	
 //	tabShow.setcolumnwid
   /*用匿名类实现监听器接口*/
   this.tabShow.addMouseListener(new java.awt.event.MouseAdapter(){
   public void mouseClicked(java.awt.event.MouseEvent me)
   {
	   if(me.getClickCount()==1&&me.getButton()==me.BUTTON1)
	   {
	      String strSel=(String)(tabShow.getValueAt(tabShow.getSelectedRow(),tabShow.getSelectedColumn()));
	      tabShow.setSelectionForeground(Color.red);
	      tabShow.setSelectionBackground(Color.GREEN);
   		  if(tabShow.getSelectedColumn()==0)
   		  {
   		  	VoSumBus vsb=new VoSumBus();
   		    vsb=sel.selectDataByXianName(strSel);
	        TabXianLuDialog tabXianLuDialog=new TabXianLuDialog(BtnJianZhuFrame.this,vsb);
   		    
    		//获得屏幕的大小
		    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		    //获得窗体的大小
		    Dimension frameSize = tabXianLuDialog.getSize();
		    /*以防窗体的大小超过屏幕的大小*/
		    if (frameSize.height > screenSize.height) {
		      frameSize.height = screenSize.height;
		    }
		    if (frameSize.width > screenSize.width) {
		      frameSize.width = screenSize.width;
		    }
		   	/*设置窗体在屏幕中间*/
		    tabXianLuDialog.setLocation( (screenSize.width - frameSize.width) / 2,
		                      (screenSize.height - frameSize.height) / 2);
		   tabXianLuDialog.setVisible(true);
   

   		  }
   		  if(tabShow.getSelectedColumn()==1||tabShow.getSelectedColumn()==2||tabShow.getSelectedColumn()==3)
   		  {
   		  	 //根据站路名调方法获得table的模型
   		  	 javax.swing.table.DefaultTableModel dtm=sel.selectZhan(strSel);
   		  	 vec.add(dtm);
   		  	 if(vec.size()>1)
   		  	 {
   		  	 	btnHuanHui.setEnabled(true);
   		  	 }
   		  	 for(int i=0;i<vec.size();i++)
   		  	 {
   		  	 	System.out.println ("****vecgeti"+vec.get(i));
   		  	 }
   		  	 num=vec.size();
   		  	 tabShow.setModel(dtm);//根据站路名更换Model
   	
   		  }
   		
   			
   		}
   		
   	}
   	});
 
    tabShow.setBounds(20,40,480,430);
    pnlSouth.setBounds(0,476,500,50);
    Spn.getViewport().add(tabShow);
    this.add(lblTitle,BorderLayout.NORTH);
    this.add(Spn); 
    
    
 
    btnClose.setBounds(new Rectangle(350, 5, 120, 31));
    btnClose.setText("退出");
	btnClose.setForeground(new Color(0, 210, 46));
    btnClose.setFont(new java.awt.Font("Dialog", Font.BOLD | Font.ITALIC, 14));
    
    
    btnHuanHui.setBounds(new Rectangle(150, 5, 120, 31));
    btnHuanHui.setFont(new java.awt.Font("Dialog", Font.BOLD | Font.ITALIC, 14));
    btnHuanHui.setForeground(new Color(0, 210, 46));
    btnHuanHui.setToolTipText("点击即可返回上一页");
    btnHuanHui.setText("返回上页");
    //pnlSouth.setLayout(new FlowLayout());
    pnlSouth.add(btnHuanHui);
    pnlSouth.add(btnClose);
    
    this.add(pnlSouth);
 
    
    
    this.tabShow.setModel(mDtm);
    btnClose.setActionCommand("btnClose");
    btnHuanHui.setActionCommand("btnHuanHui");
   // this.tabShow.setAction
    
    btnClose.addActionListener(this);
    btnHuanHui.addActionListener(this);
    
  	
  	
  	setSize(new Dimension(650,560));
    setTitle("长沙公交查询管理系统");
  }
//////////////////////////////////////////////  
 	public int num;
   public void actionPerformed(java.awt.event.ActionEvent ae)
  {
  	String strCmd=ae.getActionCommand();
  	if(strCmd.equals("btnClose"))
  	{  	
  	   this.dispose();
    }
    else//实现返回上一页的功能
    {
	    if(num>0)
	    {
	    	System.out.println ("num="+num);
	    	tabShow.setModel((DefaultTableModel)vec.get(--num));
	    }
	    else
	    {
	    	javax.swing.JOptionPane.showMessageDialog(this,"已返回到第一页");
	    	btnHuanHui.setEnabled(false);
	    }
    	 	 
    }
   }
}

⌨️ 快捷键说明

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