Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java GUI 设计  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:诚心求教:如何在JTABLE中部署JPOPUPMENU [Re:chenyoufan]
chenyoufan





发贴: 11
积分: 0
于 2005-09-27 17:12 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
代码如下,个人认为貌似没有什么语法错误吧?
我还特地获取了鼠标点击时的坐标..............
运行结果:
JFRAME全屏显示时,不管点在哪里,菜单都不出现
JFRAME不是全屏显示时,鼠标点击在JTABLE的最右边一部分区域有显示,
不解................迷茫中.............高手赐教啊

package com.system.Gui;

import java.awt.*;

import javax.swing.*;
import javax.swing.table.*;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;

public class MainGui extends JFrame {
  
  TableList tablelist;
  
  String namestr;
  String schoolstr;
  String classstr;
  String subjectstr;
  
  JRootPane m_root;
  
  /*
   * 控件
   */
  JTextField m_Condition;
  JComboBox m_type;
  JButton m_btnSearch;
  
  public MainGui(){
    
    jbInit();
    
  }
  
  void jbInit(){
    
    m_root = this.getRootPane();
    m_root.setLayout(new BorderLayout());
    
    this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    
    JPanel TopPanel = new JPanel();
    TopPanel.setLayout(new FlowLayout());
    
    JPanel BottomPanel = new JPanel();
    BottomPanel.setLayout(new BorderLayout());
    
    JPanel InforPanel = new JPanel();
    InforPanel.setLayout(new FlowLayout());
    
    JPanel NamePanel = new JPanel();
    JLabel lbname = new JLabel("姓名:");
    JLabel lbnamestr = new JLabel(namestr);
    NamePanel.add(lbname);
    NamePanel.add(lbnamestr);
    
    JPanel SubPanel = new JPanel();
    JLabel lbsub = new JLabel("所教科目:");
    JLabel lbsubstr = new JLabel(subjectstr);
    SubPanel.add(lbsub);
    SubPanel.add(lbsubstr);
    
    JPanel ScPanel = new JPanel();
    JLabel lbsc = new JLabel("所在学校:");
    JLabel lbscstr = new JLabel(schoolstr);
    ScPanel.add(lbsc);
    ScPanel.add(lbscstr);
    
    JPanel ClassPanel = new JPanel();
    JLabel lbclass = new JLabel("任课班级");
    JLabel lbclassstr = new JLabel(classstr);
    
    InforPanel.add(NamePanel);
    InforPanel.add(SubPanel);
    InforPanel.add(ScPanel);
    InforPanel.add(ClassPanel);
    
    TopPanel.add(InforPanel);
    
    tablelist = new TableList(this,10,10);
    JPanel SearchPanel = new JPanel();
    SearchPanel.setLayout(new GridLayout(1,4,4,2));
    
    JLabel lbcondition = new JLabel("查询条件:");
    m_Condition = new JTextField();
    m_type = new JComboBox();
    m_btnSearch = new JButton("查询");
    
    SearchPanel.add(lbcondition);
    SearchPanel.add(m_Condition);
    SearchPanel.add(m_type);
    SearchPanel.add(m_btnSearch);
    
    BottomPanel.add(tablelist,BorderLayout.CENTER);
    BottomPanel.add(SearchPanel,BorderLayout.SOUTH);
    
    m_root.add(TopPanel,BorderLayout.NORTH);
    m_root.add(BottomPanel,BorderLayout.CENTER);
    
    
  }
  
  
}

class TableList extends JScrollPane {
  
  FrameListener m_framelistener;
  public static int m_selectionRow;
  public static int m_selectionColumn;
  
  public TableList(MainGui maingui,final int row,final int col){
    
    
   TableModel dataModel = new AbstractTableModel() {
        public int getColumnCount() { return row; }
     public int getRowCount() { return col;}
     public Object getValueAt(int row, int col) { return new Integer(row*col);
        }

      };
      
      JTable table = new JTable(dataModel);
      table.setAutoResizeMode(0);//设置JTable是否及如何调整大小,以适应可用空间
      this.getViewport().add(table);

      m_framelistener = new FrameListener(table);
      table.setRowSelectionAllowed(true);
      table.addMouseListener(m_framelistener);
      table.addKeyListener(m_framelistener);

      
  }

}




关于女孩子从事软件开发的问题

话题树型展开
人气 标题 作者 字数 发贴时间
6015 诚心求教:如何在JTABLE中部署JPOPUPMENU chenyoufan 266 2005-09-08 17:19
4405 Re:诚心求教:如何在JTABLE中部署JPOPUPMENU chenyoufan 34 2005-09-27 12:42
4375 Re:诚心求教:如何在JTABLE中部署JPOPUPMENU littledeer1974 60 2005-09-27 13:42
4600 Re:诚心求教:如何在JTABLE中部署JPOPUPMENU chenyoufan 3330 2005-09-27 17:12

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923