當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。