Console - changing sizes of InputArea and OutputArea

View: New views
5 Messages — Rating Filter:   Alert me  

Console - changing sizes of InputArea and OutputArea

by cshannon2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am currently launching the Groovy Console successfully in my code, but would like to change the size of the window when it is displayed.

I am able to grab the JFrame, and set its size correctly with something like this:

console.getFrame().setSize(577, 707);

The problem is that I cannot figure out how to automatically move the split between the InputArea and the OutputArea.  I'd like to launch the Console with a larger InputArea than OutputArea, but there always seems to be a 50/50 split between the two no matter what.

As a user, I can change the split in the GUI without issue, but I'd like to do the same thing in my Java code.  What's interesting is that when I set the frame size with the command above, the Console initially displays an uneven split which I would want - but then ends up as 50/50 by the time everything is rendered on the screen.

Thanks,
Chris

Re: Console - changing sizes of InputArea and OutputArea

by shemnon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The split pane is not manipulated by any of the controller methods, so it doesn't have a property in the controller.  To get the instance of the split pane you can go through the SwingBuilder instance 'swing' and the pane happens to be stored in the 'splitPane' variable in the SwingBuilderBinding... so

console.swing.splitPane.dividerLocation = 200

In this case, dividerLocation represents the pixel size of the inputArea, or the upper component.

As far as the pane resizing, what you are noticing in the auto-resizing is the use of resizeWeight, which we set to 0.5.  If you want to maintain the top or bottom sizes you can set it to 0.0 or 1.0 respectively.

On Mon, Jun 30, 2008 at 9:34 AM, cshannon2 <w60001@...> wrote:

I am currently launching the Groovy Console successfully in my code, but
would like to change the size of the window when it is displayed.

I am able to grab the JFrame, and set its size correctly with something like
this:

console.getFrame().setSize(577, 707);

The problem is that I cannot figure out how to automatically move the split
between the InputArea and the OutputArea.  I'd like to launch the Console
with a larger InputArea than OutputArea, but there always seems to be a
50/50 split between the two no matter what.

As a user, I can change the split in the GUI without issue, but I'd like to
do the same thing in my Java code.  What's interesting is that when I set
the frame size with the command above, the Console initially displays an
uneven split which I would want - but then ends up as 50/50 by the time
everything is rendered on the screen.

Thanks,
Chris
--
View this message in context: http://www.nabble.com/Console---changing-sizes-of-InputArea-and-OutputArea-tp18198146p18198146.html
Sent from the groovy - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





--
------------------------------------------------------
I'm Danno Ferrin, and I approved this message.

Re: Console - changing sizes of InputArea and OutputArea

by cshannon2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm not sure if it's something in the way I'm using Groovy, but I cannot access splitPane (or console.swing without using console.getSwing() instead)...

I'm actually creating and editing the console in a separate Java application, which is including Groovy as a jar library.  My Java application is basically doing:

import groovy.ui.Console;

...

Console console = new Console();
console.run();
console.getFrame().setSize(577, 707);

...

My Java app sees swing as a private member of console, so it will not compile if I access "console.swing" directly.  But I can get the handle using console.getSwing().  Once I do this, though, I cannot access splitPane.  Perhaps this is only a problem because I'm embedding Groovy in Java (and it would be easier if only dealing with Groovy scripts)?

Anyways, I can get to the SplitPaneFactory from SwingBuilder, but I don't believe this helps me...

Thanks,
Chris

shemnon wrote:
The split pane is not manipulated by any of the controller methods, so it
doesn't have a property in the controller.  To get the instance of the split
pane you can go through the SwingBuilder instance 'swing' and the pane
happens to be stored in the 'splitPane' variable in the
SwingBuilderBinding... so

console.swing.splitPane.dividerLocation = 200

In this case, dividerLocation represents the pixel size of the inputArea, or
the upper component.

As far as the pane resizing, what you are noticing in the auto-resizing is
the use of resizeWeight, which we set to 0.5.  If you want to maintain the
top or bottom sizes you can set it to 0.0 or 1.0 respectively.

On Mon, Jun 30, 2008 at 9:34 AM, cshannon2 <w60001@gmail.com> wrote:

