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: 
In c, you would want:

```
func1(&pNext);
func1(Object** pNext) { *pNext = ... }

```

In C++

```
func1(pNext);
func1(Object*& pNext) { pNext = ... }

```

In either language, your example would pass an uninitialized `Object*` to `func1`, which would copy it, assign a value to the copy and then return. Note that the original pNext never gets modified (it would help if you used different names for your variables).

In both languages you need to explicitly pass references if pass-by-reference rather than pass-by-value is desired.
Please initialize pNext when you instantiate it. It might be NULL now when you're debugging, but in the field it will be 0x12AbD468, or something. The if you have a test like:

```
if( NULL != pNext )
{
  pNext->DoSomething();
}

```

...and your program will explode, users will get mad, call support and somehow get your phone extension, call you directly and give you an earful.

In your case, since 'func1()' doesnt use pNext as an in-parameter, you can simply return it from the function:

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

Object* func1()
{
  return Segment->GetFirstPara(0);
}

```