本文整理匯總了Java中javax.swing.CellRendererPane類的典型用法代碼示例。如果您正苦於以下問題:Java CellRendererPane類的具體用法?Java CellRendererPane怎麽用?Java CellRendererPane使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CellRendererPane類屬於javax.swing包,在下文中一共展示了CellRendererPane類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: scrollRectToVisible
import javax.swing.CellRendererPane; //導入依賴的package包/類
@Override
public void scrollRectToVisible(Rectangle contentRect) {
Container parent;
int dx = getX(), dy = getY();
for (parent = getParent();
!(parent == null) &&
!(parent instanceof JComponent) &&
!(parent instanceof CellRendererPane);
parent = parent.getParent()) {
Rectangle bounds = parent.getBounds();
dx += bounds.x;
dy += bounds.y;
}
if (!(parent == null) && !(parent instanceof CellRendererPane)) {
contentRect.x += dx;
contentRect.y += dy;
((JComponent) parent).scrollRectToVisible(contentRect);
contentRect.x -= dx;
contentRect.y -= dy;
}
}
示例2: mxGraphicsCanvas2D
import javax.swing.CellRendererPane; //導入依賴的package包/類
/**
* Constructs a new graphics export canvas.
*/
public mxGraphicsCanvas2D(Graphics2D g)
{
setGraphics(g);
state.g = g;
// Initializes the cell renderer pane for drawing HTML markup
try
{
rendererPane = new CellRendererPane();
}
catch (Exception e)
{
// ignore
}
}
示例3: MetalComboBoxButton
import javax.swing.CellRendererPane; //導入依賴的package包/類
/**
* Creates a new button.
*
* @param cb the combo that the button is used for (<code>null</code> not
* permitted).
* @param i the icon displayed on the button.
* @param onlyIcon a flag that specifies whether the button displays only an
* icon, or text as well.
* @param pane the rendering pane.
* @param list the list.
*/
public MetalComboBoxButton(JComboBox cb, Icon i, boolean onlyIcon,
CellRendererPane pane, JList list)
{
super();
if (cb == null)
throw new NullPointerException("Null 'cb' argument");
comboBox = cb;
comboIcon = i;
iconOnly = onlyIcon;
listBox = list;
rendererPane = pane;
setRolloverEnabled(false);
setEnabled(comboBox.isEnabled());
setFocusable(comboBox.isEnabled());
}
示例4: getScreenshot
import javax.swing.CellRendererPane; //導入依賴的package包/類
private BufferedImage getScreenshot(Container panel) {
Dimension size = new Dimension((int) panel.getPreferredSize().getWidth()+50, (int) panel.getPreferredSize().getHeight()+10);
panel.setSize(size);
this.layoutComponent(panel);
BufferedImage img = new BufferedImage(panel.getWidth(), panel.getHeight(), BufferedImage.TYPE_INT_RGB);
//Remove buttons panel
panel.getComponent(2).setVisible(false);
CellRendererPane crp = new CellRendererPane();
crp.add(panel);
crp.paintComponent(img.createGraphics(), panel, crp, panel.getBounds());
//Re-add buttons panel
panel.getComponent(2).setVisible(true);
return img;
}
示例5: PlasticComboBoxButton
import javax.swing.CellRendererPane; //導入依賴的package包/類
PlasticComboBoxButton(JComboBox comboBox, Icon comboIcon, boolean iconOnly, CellRendererPane rendererPane, JList listBox)
/* 36: */ {
/* 37: 80 */ super("");
/* 38: 81 */ setModel(new DefaultButtonModel()
/* 39: */ {
/* 40: */ public void setArmed(boolean armed)
/* 41: */ {
/* 42: 83 */ super.setArmed((isPressed()) || (armed));
/* 43: */ }
/* 44: 85 */ });
/* 45: 86 */ this.comboBox = comboBox;
/* 46: 87 */ this.comboIcon = comboIcon;
/* 47: 88 */ this.iconOnly = iconOnly;
/* 48: 89 */ this.rendererPane = rendererPane;
/* 49: 90 */ this.listBox = listBox;
/* 50: 91 */ setEnabled(comboBox.isEnabled());
/* 51: 92 */ setFocusable(false);
/* 52: 93 */ setRequestFocusEnabled(comboBox.isEnabled());
/* 53: 94 */ setBorder(UIManager.getBorder("ComboBox.arrowButtonBorder"));
/* 54: 95 */ setMargin(new Insets(0, 2, 0, 2));
/* 55: 96 */ this.borderPaintsFocus = UIManager.getBoolean("ComboBox.borderPaintsFocus");
/* 56: */ }
示例6: createCellRendererPane
import javax.swing.CellRendererPane; //導入依賴的package包/類
protected CellRendererPane createCellRendererPane()
{
return new CellRendererPane()
{
public void paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h, boolean shouldValidate)
{
w = p.getWidth() - x;
Insets m = p.getInsets();
if(m != null)
{
w -= m.right;
}
super.paintComponent(g, c, p, x, y, w, h, shouldValidate);
}
};
}
示例7: MetalComboBoxButton
import javax.swing.CellRendererPane; //導入依賴的package包/類
/**
* Creates a new button.
*
* @param cb the combo that the button is used for (<code>null</code> not
* permitted).
* @param i the icon displayed on the button.
* @param onlyIcon a flag that specifies whether the button displays only an
* icon, or text as well.
* @param pane the rendering pane.
* @param list the list.
*/
public MetalComboBoxButton(JComboBox cb, Icon i, boolean onlyIcon,
CellRendererPane pane, JList list)
{
super();
if (cb == null)
throw new NullPointerException("Null 'cb' argument");
comboBox = cb;
comboIcon = i;
iconOnly = onlyIcon;
listBox = list;
rendererPane = pane;
setRolloverEnabled(false);
setEnabled(comboBox.isEnabled());
setFocusable(comboBox.isEnabled());
}
示例8: installUI
import javax.swing.CellRendererPane; //導入依賴的package包/類
/**
* Initializes <code>this.list</code> by calling <code>installDefaults()</code>,
* <code>installListeners()</code>, and <code>installKeyboardActions()</code>
* in order.
*
* @see #installDefaults
* @see #installListeners
* @see #installKeyboardActions
*/
public void installUI(JComponent c)
{
list = (JXList)c;
layoutOrientation = list.getLayoutOrientation();
rendererPane = new CellRendererPane();
list.add(rendererPane);
columnCount = 1;
updateLayoutStateNeeded = modelChanged;
isLeftToRight = list.getComponentOrientation().isLeftToRight();
installDefaults();
installListeners();
installKeyboardActions();
installSortUI();
}
示例9: testZoomableCustomHeader
import javax.swing.CellRendererPane; //導入依賴的package包/類
/**
* Issue #77-swingx: support year-wise navigation.
* Alleviate the problem by allowing custom calendar headers.
*
* Here: test that the monthViewUI uses the custom header if available.
*/
@Test
public void testZoomableCustomHeader() {
UIManager.put(CalendarHeaderHandler.uiControllerID, "org.jdesktop.swingx.plaf.basic.SpinningCalendarHeaderHandler");
JXMonthView monthView = new JXMonthView();
monthView.setZoomable(true);
// digging into internals
Container header = (Container) monthView.getComponent(0);
if (header instanceof CellRendererPane) {
header = (Container) monthView.getComponent(1);
}
try {
assertTrue("expected SpinningCalendarHeader but was " + header.getClass(), header instanceof SpinningCalendarHeaderHandler.SpinningCalendarHeader);
} finally {
UIManager.put(CalendarHeaderHandler.uiControllerID, null);
}
}
示例10: installUI
import javax.swing.CellRendererPane; //導入依賴的package包/類
@Override
public void installUI( JComponent c ) {
if ( !( c instanceof JBroTableHeader ) )
throw new IllegalArgumentException( "Not a groupable header: " + c );
JBroTableHeader header = ( JBroTableHeader )c;
this.header = header;
int levelsCnt = table.getData() == null ? 0 : table.getData().getFieldGroups().size();
delegates = new ArrayList< ComponentUI >( levelsCnt );
headers = new ArrayList< JTableHeader >( levelsCnt );
rendererPanes = new ArrayList< CellRendererPane >( levelsCnt );
if ( heightsCache == null || heightsCache.length < levelsCnt )
heightsCache = new int[ levelsCnt ];
updateModel();
super.installUI( c );
SwingUtilities.updateComponentTreeUI( header );
for ( JTableHeader delegateHeader : headers )
SwingUtilities.updateComponentTreeUI( delegateHeader );
}
示例11: createCustomCellRendererPane
import javax.swing.CellRendererPane; //導入依賴的package包/類
/**
* Creates a custom {@link CellRendererPane} that sets the renderer
* component to be non-opqaque if the associated row isn't selected. This
* custom {@code CellRendererPane} is needed because a table UI delegate has
* no prepare renderer like {@link JTable} has.
*/
protected CellRendererPane createCustomCellRendererPane() {
return new CellRendererPane() {
@Override
public void paintComponent(Graphics graphics, Component component,
Container container, int x, int y, int w, int h,
boolean shouldValidate) {
int rowAtPoint = table.rowAtPoint(new Point(x, y));
boolean isSelected = table.isRowSelected(rowAtPoint);
if (component instanceof JComponent) {
JComponent jComponent = (JComponent) component;
jComponent.setOpaque(isSelected);
jComponent.setBorder(isSelected ? getSelectedRowBorder()
: getRowBorder());
jComponent.setBackground(isSelected ? table
.getSelectionBackground() : TRANSPARENT_COLOR);
}
super.paintComponent(graphics, component, container, x, y, w,
h, shouldValidate);
}
};
}
示例12: getAccessibleText
import javax.swing.CellRendererPane; //導入依賴的package包/類
public AccessibleText getAccessibleText() {
if (pane == null) {
//Cheat just a bit here - will do for now - the text is
//there, more or less where it should be, and a screen
//reader should be able to find it; exact bounds don't
//make much difference
pane = new JEditorPane();
pane.setBounds (panel.getBounds());
pane.getAccessibleContext().getAccessibleText();
pane.setFont (panel.getFont());
CellRendererPane cell = new CellRendererPane();
cell.add (pane);
}
pane.setText(getText());
pane.selectAll();
pane.validate();
return pane.getAccessibleContext().getAccessibleText();
}
示例13: testInstallUninstallComponents
import javax.swing.CellRendererPane; //導入依賴的package包/類
public void testInstallUninstallComponents() throws Exception {
ui.comboBox = comboBox;
ui.popup = new BasicComboPopup(comboBox);
ui.uninstallComponents();
assertEquals(0, ui.comboBox.getComponentCount());
assertNull(ui.arrowButton);
assertNull(ui.editor);
ui.installComponents();
assertEquals(2, ui.comboBox.getComponentCount());
assertTrue(ui.comboBox.getComponent(0) instanceof BasicArrowButton);
assertTrue(ui.comboBox.getComponent(1) instanceof CellRendererPane);
assertNotNull(ui.arrowButton);
assertNull(ui.editor);
ui.comboBox.add(new JLabel());
ui.uninstallComponents();
assertEquals(0, ui.comboBox.getComponentCount());
assertNull(ui.arrowButton);
assertNull(ui.editor);
comboBox.setEditable(true);
ui.installComponents();
assertNotNull(ui.arrowButton);
assertNotNull(ui.editor);
}
示例14: paintTable
import javax.swing.CellRendererPane; //導入依賴的package包/類
protected void paintTable(Graphics g) {
treeTableCellRenderer.prepareForTable(g);
Graphics cg = g.create(0, 0, treeTable.getWidth(), treeTable.getHeight());
try {
table.paint(cg);
} finally {
cg.dispose();
}
// JTable doesn't paint anything for the editing cell,
// so painting the background color is placed here
if (table.isEditing()) {
int col = table.getEditingColumn();
int row = table.getEditingRow();
boolean sel = treeTableCellRenderer.isSelected(
tree.isRowSelected(row) && table.isColumnSelected(col));
TreeTableCellRenderer r = treeTable.getCellRenderer(row, col);
Component c = r.getTreeTableCellRendererComponent(
treeTable, null, sel, false, row, col);
// TODO, create CellRendererPane for TreeTable, for use by the focus renderer too.
CellRendererPane rp = (CellRendererPane)table.getComponent(0);
Rectangle cell = table.getCellRect(row, col, true);
rp.paintComponent(g, c, table, cell.x, cell.y, cell.width, cell.height, true);
rp.removeAll();
}
}
示例15: installUI
import javax.swing.CellRendererPane; //導入依賴的package包/類
@Override
public void installUI(JComponent component) {
grid = (JGrid) component;
rendererPane = new CellRendererPane();
grid.add(rendererPane);
// gridHeader = (JGrid) component;
component.setOpaque(false);
LookAndFeel.installColorsAndFont(
component,
"TableHeader.background",
"TableHeader.foreground",
"TableHeader.font");
installDefaults();
installListeners();
installKeyboardActions();
}