当前位置: 首页>>代码示例>>Java>>正文


Java JTable.hasFocus方法代码示例

本文整理汇总了Java中javax.swing.JTable.hasFocus方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.hasFocus方法的具体用法?Java JTable.hasFocus怎么用?Java JTable.hasFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTable的用法示例。


在下文中一共展示了JTable.hasFocus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTableCellRendererComponent

import javax.swing.JTable; //导入方法依赖的package包/类
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row,
                                               int column) {
    ProfilerTable ptable = (ProfilerTable)table;
    
    currentRowOffset = row * rowHeight;
    currentFirst = column == 0 || isFirstColumn(table.getColumnModel(), column);
    currentFocused = !ptable.shadesUnfocusedSelection() || hasFocus || table.hasFocus();
    currentSelected = isSelected;
    
    Rectangle cellBounds = getRowBounds(row);
    currentX = cellBounds.x;
    currentWidth = cellBounds.width;
    
    customRendering = ptable.isCustomRendering();
    if (synthLikeUI != null) synthLikeUI.setSelected(isSelected);
    
    return this;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ProfilerTreeTable.java

示例2: getTableCellRendererComponent

import javax.swing.JTable; //导入方法依赖的package包/类
/**
  * @see javax.swing.table.TableCellRenderer.getTableCellRendererComponent(JTable, Object, boolean, boolean, int, int)
  */
 @Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
    int row, int column) {
   Icon icon = null;
   String tooltipText = null;
   String labelText = "";
   
   JLabel tableCellRendererComponent = (JLabel) super.getTableCellRendererComponent(
       table, value, isSelected, hasFocus, row, column);
   
   if (value instanceof GitChangeType) {
     RenderingInfo renderingInfo = getRenderingInfo((GitChangeType) value);
     if (renderingInfo != null) {
       icon = renderingInfo.getIcon();
       tooltipText = renderingInfo.getTooltip();
     }
   } else if (value instanceof String) {
     tooltipText = (String) value;
     String fileName = tooltipText.substring(tooltipText.lastIndexOf('/') + 1);
     if (!fileName.equals(tooltipText)) {
       tooltipText = tooltipText.replace("/" + fileName, "");
       tooltipText = fileName + " - " + tooltipText;
     }
     labelText = (String) value;
   }
   
   tableCellRendererComponent.setIcon(icon);
   tableCellRendererComponent.setToolTipText(tooltipText);
   tableCellRendererComponent.setText(labelText);
   
   // Active/inactive table selection
   if (table.isRowSelected(row)) {
     if (table.hasFocus()) {
       tableCellRendererComponent.setBackground(table.getSelectionBackground());
     } else if (!isContextMenuShowing) {
       Color defaultColor = table.getSelectionBackground();
       tableCellRendererComponent.setBackground(getInactiveSelectionColor(defaultColor));
     }
   } else {
     tableCellRendererComponent.setBackground(table.getBackground());
   }

   return tableCellRendererComponent;
 }
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:48,代码来源:ChangesPanel.java

示例3: getTableCellRendererComponent

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent (JTable t, Object o, boolean isSelected, boolean hasFocus, int row, int column) 
{
	Component cell = super.getTableCellRendererComponent(t, o, isSelected, hasFocus, row, column);

	if (isSelected && t.hasFocus())
	{
		setBackground(backgroundSelect);
	}
	else if (isSelected)
	{
		setBackground(backgroundSelectNoFocus);
		setBorder(new LineBorder(Color.RED, 2));
	}
	else
	{
		setBackground(Color.WHITE);
	}

	if (o instanceof Run)
	{
		Run r = (Run)o;
		EntryModel m = (EntryModel)t.getModel();

		if (!isSelected)
		{
			if (m.isBest(t.convertRowIndexToModel(row), r))
				setBackground(backgroundBest);
			else if (m.rowIsFull(t.convertRowIndexToModel(row)))
				setBackground(backgroundDone);
		}

		String display = NF.format(r.getRaw()) + " (" + r.getCones() + "," + r.getGates() + ")";
		if (!r.isOK())
			display= "<HTML><center>" + r.getStatus() + "<br><FONT size=-2>" + display;

		setText(display);

	}
	else if (o != null)
	{
		setBackground(Color.red); /* This shouldn't happen */
		setText(o.toString());
	}
	else
	{
		setText("");
	}

	return cell;
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:52,代码来源:RunsTable.java

示例4: getTableCellRendererComponent

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
    boolean hasFocus, int row, int column) {
    if (column == 0) {
        // setBackground(Color.lightGray);
        switch (row) {
            case 0:
                setText(FAdmin.getLocaleMessage("admin.calendar.month.january"));
                break;
            case 1:
                setText(FAdmin.getLocaleMessage("admin.calendar.month.february"));
                break;
            case 2:
                setText(FAdmin.getLocaleMessage("admin.calendar.month.march"));
                break;
            case 3:
                setText(FAdmin.getLocaleMessage("admin.calendar.month.april"));
                break;
            case 4:
                setText(FAdmin.getLocaleMessage("admin.calendar.month.may"));
                break;
            case 5:
                setText(FAdmin.getLocaleMessage("admin.calendar.month.june"));
                break;
            case 6:
                setText(FAdmin.getLocaleMessage("admin.calendar.month.july"));
                break;
            case 7:
                setText(FAdmin.getLocaleMessage("admin.calendar.month.augustus"));
                break;
            case 8:
                setText(FAdmin.getLocaleMessage("admin.calendar.month.september"));
                break;
            case 9:
                setText(FAdmin.getLocaleMessage("admin.calendar.month.october"));
                break;
            case 10:
                setText(FAdmin.getLocaleMessage("admin.calendar.month.november"));
                break;
            case 11:
                setText(FAdmin.getLocaleMessage("admin.calendar.month.december"));
                break;
        }
        final GridLayout gl = new GridLayout(1, 1);
        final JPanel panel = new JPanel(gl);
        panel.setBorder(new BevelBorder(0, panel.getBackground(), panel.getBackground()));
        panel.add(this);
        return panel;
    } else {
        setText("");
        // залочим несуществующие даты, таблица все же прямоугольная
        if (checkDate(row, column)) {
            if (isSelected && table.hasFocus()) {
                setBackground(((CalendarTableModel) table.getModel())
                    .addDay(getDate(row, column), /*!hasFocus*/
                        !(table.getSelectedColumnCount() == 1
                            && table.getSelectedRowCount() == 1))
                    ? Color.lightGray : getWorkColor(row));
            } else {
                setBackground(
                    ((CalendarTableModel) table.getModel()).isFreeDate(getDate(row, column))
                        != null
                        ? Color.lightGray : getWorkColor(row));
            }
        } else {
            setBackground(Color.black);
        }
    }
    setOpaque(true);
    table.getColumnModel().getColumn(column).setResizable(false);
    return this;
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:73,代码来源:TableCell.java


注:本文中的javax.swing.JTable.hasFocus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。