本文整理了Java中javax.swing.JTable.setSize()
方法的一些代码示例,展示了JTable.setSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTable.setSize()
方法的具体详情如下:
包路径:javax.swing.JTable
类名称:JTable
方法名:setSize
暂无
代码示例来源:origin: stackoverflow.com
final JTable table = new JTable();
JLayeredPane layers = new JLayeredPane() {
@Override
public Dimension getPreferredSize() {
return table.getPreferredSize();
}
@Override
public void setSize(int width, int height) {
super.setSize(width, height);
table.setSize(width, height);
}
@Override
public void setSize(Dimension d) {
super.setSize(d);
table.setSize(d);
}
};
// NB you must use new Integer() - the int version is a different method
layers.add(label, new Integer(JLayeredPane.PALETTE_LAYER), 0);
JScrollPane scrolling = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scrolling.setViewportView(layers);
代码示例来源:origin: stackoverflow.com
JTable toPrint = new JTable(printModel);
toPrint.setSize(toPrint.getPreferredSize());
JTableHeader tableHeader = toPrint.getTableHeader();
tableHeader.setSize(tableHeader.getPreferredSize());
toPrint.print(JTable.PrintMode.FIT_WIDTH);
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
//init frame - main component
JFrame frame = new JFrame("SimpleTableDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
JPanel panel = new JPanel();
frame.setContentPane(panel);
DefaultTableModel model = new DefaultTableModel();
JTable table = new JTable(model);
model.addColumn("col1");
model.addColumn("col2");
model.addColumn("col3");
model.addColumn("col4");
for (int i=1;i<=100;i++){
model.addRow(new Object[]{i,1,2,3}); //output jtable row
}
table.setSize(600, 200);
JScrollPane scrollPane = new JScrollPane(table);
panel.add(scrollPane);
//Display the window.
frame.pack();
frame.setVisible(true);
}
代码示例来源:origin: stackoverflow.com
JTable table = new JTable(new AncientSwingTeam());
JTableHeader header =table.getTableHeader();
table.setSize(table.getPreferredSize());
header.setSize(header.getPreferredSize());
int w = Math.max(table.getWidth(), header.getWidth());
int h = table.getHeight() + header.getHeight();
BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = bi.createGraphics();
header.paint(g2);
g2.translate(0, header.getHeight());
table.paint(g2);
g2.dispose();
JLabel label = new JLabel(new ImageIcon(bi));
showInFrame(label, "image of table");
代码示例来源:origin: stackoverflow.com
jTable2.setSize(jTable2.getPreferredSize());
JTableHeader tableHeader = jTable2.getTableHeader();
tableHeader.setSize(tableHeader.getPreferredSize());
代码示例来源:origin: kaklakariada/portmapper
private JComponent getMappingsPanel() {
// Mappings panel
final ActionMap actionMap = this.getContext().getActionMap(this.getClass(), this);
tableModel = new PortMappingsTableModel(app);
mappingsTable = new JTable(tableModel);
mappingsTable.setAutoCreateRowSorter(true);
mappingsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
mappingsTable.setSize(new Dimension(400, 100));
mappingsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(final ListSelectionEvent e) {
firePropertyChange(PROPERTY_MAPPING_SELECTED, false, isMappingSelected());
}
});
final JScrollPane mappingsTabelPane = new JScrollPane();
mappingsTabelPane.setViewportView(mappingsTable);
final JPanel mappingsPanel = new JPanel(new MigLayout("", "[fill,grow]", "[grow,fill][]"));
mappingsPanel.setName("port_mappings");
final Border panelBorder = BorderFactory
.createTitledBorder(app.getResourceMap().getString("mainFrame.port_mappings.title"));
mappingsPanel.setBorder(panelBorder);
mappingsPanel.add(mappingsTabelPane, "height 100::, span 2, wrap");
mappingsPanel.add(new JButton(actionMap.get(ACTION_REMOVE_MAPPINGS)), "");
mappingsPanel.add(new JButton(actionMap.get(ACTION_UPDATE_PORT_MAPPINGS)), "wrap");
return mappingsPanel;
}
代码示例来源:origin: org.apache.directory/com.springsource.org.apache.directory.server.core
jPanel4.add( jScrollPane2, java.awt.BorderLayout.CENTER );
jScrollPane2.getViewport().add( m_resultsTbl );
m_resultsTbl.setSize( new java.awt.Dimension( 450, 10 ) );
m_resultsTbl.getSelectionModel().addListSelectionListener( this );
代码示例来源:origin: stackoverflow.com
JTable printTable = new JTable(table.getModel());
printTable.setSize(printTable.getPreferredSize());
JTableHeader tableHeader = printTable.getTableHeader();
tableHeader.setSize(tableHeader.getPreferredSize());
printTable.setShowHorizontalLines(false);
printTable.setShowVerticalLines(false);
printTable.print(JTable.PrintMode.FIT_WIDTH);
代码示例来源:origin: org.apache.directory.server/apacheds-xdbm-tools
jPanel4.add( jScrollPane2, java.awt.BorderLayout.CENTER );
jScrollPane2.getViewport().add( m_resultsTbl );
m_resultsTbl.setSize( new java.awt.Dimension( 450, 10 ) );
m_resultsTbl.getSelectionModel().addListSelectionListener( this );
代码示例来源: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: hs-web/hsweb-generator
/**
* 创建表格
*/
protected void createTable() {
final Object[][] cellData = new Object[][]{};
final DefaultTableModel model = new DefaultTableModel(cellData, columnNames);
final DefaultTableCellRenderer render = new DefaultTableCellRenderer();
render.setHorizontalAlignment(SwingConstants.CENTER);
table = new JTable(model) {
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
};
table.setDefaultRenderer(Object.class,render);
table.setSize(SwingGeneratorApplication.WIDTH - 70, 300);
table.setRowMargin(4);
table.setFont(SwingGeneratorApplication.BASIC_FONT_MIN);
table.setRowHeight(25);
table.setSelectionBackground(new Color(227, 227, 227));
for (Object[] objects : defaultData) {
model.addRow(objects);
}
}
代码示例来源:origin: apache/axis2-java
table.setBackground(getBackground());
table.setShowGrid(true);
table.setSize(getPreferredSize());
代码示例来源:origin: stackoverflow.com
table.setSize(table.getPreferredSize());
代码示例来源:origin: robo-code/robocode
protected void scrollPaneComponentResized() {
// This code is not working...
Dimension scrollPaneExtent = getScrollPane().getViewport().getExtentSize();
if (tableSize != null && (tableSize.width < scrollPaneExtent.width)) {
getTable().setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
getTable().setSize(scrollPaneExtent);
getTable().sizeColumnsToFit(-1);
} else {
if (tableSize != null) {
getTable().setSize(tableSize);
getTable().sizeColumnsToFit(-1);
}
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
}
validate();
repaint();
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-common
table_.setSize(tableSize);
代码示例来源:origin: in.jlibs/org-netbeans-swing-outline
table.setSize(tableSize);
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf
table.setSize(tableSize);
内容来源于网络,如有侵权,请联系作者删除!