Question: I have subclassed [`java.awt.Frame`](https://docs.oracle.com/javase/9/docs/api/java/awt/Frame.html) and have overridden the [`paint()`](https://docs.oracle.com/javase/9/docs/api/java/awt/Window.html#paint-java.awt.Graphics-) method as I wish to draw the entire contents of the window manually.

However, on the graphics object, (0,0) corresponds to the upper left hand corner of the window **inside** the title bar decoration, not the first drawable pixel.

Can I determine the co-ordinate of the first drawable pixel (ie, the height of the decoration) in a cross-platform manner, avoiding using a Mac OS X-specific [fudge factor](https://en.wikipedia.org/wiki/Fudge_factor)? Will I be forced to nest a [Panel](https://docs.oracle.com/javase/9/docs/api/java/awt/Panel.html) component in order to find the actual drawable area of the window?

Here, my code fails to centre the blue square inside the paintable area of the window:

```
@Override
public void paint (Graphics g) {
    g.setColor(Color.BLUE);
    g.setPaintMode();
    g.fillRect(30, 30, getWidth()-60, getHeight()-60);
}

```

Answer: 
For C++ only, you can make the parameter a reference

```
func()
{
    Object* pNext;
    func1(pNext);
}

func1(Object*& pNext)
{
    pNext = Segement->GetFirstPara(0);
}

```

What is going on here is the difference between passing parameters by value and passing by reference. C always passes by value. In order to get a value back, the value needs to be a reference value (e.g. Object\*\* refers to Object\* as a pointer). C++ adds reference parameters (signified by the &).
Pass by value only passes a copy of the data and never the actual data itself. That is why the variable used in the function call was not updated in the function.
To change a pointer, you need to pass a pointer to the pointer, ie `Object** pNext`. To change the value of a variable inside a function, you pass a pointer. Hence, by extension, to change the value of a pointer inside a function, pass a pointer to the pointer.

```
func() { 
    Object* pNext;
    func1(&pNext);
}

func1(Object** pNext) { *pNext = Segement->GetFirstPara(0); }

```