首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

如何摆脱JTable/JScrollPane的边界

要摆脱JTable/JScrollPane的边界,可以使用以下方法:

  1. 设置JTable的表格边框:
代码语言:java
复制
JTable table = new JTable();
table.setShowGrid(false);
table.setIntercellSpacing(new Dimension(0, 0));
table.setBorder(BorderFactory.createEmptyBorder());
  1. 设置JScrollPane的边框:
代码语言:java
复制
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
scrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
  1. 设置JScrollPane的视口大小:
代码语言:java
复制
scrollPane.getViewport().setPreferredSize(table.getPreferredSize());
  1. 设置JScrollPane的滚动条样式:
代码语言:java
复制
scrollPane.getVerticalScrollBar().setUI(new BasicScrollBarUI());
scrollPane.getHorizontalScrollBar().setUI(new BasicScrollBarUI());
  1. 设置JTable的行高:
代码语言:java
复制
table.setRowHeight(20);
  1. 设置JTable的单元格边距:
代码语言:java
复制
table.setIntercellSpacing(new Dimension(0, 0));
  1. 设置JTable的表头样式:
代码语言:java
复制
JTableHeader header = table.getTableHeader();
header.setBorder(BorderFactory.createEmptyBorder());
header.setBackground(Color.WHITE);
header.setForeground(Color.BLACK);
header.setFont(new Font("Arial", Font.BOLD, 12));

通过以上方法,可以有效地摆脱JTable/JScrollPane的边界,使其更加美观和易于使用。

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

  • jTable插件辅助资料

    ==============================================jTable插件================================================ 【】引入jtable <link rel="stylesheet" type="text/css" href="../jtable/themes/lightcolor/blue/jtable.min.css" /> <script type="text/javascript" src="../jtable/jquery.jtable.min.js"></script> <script type="text/javascript" src="../jtable/localization/jquery.jtable.zh-CN.js"></script> 注:jTable插件需要jquery UI插件。之前要引入jQuery和jQueryUI 【】Servlet生成JSON结果 collegeList=collegeBusiness.getListByAll(); //定义数据返回JSON map Map<String, Object> jsonMap = new HashMap<String, Object>(); jsonMap.put("Result", "OK"); jsonMap.put("Records", collegeList); JSONObject result=JSONObject.fromObject(jsonMap); HttpServletResponse response=ServletActionContext.getResponse(); response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); PrintWriter out=response.getWriter(); out.println(result.toString()); out.flush(); out.close(); 【】jtable要求的返回格式 {  "Result":"OK",  "Records":[   {"PersonId":1,"Name":"Benjamin Button","Age":17,"RecordDate":"\/Date(1320259705710)\/"},   {"PersonId":2,"Name":"Douglas Adams","Age":42,"RecordDate":"\/Date(1320259705710)\/"},   {"PersonId":3,"Name":"Isaac Asimov","Age":26,"RecordDate":"\/Date(1320259705710)\/"},   {"PersonId":4,"Name":"Thomas More","Age":65,"RecordDate":"\/Date(1320259705710)\/"}  ] } 【】当出现异常后的jTable要求的结果 {    "Result":"ERROR",    "Message":"异常信息字符串" } 【】jTable的语法  $('#MyTableContainer').jtable({             //General options comes here             actions: {                 //Action definitions comes here             },             fields: {                 //Field definitions comes here             }             //Event handlers... });      【】jtable初始化 1.定义jTable显示的区域div

    2.在JS中初始化jTable //定义部门表格 $('div#departmentmaincontent').jtable({            title: '部门列表',            selecting: true, //Enable selecting            multiselect: false, //not Allow mu

    04
    领券