本文整理匯總了Java中javax.swing.table.TableColumn.setMinWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java TableColumn.setMinWidth方法的具體用法?Java TableColumn.setMinWidth怎麽用?Java TableColumn.setMinWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.table.TableColumn
的用法示例。
在下文中一共展示了TableColumn.setMinWidth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: adjustColumnRatios
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
public void adjustColumnRatios()
{
TableColumnModel m = getColumnModel();
if (m == null) return;
TableColumn c;
int ii;
for (ii = 0; ii < m.getColumnCount()-1; ii++)
{
c = m.getColumn(ii);
c.setCellRenderer(seqRenderer);
c.setMinWidth(35);
c.setPreferredWidth(100);
c.setMaxWidth(Integer.MAX_VALUE/2);
}
if (ii < m.getColumnCount())
{
c = m.getColumn(ii);
c.setCellRenderer(totalRenderer);
c.setMinWidth(70);
c.setPreferredWidth(200);
c.setMaxWidth(Integer.MAX_VALUE);
}
}
示例2: adjustColumnWidths
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
protected void adjustColumnWidths() {
TableColumnModel colModel = getColumnModel();
for( int i=0; i<colModel.getColumnCount(); i++ ) {
TableColumn tc = colModel.getColumn( i );
int colWidth = 0;
for( int row=0; row<getRowCount(); row++ ) {
colWidth = Math.max( renderer.getPreferredWidth( getValueAt( row, i ) ), colWidth );
}
colWidth = Math.max( colWidth, 30 );
colWidth += getIntercellSpacing().width;
tc.setWidth( colWidth );
tc.setMinWidth( colWidth );
tc.setMaxWidth( colWidth );
tc.setPreferredWidth( colWidth );
tc.setResizable( false );
}
}
示例3: initTableVisualProperties
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
private void initTableVisualProperties(JTable table) {
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
table.setIntercellSpacing(new java.awt.Dimension(0, 0));
// set the color of the table's JViewport
table.getParent().setBackground(table.getBackground());
//we'll get the parents width so we can use that to set the column sizes.
double pw = table.getParent().getParent().getPreferredSize().getWidth();
//#88174 - Need horizontal scrollbar for library names
//ugly but I didn't find a better way how to do it
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
TableColumn column = table.getColumnModel().getColumn(0);
column.setMinWidth(226);
column.setWidth( ((int)pw/2) - 1 );
column.setPreferredWidth( ((int)pw/2) - 1 );
column.setMinWidth(75);
column = table.getColumnModel().getColumn(1);
column.setMinWidth(226);
column.setWidth( ((int)pw/2) - 1 );
column.setPreferredWidth( ((int)pw/2) - 1 );
column.setMinWidth(75);
this.addComponentListener(new TableColumnSizeComponentAdapter(table));
}
示例4: updateTableColumnSizes
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
private void updateTableColumnSizes() {
ETable table = tableView.getTable();
Font font = tableView.getFont();
FontMetrics fm = tableView.getFontMetrics(font);
int maxCharWidth = fm.charWidth('A');
int editingBorder = 4;
TableColumnModel columnModel = table.getColumnModel();
TableColumn nameColumn = columnModel.getColumn(0);
nameColumn.setPreferredWidth(8 * maxCharWidth + editingBorder); // 8 chars for name
TableColumn keyColumn = columnModel.getColumn(1);
// Single char for key (but 3 chars to prevent "..." in column header)
keyColumn.setPreferredWidth(3 * maxCharWidth + editingBorder);
keyColumn.setMinWidth(keyColumn.getPreferredWidth());
TableColumn locationColumn = columnModel.getColumn(2);
Insets insets = tableView.getBorder().getBorderInsets(tableView);
int remainingWidth = tableView.getParent().getWidth() - insets.left - insets.right;
remainingWidth -= 2 * columnModel.getColumnMargin();
remainingWidth -= nameColumn.getPreferredWidth();
remainingWidth -= keyColumn.getPreferredWidth();
locationColumn.setPreferredWidth(remainingWidth); // remaining space for location
}
示例5: hideColumn
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
void hideColumn(TableColumn column, ProfilerTable table) {
hiddenColumnWidths.put(column.getModelIndex(), column.getWidth());
column.setMinWidth(0);
column.setMaxWidth(0);
int selected = table.getSelectedColumn();
if (selected != -1 && getColumn(selected).equals(column)) {
int newSelected = getPreviousVisibleColumn(selected);
getSelectionModel().setSelectionInterval(newSelected, newSelected);
}
if (table.isSortable()) {
ProfilerRowSorter sorter = table._getRowSorter();
int sortColumn = sorter.getSortColumn();
if (sortColumn == column.getModelIndex()) {
int newSortColumn = table.convertColumnIndexToView(sortColumn);
newSortColumn = getPreviousVisibleColumn(newSortColumn);
sorter.setSortColumn(getColumn(newSortColumn).getModelIndex());
}
}
}
示例6: setColumnWidth
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
/**
* Sets the appropriate widths for the cells of the table.
*
* @param table
* JTable containing the brain.
*/
private void setColumnWidth(JTable table) {
final int numDirections = CollisionDirection.values().length;
int[] minimumWidths = new int[numDirections];
int[] preferredWidths = new int[numDirections];
int[] maximumWidths = new int[numDirections];
for (int i = 0; i < numDirections; i++) {
minimumWidths[i] = 50;
preferredWidths[i] = 150;
maximumWidths[i] = 1000;
}
minimumWidths = GeneralUtil.concatenate(new int[] { 50, 70 },
minimumWidths);
preferredWidths = GeneralUtil.concatenate(new int[] { 40, 200 },
preferredWidths);
maximumWidths = GeneralUtil.concatenate(new int[] { 50, 1000 },
maximumWidths);
for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) {
TableColumn column = table.getColumnModel().getColumn(i);
column.setMinWidth(minimumWidths[i]);
column.setPreferredWidth(preferredWidths[i]);
column.setMaxWidth(maximumWidths[i]);
}
}
示例7: setupKeyColumnWidth
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
private void setupKeyColumnWidth() {
FontUIResource font = (FontUIResource) UIManager.get("Table.font");
for (int j = 0; j < getColumnModel().getColumnCount(); j++) {
TableColumn column = getColumnModel().getColumn(j);
Integer columnWidth = columnWidthMap.get(j);
if (columnWidth != null) {
int fixedSize = columnWidth;
if (fixedSize == -1) {
double max = 0;
int rowCount = getModel().getRowCount();
for (int i = 0; i < rowCount; i++) {
String text = getValueAt(i, 0).toString();
int width = SwingUtils.getWidth(font, text);
max = Math.max(max, width);
}
fixedSize = (int) (max + 16 * 2);
}
column.setMinWidth(fixedSize);
column.setMaxWidth(fixedSize);
}
}
}
示例8: initColumsWidth
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
void initColumsWidth() {
for (int i = 0; i < 4; i++) {
TableColumn column = getColumnModel().getColumn(i);
if (i == 0) {
column.setPreferredWidth(32767);
}
else {
column.setMinWidth(100);
column.setPreferredWidth(100);
}
}
}
示例9: initColumsWidth
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
void initColumsWidth() {
for (int i = 0; i < getColumnCount(); i++) {
TableColumn column = getColumnModel().getColumn(i);
if (i == 0) {
column.setPreferredWidth(1500);
} else if (i == 1) {
column.setPreferredWidth(2000);
} else {
column.setMinWidth(200);
column.setPreferredWidth(200);
}
}
}
示例10: setColumnWidths
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
private void setColumnWidths(TableColumn col, int min, int pref, int max)
{
if (col == null) return;
col.setMinWidth(min);
col.setPreferredWidth(pref);
col.setMaxWidth(max);
}
示例11: setColumnWidth
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
private void setColumnWidth(int columnIndex) {
TableColumn col = jTableFields.getColumnModel().getColumn(columnIndex);
JCheckBox box = new JCheckBox();
int width = (int) box.getPreferredSize().getWidth();
col.setPreferredWidth(width);
col.setMinWidth(width);
col.setMaxWidth(width);
col.setResizable(false);
}
示例12: initProjectsTable
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
void initProjectsTable() {
projectsTable.setModel(new PrjTableModel());
for (int i = 0; i < 4; i++) {
TableColumn column = projectsTable.getColumnModel().getColumn(i);
if (i == 0) {
column.setPreferredWidth(32767);
}
else {
column.setMinWidth(80);
column.setPreferredWidth(80);
}
}
}
示例13: initProjectsTable
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
void initProjectsTable() {
projectsTable.setModel(new PrjTableModel());
projectsTable.setAutoCreateRowSorter(true);
for (int i = 0; i < 4; i++) {
TableColumn column = projectsTable.getColumnModel().getColumn(i);
if (i == 0) {
column.setPreferredWidth(100);
}
else {
column.setMinWidth(80);
column.setPreferredWidth(80);
}
}
}
示例14: initColumsWidth
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
/**
* Determine column width of table.
*/
void initColumsWidth() {
for (int i = 0; i < 4; i++) {
TableColumn column = getColumnModel().getColumn(i);
if (i == 0) {
column.setPreferredWidth(32767);
}
else {
column.setMinWidth(100);
column.setPreferredWidth(100);
}
}
}
示例15: initTable
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
private void initTable() {
TableColumn tagColumn = columnModel.getColumn(LogTableModel.COL_TAG);
TableColumn pidColumn = columnModel.getColumn(LogTableModel.COL_PID);
TableColumn pNameColumn = columnModel.getColumn(LogTableModel.COL_PROCESS);
TableColumn timeColumn = columnModel.getColumn(LogTableModel.COL_TIME);
TableColumn levelColumn = columnModel.getColumn(LogTableModel.COL_LEVEL);
tagColumn.setMinWidth(50);
tagColumn.setPreferredWidth(150);
tagColumn.setMaxWidth(300);
pidColumn.setMinWidth(35);
pidColumn.setPreferredWidth(50);
pidColumn.setMaxWidth(70);
pNameColumn.setMinWidth(60);
pNameColumn.setPreferredWidth(80);
pNameColumn.setMaxWidth(300);
timeColumn.setMinWidth(60);
timeColumn.setPreferredWidth(80);
timeColumn.setMaxWidth(120);
levelColumn.setMinWidth(20);
levelColumn.setPreferredWidth(80);
levelColumn.setMaxWidth(80);
}