>
> I am currently launching the Groovy Console successfully in my code, but
> would like to change the size of the window when it is displayed.
>
> I am able to grab the JFrame, and set its size correctly with something
> like
> this:
>
> console.getFrame().setSize(577, 707);
>
> The problem is that I cannot figure out how to automatically move the split
> between the InputArea and the OutputArea.  I'd like to launch the Console
> with a larger InputArea than OutputArea, but there always seems to be a
> 50/50 split between the two no matter what.
>
> As a user, I can change the split in the GUI without issue, but I'd like to
> do the same thing in my Java code.  What's interesting is that when I set
> the frame size with the command above, the Console initially displays an
> uneven split which I would want - but then ends up as 50/50 by the time
> everything is rendered on the screen.
>
> Thanks,
> Chris
> --
> View this message in context:
> http://www.nabble.com/Console---changing-sizes-of-InputArea-and-OutputArea-tp18198146p18198146.html
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


--
------------------------------------------------------
I'm Danno Ferrin, and I approved this message.

Re: Console - changing sizes of InputArea and OutputArea

by shemnon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Java application, yes this changes things.  I was thinking in Groovy

the 'swing' property is a JavaBeans property, so getSwing() is appropriate.

As for the 'splitPane' variable, use getVariable("splitPane") and cast it to JSplitPane.


import groovy.ui.Console;
import javax.swing.JSplitPane;

//...

Console console = new Console();
console.run();
JSplitPane pane = (JSplitPane)console.getSwing().getVariable("splitPane");
pane.setResizeWeight(0); 
//pane.setDividerLocation(650);
console.getFrame().setSize(577, 707);



On Tue, Jul 1, 2008 at 8:32 AM, cshannon2 <w60001@...> wrote:

I'm not sure if it's something in the way I'm using Groovy, but I cannot
access splitPane (or console.swing without using console.getSwing()
instead)...

I'm actually creating and editing the console in a separate Java
application, which is including Groovy as a jar library.  My Java
application is basically doing:

import groovy.ui.Console;

...

Console console = new Console();
console.run();
console.getFrame().setSize(577, 707);

...

My Java app sees swing as a private member of console, so it will not
compile if I access "console.swing" directly.  But I can get the handle
using console.getSwing().  Once I do this, though, I cannot access
splitPane.  Perhaps this is only a problem because I'm embedding Groovy in
Java (and it would be easier if only dealing with Groovy scripts)?

Anyways, I can get to the SplitPaneFactory from SwingBuilder, but I don't
believe this helps me...

Thanks,
Chris


shemnon wrote:
>
> The split pane is not manipulated by any of the controller methods, so it
> doesn't have a property in the controller.  To get the instance of the
> split
> pane you can go through the SwingBuilder instance 'swing' and the pane
> happens to be stored in the 'splitPane' variable in the
> SwingBuilderBinding... so
>
> console.swing.splitPane.dividerLocation = 200
>
> In this case, dividerLocation represents the pixel size of the inputArea,
> or
> the upper component.
>
> As far as the pane resizing, what you are noticing in the auto-resizing is
> the use of resizeWeight, which we set to 0.5.  If you want to maintain the
> top or bottom sizes you can set it to 0.0 or 1.0 respectively.
>
> On Mon, Jun 30, 2008 at 9:34 AM, cshannon2 <w60001@...> wrote:
>
>>
>> I am currently launching the Groovy Console successfully in my code, but
>> would like to change the size of the window when it is displayed.
>>
>> I am able to grab the JFrame, and set its size correctly with something
>> like
>> this:
>>
>> console.getFrame().setSize(577, 707);
>>
>> The problem is that I cannot figure out how to automatically move the
>> split
>> between the InputArea and the OutputArea.  I'd like to launch the Console
>> with a larger InputArea than OutputArea, but there always seems to be a
>> 50/50 split between the two no matter what.
>>
>> As a user, I can change the split in the GUI without issue, but I'd like
>> to
>> do the same thing in my Java code.  What's interesting is that when I set
>> the frame size with the command above, the Console initially displays an
>> uneven split which I would want - but then ends up as 50/50 by the time
>> everything is rendered on the screen.
>>
>> Thanks,
>> Chris
>> --
>> View this message in context:
>> http://www.nabble.com/Console---changing-sizes-of-InputArea-and-OutputArea-tp18198146p18198146.html
>> Sent from the groovy - user mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>
>
> --
> ------------------------------------------------------
> I'm Danno Ferrin, and I approved this message.
>
>

--
View this message in context: http://www.nabble.com/Console---changing-sizes-of-InputArea-and-OutputArea-tp18198146p18216542.html
Sent from the groovy - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





--
------------------------------------------------------
I'm Danno Ferrin, and I approved this message.

Re: Console - changing sizes of InputArea and OutputArea

by cshannon2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This worked great, and did exactly what I was looking for.  Thanks!
LightInTheBox - Buy quality products at wholesale price