use of java.awt.Component in project hackpad by dropbox.
the class RunProxy method updateToolTip.
/**
* Updates the tool tip contents.
*/
private void updateToolTip() {
// Try to set tool tip on frame. On Mac OS X 10.5,
// the number of components is different, so try to be safe.
int n = getComponentCount() - 1;
if (n > 1) {
n = 1;
} else if (n < 0) {
return;
}
Component c = getComponent(n);
// this will work at least for Metal L&F
if (c != null && c instanceof JComponent) {
((JComponent) c).setToolTipText(getUrl());
}
}
use of java.awt.Component in project screenbird by adamhub.
the class RecorderPanel method showUploadMessage.
/*
* Upload methods
*/
/**
* Displays a message on the upload form, formatted with a text color.
* @param message
* @param type
*/
public void showUploadMessage(String message, Color type) {
int start = 0;
int end = 0;
Component focusedComponent = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (focusedComponent instanceof JTextComponent) {
end = ((JTextComponent) focusedComponent).getSelectionEnd();
start = ((JTextComponent) focusedComponent).getSelectionStart();
}
Dimension size = new Dimension(160, 14);
this.lblUploadMessage.setPreferredSize(size);
this.lblUploadMessage.setMinimumSize(size);
this.lblUploadMessage.setMaximumSize(size);
this.lblUploadMessage.setSize(size);
this.pbEncoding.setVisible(true);
this.pbEncoding.setForeground(type);
this.lblUploadMessage.validate();
this.lblUploadMessage.setText(message);
this.lblUploadMessage.setVisible(true);
this.lblUploadMessage.setForeground(type);
((JFrame) this.getParent().getParent().getParent().getParent()).pack();
this.redrawWindow();
if (focusedComponent instanceof JTextComponent) {
((JTextComponent) focusedComponent).grabFocus();
((JTextComponent) focusedComponent).setSelectionStart(start);
((JTextComponent) focusedComponent).setSelectionEnd(end);
}
}
use of java.awt.Component in project druid by alibaba.
the class ColumnGroup method getSize.
/**
* 取得合并后的单元格的大小,这个方法需要计算,首先 是取得一个没有合并的最小单元格的JTableHeader 的大小
* 通过Renderer取得组件
*
* @return
*/
public Dimension getSize(JTable table) {
Component comp = renderer.getTableCellRendererComponent(table, getHeaderValue(), false, false, -1, -1);
int height = comp.getPreferredSize().height;
int width = 0;
// 宽度需要计算合并的还要加上间隙
Enumeration<Object> enumeration = vector.elements();
while (enumeration.hasMoreElements()) {
Object obj = enumeration.nextElement();
if (obj instanceof TableColumn) {
TableColumn aColumn = (TableColumn) obj;
width += aColumn.getWidth();
width += margin;
} else {
width += ((ColumnGroup) obj).getSize(table).width;
}
}
return new Dimension(width, height);
}
use of java.awt.Component in project druid by alibaba.
the class GroupableTableHeaderUI method paintCell.
private void paintCell(Graphics g, Rectangle cellRect, ColumnGroup cGroup) {
TableCellRenderer renderer = cGroup.getHeaderRenderer();
//
if (renderer == null) {
renderer = new DefaultTableCellRenderer() {
private static final long serialVersionUID = 1L;
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JTableHeader header = table.getTableHeader();
if (header != null) {
setForeground(header.getForeground());
setBackground(header.getBackground());
setFont(header.getFont());
}
setHorizontalAlignment(JLabel.CENTER);
setText((value == null) ? "" : value.toString());
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
return this;
}
};
}
String headerValue = cGroup.getHeaderValue().toString();
Component component = renderer.getTableCellRendererComponent(header.getTable(), headerValue, false, false, -1, -1);
rendererPane.add(component);
rendererPane.paintComponent(g, component, header, cellRect.x, cellRect.y, cellRect.width, cellRect.height, true);
}
use of java.awt.Component in project druid by alibaba.
the class GroupableTableHeaderUI method paintCell.
private void paintCell(Graphics g, Rectangle cellRect, int columnIndex) {
TableColumn aColumn = header.getColumnModel().getColumn(columnIndex);
TableCellRenderer renderer = aColumn.getHeaderRenderer();
//
if (renderer == null) {
renderer = new DefaultTableCellRenderer() {
private static final long serialVersionUID = 1L;
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JTableHeader header = table.getTableHeader();
if (header != null) {
setForeground(header.getForeground());
setBackground(header.getBackground());
setFont(header.getFont());
}
setHorizontalAlignment(JLabel.CENTER);
setText((value == null) ? "" : value.toString());
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
return this;
}
};
}
String headerValue = aColumn.getHeaderValue().toString();
Component component = renderer.getTableCellRendererComponent(header.getTable(), headerValue, false, false, -1, columnIndex);
rendererPane.add(component);
rendererPane.paintComponent(g, component, header, cellRect.x, cellRect.y, cellRect.width, cellRect.height, true);
}
Aggregations