javax.swing.JTable.getSize()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中javax.swing.JTable.getSize()方法的一些代码示例,展示了JTable.getSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTable.getSize()方法的具体详情如下:
包路径:javax.swing.JTable
类名称:JTable
方法名:getSize

JTable.getSize介绍

暂无

代码示例

代码示例来源:origin: winterDroid/android-drawable-importer-intellij-plugin

@Override
  public void componentResized(ComponentEvent componentEvent) {
    super.componentResized(componentEvent);
    Dimension tableSize = table.getSize();
    final int[] columnSizes = new int[]{ 20, 20, 20, 40 };
    for (int i = 0; i < table.getColumnCount(); i++) {
      TableColumn column = table.getColumnModel().getColumn(i);
      column.setPreferredWidth((int) (tableSize.width * (columnSizes[i] / 100f)));
    }
  }
});

代码示例来源:origin: girtel/Net2Plan

@Override
public void columnMarginChanged(ChangeEvent e)
{
  TableColumnModel tcm = (TableColumnModel) e.getSource();
  fixedTable.setPreferredScrollableViewportSize(new Dimension(tcm.getTotalColumnWidth(), fixedTable.getSize().height));
}

代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client

@Override
  public void mouseReleased(MouseEvent e) {
    if (SwingUtilities.isRightMouseButton(e)) {
      
      int[] selection = table.getSelectedRows();
      Object[][] selections = new Object[selection.length][table.getSize().width];
      for (int i = 0; i < selection.length; i++) {
        int j = table.convertRowIndexToModel(selection[i]);
        selections[i] = data[j];
      } 
      JPopupMenu m = createTablePopup(selections);
      if(m != null){
        m.show(e.getComponent(), e.getX(), e.getY());
      }                                          
    }
  }
});

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-dlight-visualizers

@Override
  public void keyPressed(KeyEvent e) {
    if ((e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU) || ((e.getKeyCode() == KeyEvent.VK_F10) && (e.getModifiers() == InputEvent.SHIFT_MASK))) {
      int selectedRow = table.getSelectedRow();
      if (selectedRow != -1) {
        Rectangle cellRect = table.getCellRect(selectedRow, 0, false);
        showLegend.setVisible(!isShowLegend);
        hideLegend.setVisible(isShowLegend);
        popupMenu.show(e.getComponent(), ((cellRect.x + table.getSize().width) > 50) ? 50 : 5, cellRect.y);
      }
    }
  }
});

代码示例来源:origin: org.rwshop/org.rwshop.swing.common

private void setVals(){
  Properties props = myService.getRegistrationProperties();
  Object[][] objs = new Object[props.size()][2];
  int i = 0;
  for(Entry e : props.entrySet()){
    objs[i][0] = e.getKey();
    objs[i][1] = e.getValue();
    i++;
  }
  tblProperties.setModel(new DefaultTableModel(
      objs, new String []{"Property Name", "Value"}));
  int h = tblProperties.getRowCount() * 
      (tblProperties.getRowHeight()+tblProperties.getRowMargin());
  Dimension dim = pnlProperties.getSize();
  dim.setSize(dim.width, h);
  Dimension dim2 = tblProperties.getSize();
  Dimension d2 = new Dimension(dim2.width, h);
  //tblProperties.setSize(d2);
  pnlProperties.setPreferredSize(d2);
}

代码示例来源:origin: org.jflux/org.jflux.swing.services

private void setVals(){
  Properties props = myService.getRegistrationProperties();
  Object[][] objs = new Object[props.size()][2];
  int i = 0;
  for(Entry e : props.entrySet()){
    objs[i][0] = e.getKey();
    objs[i][1] = e.getValue();
    i++;
  }
  tblProperties.setModel(new DefaultTableModel(
      objs, new String []{"Property Name", "Value"}));
  int h = tblProperties.getRowCount() * 
      (tblProperties.getRowHeight()+tblProperties.getRowMargin());
  Dimension dim = pnlProperties.getSize();
  dim.setSize(dim.width, h);
  Dimension dim2 = tblProperties.getSize();
  Dimension d2 = new Dimension(dim2.width, h);
  //tblProperties.setSize(d2);
  pnlProperties.setPreferredSize(d2);
}

代码示例来源:origin: org.rwshop/org.rwshop.swing.common

private void setVals(){
  Map<String, String> props =
      myService.getRegistrationStrategy().getRegistrationProperties(
      null);
  Object[][] objs = new Object[props.size()][2];
  int i = 0;
  for(Entry e : props.entrySet()){
    objs[i][0] = e.getKey();
    objs[i][1] = e.getValue();
    i++;
  }
  tblProperties.setModel(new DefaultTableModel(
      objs, new String []{"Property Name", "Value"}));
  int h = tblProperties.getRowCount() * 
      (tblProperties.getRowHeight()+tblProperties.getRowMargin());
  Dimension dim = pnlProperties.getSize();
  dim.setSize(dim.width, h);
  Dimension dim2 = tblProperties.getSize();
  Dimension d2 = new Dimension(dim2.width, h);
  //tblProperties.setSize(d2);
  pnlProperties.setPreferredSize(d2);
}

