use of java.awt.Component in project jdk8u_jdk by JetBrains.
the class bug7170310 method check.
private static void check() {
try {
JViewport vp = null;
for (Component c : tabbedPane.getComponents()) {
if (c instanceof JViewport) {
vp = (JViewport) c;
break;
}
}
JComponent v = (JComponent) vp.getView();
Rectangle vr = vp.getViewRect();
Dimension vs = v.getSize();
// The tab view must be scrolled to the end so that the last tab is visible
if (vs.width != (vr.x + vr.width)) {
throw new RuntimeException("tabScroller.tabPanel view is positioned incorrectly: " + vs.width + " vs " + (vr.x + vr.width));
}
} catch (Exception e) {
exception = e;
}
}
use of java.awt.Component in project jdk8u_jdk by JetBrains.
the class DimensionEncapsulation method run.
@Override
public void run() {
runTest(new Panel());
runTest(new Button());
runTest(new Checkbox());
runTest(new Canvas());
runTest(new Choice());
runTest(new Label());
runTest(new Scrollbar());
runTest(new TextArea());
runTest(new TextField());
runTest(new Dialog(new JFrame()));
runTest(new Frame());
runTest(new Window(new JFrame()));
runTest(new FileDialog(new JFrame()));
runTest(new List());
runTest(new ScrollPane());
runTest(new JFrame());
runTest(new JDialog(new JFrame()));
runTest(new JWindow(new JFrame()));
runTest(new JLabel("hi"));
runTest(new JMenu());
runTest(new JTree());
runTest(new JTable());
runTest(new JMenuItem());
runTest(new JCheckBoxMenuItem());
runTest(new JToggleButton());
runTest(new JSpinner());
runTest(new JSlider());
runTest(Box.createVerticalBox());
runTest(Box.createHorizontalBox());
runTest(new JTextField());
runTest(new JTextArea());
runTest(new JTextPane());
runTest(new JPasswordField());
runTest(new JFormattedTextField());
runTest(new JEditorPane());
runTest(new JButton());
runTest(new JColorChooser());
runTest(new JFileChooser());
runTest(new JCheckBox());
runTest(new JInternalFrame());
runTest(new JDesktopPane());
runTest(new JTableHeader());
runTest(new JLayeredPane());
runTest(new JRootPane());
runTest(new JMenuBar());
runTest(new JOptionPane());
runTest(new JRadioButton());
runTest(new JRadioButtonMenuItem());
runTest(new JPopupMenu());
//runTest(new JScrollBar()); --> don't test defines max and min in
// terms of preferred
runTest(new JScrollPane());
runTest(new JViewport());
runTest(new JSplitPane());
runTest(new JTabbedPane());
runTest(new JToolBar());
runTest(new JSeparator());
runTest(new JProgressBar());
if (!failures.isEmpty()) {
System.out.println("These classes failed");
for (final Component failure : failures) {
System.out.println(failure.getClass());
}
throw new RuntimeException("Test failed");
}
}
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