本文整理匯總了Java中javax.swing.JTable.setRowHeight方法的典型用法代碼示例。如果您正苦於以下問題:Java JTable.setRowHeight方法的具體用法?Java JTable.setRowHeight怎麽用?Java JTable.setRowHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.setRowHeight方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: update
import javax.swing.JTable; //導入方法依賴的package包/類
void update(MapRule rule,JTable table,int row){
this.rule=rule;
int rowHeight=50;
int h=table.getRowHeight(row);
if(h!=rowHeight){
table.setRowHeight(row, rowHeight);
}
String name=rule.getName();
if(name==null){
name="無";
}else if(name.trim().equals("")){
name="無";
}
label_wan_address.setText("名稱: "+rule.name+" 加速端口: "+rule.dst_port);
label2.setText("本地端口: "+rule.getListen_port());
}
示例2: init
import javax.swing.JTable; //導入方法依賴的package包/類
private void init(JLabel label, String[] columns) {
tableModel = new PropertiesTableModel(columns);
tableModel.addTableModelListener(this);
table = new JTable(tableModel);
table.getTableHeader().setReorderingAllowed(false);
table.setDefaultRenderer(String.class, new PropertiesTableCellRenderer());
//table.setDefaultEditor(CommitOptions.class, new CommitOptionsCellEditor());
table.setRowHeight(table.getRowHeight());
table.addAncestorListener(this);
component = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
component.setPreferredSize(new Dimension(340, 150));
table.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PropertiesTable.class, "ACSD_PropertiesTable")); // NOI18N
table.getAccessibleContext().setAccessibleName(NbBundle.getMessage(PropertiesTable.class, "ACSN_PropertiesTable")); // NOI18N
label.setLabelFor(table);
setColumns(columns);
}
示例3: CourseListPanel
import javax.swing.JTable; //導入方法依賴的package包/類
/**
* Create the panel.
*/
public CourseListPanel(String user,ProfessorFrame pf) throws Exception{
setLayout(new BorderLayout(0, 0));
TableCellRenderer buttonRenderer = new ButtonRenderer();
dao = new ProfessorDAO();
model=new tableModelTeach(dao.getAllCourses(user),user,pf);
table = new JTable();
table.setRowHeight(30);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setDefaultRenderer(JButton.class,buttonRenderer);
table.addMouseListener(new JTableButtonMouseListener(table));
table.setModel(model);
JScrollPane scrollPane = new JScrollPane(table,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
//resizeColumnWidth(table);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
TableColumnModel tcm = table.getColumnModel();
tcm.getColumn(0).setPreferredWidth(800);
tcm.getColumn(1).setPreferredWidth(200);
scrollPane.setBounds(10, 57, 1320, 450);
add(scrollPane, BorderLayout.CENTER);
}
示例4: buildTablePanel
import javax.swing.JTable; //導入方法依賴的package包/類
private JScrollPane buildTablePanel() {
table = new JTable(new AddressBookTableModel(),new DefaultTableColumnModel());
TableColumn nameColumn = new TableColumn(0);
TableColumn addressColumn = new TableColumn(1);
table.addColumn(nameColumn);
table.addColumn(addressColumn);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // one at a time
table.getSelectionModel().addListSelectionListener(new AddressListSelectionListener());
table.addMouseListener(new AddressMouseListener());
// TODO: isolate in utility
TableCellRenderer renderer = table.getCellRenderer(0, 0);
Component comp = renderer.getTableCellRendererComponent(table, "123", false, false, 0, 0);
table.setRowHeight(new Double(comp.getPreferredSize().getHeight()).intValue() + 2);
JScrollPane scrollPane = new JScrollPane(table);
return scrollPane;
}
示例5: printDifferentRowHeight
import javax.swing.JTable; //導入方法依賴的package包/類
private static void printDifferentRowHeight() {
final JTable table = createAuthorTable(50);
table.setRowHeight(15, table.getRowHeight(15)+10);
Printable printable = table.getPrintable(
JTable.PrintMode.NORMAL,
new MessageFormat("Author Table"),
new MessageFormat("Page - {0}"));
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(printable);
boolean printAccepted = job.printDialog();
if (printAccepted) {
try {
job.print();
closeFrame();
} catch (PrinterException e) {
throw new RuntimeException(e);
}
}
}
示例6: getTableCellRendererComponent
import javax.swing.JTable; //導入方法依賴的package包/類
@Override
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row,
int column) {
JLabel classNameLabel = new JLabel(
((Class<?>) value).getSimpleName());
table.setRowHeight(row, Math.max(table.getRowHeight(row),
(int) classNameLabel.getPreferredSize().getHeight()));
TableColumn cm = table.getColumnModel().getColumn(column);
cm.setMinWidth(Math.max(cm.getMinWidth(), (int) classNameLabel
.getMinimumSize().getWidth()));
return classNameLabel;
}
示例7: configureRowHeight
import javax.swing.JTable; //導入方法依賴的package包/類
public static void configureRowHeight(JTable table) {
int height = table.getRowHeight();
Font cellFont = UIManager.getFont("TextField.font");
if (cellFont != null) {
FontMetrics metrics = table.getFontMetrics(cellFont);
if (metrics != null) {
height = metrics.getHeight() + 2;
}
}
table.setRowHeight(Math.max(table.getRowHeight(), height));
}
示例8: getTableCellEditorComponent
import javax.swing.JTable; //導入方法依賴的package包/類
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
this.table = table;
this.row = row;
this.column = column;
this.originalRowHeight = table.getRowHeight(row);
this.confirmationKey = KeyEvent.VK_UNDEFINED;
table.setRowHeight(row, (int) (originalRowHeight*1.5));
return this.getEditorComponent(value);
}
示例9: show
import javax.swing.JTable; //導入方法依賴的package包/類
public void show(int dif) {
ArrayList<record> rec = new ArrayList<record>();
String content = FileHelper.readFromFile("ranking.ini");
if (content != null ) {
if(!content.equals("")) {
String[] sp = content.split(",");
for (int i = 0; i < sp.length; i = i + 3) {
if (dif == Integer.parseInt(sp[i])) {
rec.add(new record(sp[i + 2], Integer.parseInt(sp[i + 1])));
}
}
}
Collections.sort(rec);
rank = new Object[rec.size()][COL];
for (int i = 0; i < rec.size(); i++) {
record temp = rec.get(i);
rank[i][0] = i + 1;
rank[i][2] = temp.date;
rank[i][1] = temp.score;
}
table = new JTable(rank, title);
centerPanel.removeAll();
centerPanel.setLayout(new BorderLayout());
centerPanel.add(new JScrollPane(table), BorderLayout.CENTER);
DefaultTableCellRenderer r = new DefaultTableCellRenderer();
r.setHorizontalAlignment(JLabel.CENTER);
table.setDefaultRenderer(Object.class, r);
table.setRowHeight(20);
table.setFont(new Font("微軟雅黑", 0, 14));
table.setGridColor(Color.BLUE);
table.setSize(centerPanel.getWidth(), centerPanel.getHeight());
table.setRowSelectionAllowed(false);
}
setVisible(true);
}
示例10: getTableCellRendererComponent
import javax.swing.JTable; //導入方法依賴的package包/類
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
setText(value.toString());
setSize(table.getColumnModel().getColumn(column).getWidth(), getPreferredSize().height);
if (table.getRowHeight(row) != getPreferredSize().height) {
table.setRowHeight(row, getPreferredSize().height);
}
return this;
}
示例11: init
import javax.swing.JTable; //導入方法依賴的package包/類
private void init()
{
model = new DefaultTableModel()
{
private static final long serialVersionUID = 1L;
@Override
public Class<?> getColumnClass(int c)
{
Object value = getValueAt(0, c);
Class<?> cs = null;
if( value != null )
{
cs = value.getClass();
}
else
{
cs = super.getColumnClass(c);
}
return cs;
}
};
model.setColumnIdentifiers(getColumnNames());
table = new JTable(model);
table.getSelectionModel().addListSelectionListener(this);
table.setRowHeight(20);
int count = model.getColumnCount();
for( int i = 0; i < count; i++ )
{
TableColumn column = table.getColumnModel().getColumn(i);
processTableColumn(column, i);
}
table.doLayout();
this.setLayout(new BorderLayout());
this.add(new JScrollPane(table), BorderLayout.CENTER);
this.add(createBottom(), BorderLayout.SOUTH);
}
示例12: AttrTable
import javax.swing.JTable; //導入方法依賴的package包/類
public AttrTable(Window parent) {
super(new BorderLayout());
this.parent = parent;
titleEnabled = true;
title = new TitleLabel();
title.setHorizontalAlignment(SwingConstants.CENTER);
title.setVerticalAlignment(SwingConstants.CENTER);
tableModel = new TableModelAdapter(parent, NULL_ATTR_MODEL);
table = new JTable(tableModel);
table.setDefaultEditor(Object.class, editor);
table.setTableHeader(null);
table.setRowHeight(20);
Font baseFont = title.getFont();
int titleSize = Math.round(baseFont.getSize() * 1.2f);
Font titleFont = baseFont.deriveFont((float) titleSize).deriveFont(Font.BOLD);
title.setFont(titleFont);
Color bgColor = new Color(240, 240, 240);
setBackground(bgColor);
table.setBackground(bgColor);
Object renderer = table.getDefaultRenderer(String.class);
if (renderer instanceof JComponent) {
((JComponent) renderer).setBackground(Color.WHITE);
}
JScrollPane tableScroll = new JScrollPane(table);
this.add(title, BorderLayout.PAGE_START);
this.add(tableScroll, BorderLayout.CENTER);
LocaleManager.addLocaleListener(this);
localeChanged();
}
示例13: ResultsPane
import javax.swing.JTable; //導入方法依賴的package包/類
public ResultsPane(ResultsModel inModel)
{
setLayout(new BorderLayout());
mdl = inModel;
ColorTimeRenderer large = new ColorTimeRenderer(3);
ColorTimeRenderer medium = new ColorTimeRenderer(2);
//ColorTimeRenderer small = new ColorTimeRenderer(1);
DifferenceRenderer diff = new DifferenceRenderer();
tbl = new JTable(inModel) { public void tableChanged(TableModelEvent e) { super.tableChanged(e); scrollTable(); } };
tbl.setDefaultRenderer(ColorTime.class, new ColorTimeRenderer(1));
tbl.setRowHeight(140);
tbl.setRowSelectionAllowed(false);
//tbl.setIntercellSpacing(new Dimension(8, 8));
TableColumnModel tcm = tbl.getColumnModel();
columnStyle(tcm, 0, 50, 70, 200, medium);
columnStyle(tcm, 1, 50, 70, 200, medium);
columnStyle(tcm, 2, 80, 110, 280, large);
columnStyle(tcm, 3, 180, 230, 700, diff);
columnStyle(tcm, 4, 50, 70, 200, medium);
columnStyle(tcm, 5, 50, 70, 200, medium);
columnStyle(tcm, 6, 80, 110, 280, large);
JScrollPane scroll = new JScrollPane(tbl, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
add(scroll);
}
示例14: getTableCellEditorComponent
import javax.swing.JTable; //導入方法依賴的package包/類
@Override
public Component getTableCellEditorComponent(JTable table,
Object value, boolean isSelected, int row, int column) {
panel = new JPanel();
if (value instanceof String[]) {
String[] valueArray = (String[]) value;
if (valueArray.length == 0)
return panel;
GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
SequentialGroup cols = layout.createSequentialGroup();
layout.setHorizontalGroup(cols);
ParallelGroup col1 = layout
.createParallelGroup(GroupLayout.Alignment.LEADING);
ParallelGroup col2 = layout
.createParallelGroup(GroupLayout.Alignment.TRAILING);
cols.addGroup(col1)
.addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED,
GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(col2);
SequentialGroup rows = layout.createSequentialGroup();
layout.setVerticalGroup(rows);
for (int i = 0; i < valueArray.length; i++) {
// create the label. use the resource param name for both
// resource and demand params as it should be the same. TODO
JLabel label = new JLabel();
if (resParamNames.get(row).length == 0)
label.setText("max. param");
else
label.setText("max. " + resParamNames.get(row)[i]);
JTextField tf = new JTextField(3);
tf.setText(valueArray[i]);
tf.setEditable(true);
col1.addComponent(label);
col2.addComponent(tf, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE);
rows.addGroup(layout
.createParallelGroup(GroupLayout.Alignment.CENTER)
.addComponent(label).addComponent(tf));
}
}
table.setRowHeight(row, Math.max(table.getRowHeight(row),
(int) panel.getPreferredSize().getHeight()));
TableColumn cm = table.getColumnModel().getColumn(column);
cm.setMinWidth(Math.max(cm.getMinWidth(), (int) panel
.getPreferredSize().getWidth()));
return panel;
}
示例15: PanelCourses
import javax.swing.JTable; //導入方法依賴的package包/類
public PanelCourses(Student student,CourseOutline courseoutline) throws Exception{
this.co=courseoutline;
setLayout(new BorderLayout(0, 0));
cmdao=new CourseMappingDAO();
/*JScrollPane scrollPane = new JScrollPane();
add(scrollPane, BorderLayout.CENTER);*/
JLabel lblCoursesTaken = new JLabel("Courses Taken");
//scrollPane.setColumnHeaderView(lblCoursesTaken);
StudentCourseOutlineDAO sctodao = new StudentCourseOutlineDAO(student);
ArrayList<String> course = sctodao.Coursedata(student);
/* DefaultListModel<String> model = new DefaultListModel<>();
int size = course.size();
for(int i=0; i<size; i++){
model.addElement(course.get(i));
}
JList list = new JList(model);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent arg0) {
String course_name=(String)list.getSelectedValue();
//System.out.println("Course id is::"+course_name);
//System.out.println("Batch is ::"+student.getBatch());
String path=cmdao.getDirectoryPath(course_name, student.getBatch());
//System.out.println("Path is::"+path);
//System.out.println(path);
co.c_panel.curr_subject=course_name;
try {
co.c_panel.resetPanes(student, path);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
jb=(JLabel)co.panel.getComponent(7);
jb_c=(JLabel)co.panel.getComponent(6);
jb.setVisible(true);
jb_c.setVisible(true);
jb.setText(course_name);
CardLayout card=(CardLayout)co.panel_1.getLayout();
co.panel_2.getComponent(0).setEnabled(true);
card.show(co.panel_1, "CoursePanel");
}
});
scrollPane.setViewportView(list);*/
TableCellRenderer buttonRenderer = new ButtonRenderer();
model=new CourseTableModel(course,this,student);
table = new JTable();
table.setRowHeight(30);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setDefaultRenderer(JButton.class,buttonRenderer);
table.addMouseListener(new JTableButtonMouseListener(table));
table.setModel(model);
JScrollPane scrollPane = new JScrollPane(table,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
//resizeColumnWidth(table);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
TableColumnModel tcm = table.getColumnModel();
tcm.getColumn(0).setPreferredWidth(800);
tcm.getColumn(1).setPreferredWidth(200);
scrollPane.setBounds(10, 57, 1320, 450);
scrollPane.setColumnHeaderView(lblCoursesTaken);
add(scrollPane, BorderLayout.CENTER);
}