Available Methods
- add ( )
- getInsets ( )
- getComponents ( )
- setLayout ( )
- getComponent ( )
- getComponentCount ( )
- isFocusCycleRoot ( )
- getParent ( )
- isFocusTraversalPolicyProvider ( )
- getTreeLock ( )
- getFocusTraversalPolicy ( )
- getFocusCycleRootAncestor ( )
- getLayout ( )
- getWidth ( )
- getHeight ( )
- getSize ( )
- repaint ( )
- getBounds ( )
- remove ( )
- invalidate ( )
- isDisplayable ( )
- getPeer ( )
- isShowing ( )
- revalidate ( )
- isVisible ( )
- validate ( )
- addNotify ( )
- removeAll ( )
- isAncestorOf ( )
- addContainerListener ( )
- getX ( )
- isValid ( )
- setVisible ( )
- getPreferredSize ( )
- getY ( )
- setBackground ( )
- dispatchEvent ( )
- removeContainerListener ( )
- addMouseListener ( )
- setFont ( )
- getFont ( )
- getGraphics ( )
- setPreferredSize ( )
- getBackground ( )
Related Classes
- java.awt.Color
- java.awt.event.ActionEvent
- java.awt.event.ActionListener
- javax.swing.JPanel
- java.awt.Dimension
- javax.swing.JFrame
- java.awt.Font
- java.awt.event.MouseEvent
- javax.swing.JLabel
- java.awt.Graphics
- javax.swing.JButton
- java.awt.event.KeyEvent
- java.awt.BorderLayout
- javax.swing.JOptionPane
- java.awt.Component
- javax.swing.JScrollPane
- java.awt.event.WindowEvent
- java.awt.Rectangle
- java.awt.Toolkit
- javax.swing.JTextField
- javax.swing.SwingUtilities
- java.awt.event.MouseAdapter
- javax.swing.ImageIcon
- java.awt.Point
- javax.swing.JComponent
Java Code Examples for java.awt.Container#getGraphics()
The following examples show how to use
java.awt.Container#getGraphics() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextPanel.java From osp with GNU General Public License v3.0 | 6 votes |
/** * Gets the preferred size of this component. * @return a dimension object indicating this component's preferred size * @see #getMinimumSize * @see LayoutManager */ public Dimension getPreferredSize() { Container c = this.getParent(); String text = this.text; // local reference for thread safety if((c==null)||text.equals("")) { //$NON-NLS-1$ return ZEROSIZE; } Graphics2D g2 = (Graphics2D) c.getGraphics(); if(g2==null) { return ZEROSIZE; } Font oldFont = g2.getFont(); g2.setFont(font); FontMetrics fm = g2.getFontMetrics(); int boxHeight = fm.getAscent()+4; // current string height int boxWidth = fm.stringWidth(text)+6; // current string width g2.setFont(oldFont); return new Dimension(boxWidth, boxHeight); }
Example 2
Source File: DGUI.java From Geom_Kisrhombille with GNU General Public License v3.0 | 5 votes |
public void paint(Graphics g){ if(dg.image!=null){ Container c=getContentPane(); int xoff=(c.getWidth()-dg.imagewidth)/2, yoff=(c.getHeight()-dg.imageheight)/2; t.setToIdentity(); t.translate(xoff,yoff); Graphics2D h=(Graphics2D)c.getGraphics(); h.drawImage(dg.image,t,null);}}