代码示例来源:origin: org.jflux/org.jflux.swing.services

private void setVals(){
  Map<String, String> props =
      myService.getRegistrationStrategy().getRegistrationProperties(
      null);
  Object[][] objs = new Object[props.size()][2];
  int i = 0;
  for(Entry e : props.entrySet()){
    objs[i][0] = e.getKey();
    objs[i][1] = e.getValue();
    i++;
  }
  tblProperties.setModel(new DefaultTableModel(
      objs, new String []{"Property Name", "Value"}));
  int h = tblProperties.getRowCount() * 
      (tblProperties.getRowHeight()+tblProperties.getRowMargin());
  Dimension dim = pnlProperties.getSize();
  dim.setSize(dim.width, h);
  Dimension dim2 = tblProperties.getSize();
  Dimension d2 = new Dimension(dim2.width, h);
  //tblProperties.setSize(d2);
  pnlProperties.setPreferredSize(d2);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

sourceSize = table.getSize();
} else if (component instanceof JViewport && ((JViewport) component).getView() instanceof JTable) {
  JViewport viewport = (JViewport) component;
  if (table.getSize().height > viewport.getSize().height) {
    source = viewport;
    sourceSize = viewport.getSize();
  } else {
    source = table;
    sourceSize = table.getSize();

代码示例来源:origin: stackoverflow.com

jScrollPane1 = new JScrollPane();
TableModel jTable1Model = new DefaultTableModel(...); 
JTable jTable1 = new JHorizontalFriendlyTable();
jScrollPane1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
jScrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
jScrollPane1.setViewPortView(jTable1);
jTable1.setModel(jTable1Model);
jTable1.setPreferredSize(new java.awt.Dimension(1051,518));
jTable1.setPreferredScrollableViewPortSize(new java.awt.Dimension(1000,528));
jTable1.getSize(new java.awt.Dimension(1051, 528));

if (jTable1.getPreferredScrollableViewPortSize().getWidth() > 
 ((JViewPort) jTable1.getParent()).getPreferredSize().getWidth())
 {
 jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
 jTable1.doLayout();
}

jTable1.setDragEnabled(false);
jTable1.setColumnSelectionAllowed(false);
jTable1.getTableHeader().setReorderingAllowed(false);

代码示例来源:origin: com.eas.platypus/platypus-js-grid

@Override
public void doLayout() {
  if (table != null) {
    table.setSize(getSize().width, table.getSize().height);
    table.doLayout();
  }
  super.doLayout();
}

代码示例来源:origin: apache/axis2-java

scrollPane.setSize(table.getSize());
scrollPane.setOpaque(true);
scrollPane.setBackground(getBackground());

代码示例来源:origin: stackoverflow.com

final JTable table = new JTable(dftm);        
 table.getColumnModel().addColumnModelListener(new TableColumnModelListener() {
   @Override
   public void columnAdded(TableColumnModelEvent e) {
     table.columnAdded(e);
   }
   @Override
   public void columnRemoved(TableColumnModelEvent e) {
     table.columnRemoved(e);
   }
   @Override
   public void columnMoved(TableColumnModelEvent e) {
     table.columnMoved(e);
   }
   @Override
   public void columnMarginChanged(ChangeEvent e) {
     Dimension tableSize = table.getSize();
     table.getColumn("Name").setWidth(100);
     table.getColumn("Category").setWidth(150);
     table.getColumn("Color").setWidth(Math.round((tableSize.width - 250)* 0.70f));
     table.getColumn("Ranking").setWidth(Math.round((tableSize.width - 250)* 0.30f));
   }
   @Override
   public void columnSelectionChanged(ListSelectionEvent e) {
     table.columnSelectionChanged(e);
   }
 });

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-common

final Dimension tableSize = table_.getSize();
tableSize.width += diff;
table_.setSize(tableSize);

代码示例来源:origin: RPTools/maptool

if (e.getPoint().x > getTableDefinitionTable().getSize().width - 15) {
  if (imageIdStr == null || imageIdStr.length() == 0) {
} else if (e.getPoint().x > getTableDefinitionTable().getSize().width - 30) {

代码示例来源:origin: in.jlibs/org-netbeans-swing-outline

Dimension tableSize = table.getSize();
tableSize.width += diff;
table.setSize(tableSize);

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf

Dimension tableSize=table.getSize();
tableSize.width+=diff;
table.setSize(tableSize);

相关文章

JTable类方法