Is there an event that should fire when an application is minimized?  I
can't find anything in Pivot that I can use to sync the state of the Swing
frame.

On Fri, Jun 17, 2016 at 1:23 PM, Roger and Beth Whitcomb <
rogerandb...@rbwhitcomb.com> wrote:

> Yeah, been pretty busy this week, but I should have a chance to look at
> our code some more in the next couple of days, but so far, it seems you are
> going in the correct direction.
>
> ~Roger
>
> On 6/17/16 11:11 AM, Sandro Martini wrote:
>
> Ok.
>
> I'm sorry because I can't help you so much in this feature, but maybe
> Roger can.
>
> Keep us updated.
>
> Thanks again.
> Bye
> Il 17/Giu/2016 19:18, "Josh Highley" < <joshhigh...@gmail.com>
> joshhigh...@gmail.com> ha scritto:
>
>> I will, but I'd like to figure out the event chaining first.  I'm having
>> issues getting the JDialog to behave in sync with my main application
>> window (Pivot).  Also, the app window isn't firing events like I'd expect
>> -- nothing when it loses focus or is minimized.  It does fire a
>> activeChanged event when it gains focus, though.  This makes it impossible
>> to know when to also minimize the JDialog.
>>
>> I set the JDialog alwaysOnTop to true so that it doesn't get lost behind
>> the app window. However, that makes the JDialog also stay on top of all
>> other windows  (web browser, IDE, etc) and the JDialog stays visible even
>> when the main app window is minimized.
>>
>> Roger implied they'd figured out the events, so I'm hoping he'll chime in
>> with some pointers.
>>
>> Thanks,
>>
>> Josh
>>
>>
>> On Thu, Jun 16, 2016 at 3:38 PM, Sandro Martini <
>> <sandro.mart...@gmail.com>sandro.mart...@gmail.com> wrote:
>>
>>> Hi Josh,
>>> thanks for sharing with us your work-in-progress ...
>>>
>>> Could you attach it in a jira issue ?
>>> So in this way we could integrate in Pivot sources in next release as a
>>> sample ...
>>>
>>> Bye,
>>> Sandro
>>> Il 16/Giu/2016 22:05, "Josh Highley" <joshhigh...@gmail.com> ha scritto:
>>>
>>> Documenting my progress in case others need this in the future.  I found
>>> the SwingDemo code in the Pivot SVN, which got me started.  I ended up
>>> using a JDialog instead of JFrame because I didn't want the minimize or
>>> maximize buttons, or a separate task bar item.
>>>
>>> I'm still trying to figure some things out, mainly the simplest way to
>>> tie the JDialog's AWT events (WindowListener) to Pivots window events.  I
>>> need to fire Pivot window state events so that other Pivot components are
>>> kept in sync with this dialog's window state.  Also, minimizing my main
>>> application's window does not also hide this dialog. Again, need to tie
>>> events between Pivot and Swing/AWT.
>>>
>>>
>>> This code is still a work in progress.  I _think_ I've removed my
>>> app-specific code, but no guarantee it will compile.
>>>
>>> import java.awt.Dimension;
>>>
>>> import java.awt.Image;
>>>
>>> import java.awt.Point;
>>>
>>> import java.awt.event.WindowEvent;
>>>
>>> import java.awt.event.WindowListener;
>>>
>>> import java.awt.image.BufferedImage;
>>>
>>>
>>> import javax.swing.JDesktopPane;
>>>
>>> import javax.swing.JDialog;
>>>
>>> import javax.swing.JInternalFrame;
>>>
>>> import javax.swing.plaf.basic.BasicInternalFrameUI;
>>>
>>>
>>> import org.apache.pivot.beans.BXML;
>>>
>>> import org.apache.pivot.beans.BXMLSerializer;
>>>
>>> import org.apache.pivot.wtk.ApplicationContext;
>>>
>>> import org.apache.pivot.wtk.Container;
>>>
>>> import org.apache.pivot.wtk.Form;
>>>
>>> import org.apache.pivot.wtk.Window;
>>>
>>>
>>>
>>> public class MyDialog  extends Window implements WindowListener
>>>
>>> {
>>>
>>>        // replace the default coffee cup icon
>>>
>>>        private static final Image *ICON* = new
>>>  BufferedImage(1,1,BufferedImage.*TYPE_INT_ARGB_PRE*);
>>>
>>>        private JDialog jDialog;
>>>
>>>
>>>
>>>        public MyDialog() {
>>>
>>>               super();
>>>
>>>
>>>
>>>               try {
>>>
>>>
>>>               JDesktopPane desktop = new JDesktopPane();
>>>
>>>               ApplicationContext.DisplayHost displayHost = new
>>>  ApplicationContext.DisplayHost();
>>>
>>>               ApplicationContext.*getDisplays*().add(displayHost
>>> .getDisplay());
>>>
>>>
>>>
>>>               jDialog = new JDialog();
>>>
>>>               jDialog.setTitle(*"My Dialog"*);
>>>
>>>               jDialog.setIconImage(*ICON*);
>>>
>>>               jDialog.setAlwaysOnTop(true);
>>>
>>>               jDialog.addWindowListener(this);
>>>
>>>                jDialog.setContentPane(desktop);
>>>
>>>                jDialog.setSize(1024, 768);
>>>
>>>                jDialog.setVisible(true);
>>>
>>>                jDialog.setResizable(true);
>>>
>>>
>>>
>>>                JInternalFrame internalFrame = new JInternalFrame("",
>>> false, false, false);
>>>
>>>                internalFrame.add(displayHost);
>>>
>>>                // remove the JInternalFrame border and title bar since
>>> JDialog provides this
>>>
>>>                internalFrame.setBorder(null);
>>>
>>>                ((BasicInternalFrameUI)internalFrame
>>> .getUI()).setNorthPane(null);
>>>
>>>
>>>
>>>                desktop.add(internalFrame);
>>>
>>>
>>>
>>>                // maximize our Pivot content to size it with the Swing
>>> container
>>>
>>>                 setMaximized(true);
>>>
>>>                 BXMLSerializer bxmlSerializer = new BXMLSerializer();
>>>
>>>                 setContent((Container) bxmlSerializer
>>> .readObject(Container.class, "my_dialog.bxml"));
>>>
>>>                 bxmlSerializer.bind(this, MyDialog.class);
>>>
>>>
>>>
>>>                 open(displayHost.getDisplay());
>>>
>>>
>>>
>>>                internalFrame.setMaximum(true);
>>>
>>>                internalFrame.setLocation(0, 0);
>>>
>>>                internalFrame.setSize(desktop.getSize());
>>>
>>>                internalFrame.setVisible(true);
>>>
>>>
>>>
>>>               } catch (Throwable t) {
>>>
>>>                      t.printStackTrace();
>>>
>>>               }
>>>
>>>        }
>>>
>>>
>>>
>>>        @Override
>>>
>>>        public void setVisible(boolean visible) {
>>>
>>>               jDialog.setVisible(visible);
>>>
>>>        }
>>>
>>>
>>>
>>>        private void saveSizeAndLocation() {
>>>
>>>               // removed code to save preferences  jDialog.getLocation());
>>>    jDialog.getSize());
>>>
>>>        }
>>>
>>>
>>>
>>>        private void setSizeAndLocation() {
>>>
>>>            // removed code to load preferences        jFrjDialogme
>>> .setSize((Dimension)obj);     jDialog.setLocation((Point)obj);
>>>
>>>        }
>>>
>>>
>>>
>>>        ////////////////// AWT WindowListener ////////////////////
>>>
>>>        // I left println here temporarily to see what/when events are
>>> fired
>>>
>>>        public void windowOpened(WindowEvent e) {
>>>
>>>               System.*out*.println("MyDialog windowOpened");
>>>
>>>               setSizeAndLocation();
>>>
>>>        }
>>>
>>>
>>>        public void windowClosing(WindowEvent e) {
>>>
>>>               System.*out*.println("MyDialog windowClosing");
>>>
>>>               saveSizeAndLocation();
>>>
>>>        }
>>>
>>>
>>>
>>>        public void windowClosed(WindowEvent e) { System.*out*.println("
>>> MyDialog windowClosed"); }
>>>
>>>        public void windowIconified(WindowEvent e) { System.*out*
>>> .println("MyDialog windowIconified"); }
>>>
>>>        public void windowDeiconified(WindowEvent e) { System.*out*
>>> .println("MyDialog windowDeiconified"); }
>>>
>>>        public void windowActivated(WindowEvent e) { System.*out*
>>> .println("MyDialog windowActivated"); }
>>>
>>>        public void windowDeactivated(WindowEvent e) { System.*out*
>>> .println("MyDialog windowDeactivated");  }
>>> }
>>>
>>>
>>>
>>>
>>>
>>> On Fri, Jun 10, 2016 at 11:47 AM, Josh Highley <joshhigh...@gmail.com>
>>> wrote:
>>>
>>>> Is the JFrame at the application level or at each individual,
>>>> drag-able, frame level?  I don't necessarily need example code if you can
>>>> do a bit of a "brain dump" with some of the trickier details.  You said " 
>>>> new
>>>> top-level JFrame, and host the Pivot window inside that" -- how is that
>>>> relationship made?  I see JFrame will give a Graphics object, and I know
>>>> Pivot components draw themselves with Graphics....
>>>>
>>>> On Wed, Jun 8, 2016 at 10:11 PM, Roger and Beth Whitcomb <
>>>> <rogerandb...@rbwhitcomb.com>rogerandb...@rbwhitcomb.com> wrote:
>>>>
>>>>> Hi Josh,
>>>>>
>>>>>     Yes it is, but it is complicated.  You basically have to create a
>>>>> new top-level JFrame, and host the Pivot window inside that, and do the
>>>>> message passing by hooking up listeners, etc.  We have done it in our
>>>>> application, and I hope to be able to submit the code at some point, but 
>>>>> it
>>>>> is not ready yet (still some proprietary bits in there still).  I'm not
>>>>> even sure I could send our code to you in a way that would be helpful
>>>>> (i.e., that you could build).  But what we did was based on some of the
>>>>> example code that is already there, so you could potentially reinvent it
>>>>> ....
>>>>>
>>>>>     Let me see if I can at least point you to the example code, but it
>>>>> will have to wait until next week for me ...
>>>>>
>>>>> HTH,
>>>>>
>>>>> ~Roger
>>>>>
>>>>>
>>>>> On 6/8/16 11:27 AM, Josh Highley wrote:
>>>>>
>>>>>> Is it possible to create a non-modal frame (or similar) that can be
>>>>>> dragged outside the main application window?
>>>>>>
>>>>>> For example, I have a log console Frame and some other non-modal info
>>>>>> Frames that a user can show/hide.  I want them to be able to drag it out
>>>>>> from in front of the main application window, like to another monitor.  
>>>>>> At
>>>>>> the moment, the Frames will get cutoff when they pass the edge of the
>>>>>> underlying app window.
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Josh
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>

Reply via email to