Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2] 3
  ignore  |  Print  
  PureSwing  (Read 22506 times)
0 Members and 1 Guest are viewing this topic.
Offline i30817

Junior Member





« Reply #30 - Posted 2009-11-14 01:45:37 »

DP
Offline i30817

Junior Member





« Reply #31 - Posted 2009-11-14 01:45:59 »

There is another class of strange things - bugs - (solved?) by the event queue.
By bunny hopping.
This is an example:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4740914

In this case the problem comes from the (wrong?) use of the listener api internally, so the event comes to the user, that selects the text, then to the api, that clears it. The solution is to post a event to the end of the queue.

I'm myself seeing one of these, that the a JTextComponent Highlighter only affects the view the first time. if it is posted to the end of the eventqueue.
(Yes it is in the event queue).
But that is probably because i'm using the highlighter the first time while isShowing for the text component returns false (but isVisible and isValid return true).

You can try to use swingx as a baseline. The main maintainers seem to know most of their stuff.

Also can i direct your attention to this JFileChooser File Extension bug? I found the root cause independently myself, since it is very poorly explained.

http://bugs.sun.com/view_bug.do?bug_id=6612928

This is the bug that caused my serialization attempts while shutting down to fail before. JFileChooser uses an internal File subclass that closes it's disposer (for some operations including writeObject apparently) with a shutdown hook, and i ran a serialization of those files during another shutdown hook -> Race -> exception sometimes.
Offline i30817

Junior Member





« Reply #32 - Posted 2009-11-14 03:22:44 »

I don't know if it is possible or not, but it irritated me sometimes to have to use property change listeners to filter on named events when there was no logical (or just 1) parameter to pass into the listener from the observer controller.
Just a nitpick with the swing event system.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cowwoc

Senior Newbie




Java games rock!


« Reply #33 - Posted 2009-11-17 19:07:05 »

Thanks for feedback, can you elaborate more on why the resulting implementation is a no-no for you?

For example, I am told that the code will throw some magical exception that I may not catch or it will break continuations. The whole concept of continuations twisted the accepted workings of Threads. It's a non-standard concept as you pointed out.

The other way would be to have modal dialogs non-blocking and you would have to register to some event (which happens under the hood with continations usage). This would make the handlers using modal dialogs very fragmented IMHO.

I suggest introducing the usage of Future and CompletionHandler instead. This will allow users to write sequential use-cases as you described without the kind of "magic" introduced by continuations. For code:

1  
2  
3  
4  
5  
Future<?> f = fireSwingEvent();
f.get();
f = fireAnotherSwingEvent();
f.get();
// etc


This is essentially what you're doing with continuations but it's a lot more explicit and is still quite readable.

Gili
Offline i30817

Junior Member





« Reply #34 - Posted 2009-11-17 23:42:18 »

I'd like if JProgress bar exposed the animation function even if it was a no op some times:
The context is: The default way of painting Lists and Tables in swing is with cellrenderers where you update the way the cellrenderer models and then stamp the cellrenderer into a zone, however this won't work well for any animations whose properties can't be exposed, only started. I believe this is the case with JProgressBar. Setting setIndeterminate(true) on repeated passes of the cellrenderer for each model object will only display the first frame of the animation.

Right now i'm hacking a reflection on the JProgressBar ui to see if i can work around it in most look and feels.
Offline jezek2
« Reply #35 - Posted 2009-11-18 00:03:01 »

I'd like if JProgress bar exposed the animation function even if it was a no op some times:
The context is: The default way of painting Lists and Tables in swing is with cellrenderers where you update the way the cellrenderer models and then stamp the cellrenderer into a zone, however this won't work well for any animations whose properties can't be exposed, only started. I believe this is the case with JProgressBar. Setting setIndeterminate(true) on repeated passes of the cellrenderer for each model object will only display the first frame of the animation.

Right now i'm hacking a reflection on the JProgressBar ui to see if i can work around it in most look and feels.

Interesting issue. You can also put the JProgressBar directly to JTable and then it should update automatically itself. Though I'm not sure if it can be done official way or through some tracking of cell position and size. I was doing it with another component in past, but I don't remember how I was exactly doing it (probably the latter method).

I'll think about both issues and how to resolve them.
Offline jezek2
« Reply #36 - Posted 2009-11-18 00:13:45 »

I suggest introducing the usage of Future and CompletionHandler instead. This will allow users to write sequential use-cases as you described without the kind of "magic" introduced by continuations. For code:

1  
2  
3  
4  
5  
Future<?> f = fireSwingEvent();
f.get();
f = fireAnotherSwingEvent();
f.get();
// etc


This is essentially what you're doing with continuations but it's a lot more explicit and is still quite readable.

This code is running on own thread? Not sure what exactly it's doing in relation to modal dialogs. Also I see that CompletionHandler is from Java 7, so would have to introduce own similar interface instead.

Anyway I'm not quite satisfied with current state so I will explore the possibilities of event based approach. Would be cleaner as no bytecode library would be required (and for just too little benefit in case of PureSwing) and would be in the same style with SwingWorker and other asynchronous approaches.
Offline i30817

Junior Member





« Reply #37 - Posted 2009-11-18 02:06:16 »

Interesting issue. You can also put the JProgressBar directly to JTable and then it should update automatically itself. Though I'm not sure if it can be done official way or through some tracking of cell position and size. I was doing it with another component in past, but I don't remember how I was exactly doing it (probably the latter method).

I'll think about both issues and how to resolve them.

BTW i am discussing it here too:
http://forums.java.net/jive/thread.jspa?threadID=69467&tstart=0

Ignore the delegation idea for other lafs. I'm not being able to make it work (because the method i want is protected not default). I can use reflection but i am fighting the idea for now.
Offline jezek2
« Reply #38 - Posted 2009-11-18 02:17:44 »

I've removed usage of continuations. I've resolved the modal dialog issue with Runnable callback in JDialog.showModal method. Also I've added this small interface:

1  
2  
3  
public interface Receiver<T> {
    public void receive(T value);
}


... that is used for returning value from modal dialogs. Here is an example:

1  
2  
3  
4  
5  
6  
7  
8  
JColorChooser.showDialog(button, "Choose a color", getColor(colorType), new Receiver<Color>() {
    public void receive(Color c) {
        if (c != null) {
            setColor(colorType, c);
            button.setIcon(new ColorIcon(c));
        }
    }
});
Offline i30817

Junior Member





« Reply #39 - Posted 2009-11-18 15:51:47 »

I think you should have a public accessible svn or git hub or something so people can see the code in their IDE easily.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jezek2
« Reply #40 - Posted 2009-11-21 08:50:57 »

New version available on PureSwing homepage.

Changes in release 20091121:
- Fixed compilation under Java 5
- Added MigLayout (contributed by Mikael Grev, MiG InfoCom AB)
- Changed to use Graphics2D instead of Graphics
- Added EventQueue.runLoop()
- Moved JComponent's constants UNDEFINED_CONDITION, WHEN_FOCUSED,
  WHEN_ANCESTOR_OF_FOCUSED_COMPONENT and WHEN_IN_FOCUSED_WINDOW to
  InputCondition enum
- Changed WindowConstants interface to CloseOperation enum
- Removed DebugGraphics
- Removed old version of JDesktopPane and removed JInternalFrame
- Changed Cursor API
- Moved JSplitPane's constants HORIZONTAL_SPLIT and VERTICAL_SPLIT to
  SplitOrientation enum, also made continuous layout by default
- Improved dialog modality API
- Added initial Slick support
- Removed usage of continuations
- Removed UnsupportedLookAndFeelException

Also latest development version is now available from Monotone repository.
Offline i30817

Junior Member





« Reply #41 - Posted 2009-11-21 19:11:24 »

Maybe i'm doing something wrong, but i'm perplexed that a JLabel doesn't have a model. How are we supposed to share them in more complex cellrenderers (2 labels x 3 different panels).
Offline raft

Senior Newbie




aptalkarga.com


« Reply #42 - Posted 2009-11-27 05:53:19 »

this is a great and very promising project, the one i'm looking for quite a while Smiley

i have a 3d virtual world application with a complicated Swing GUI rendered with jPCT's software renderer. i had been looking for ways to port it to OpenGL. now it seems i've found the solution Cheesy

however i'm having difficulty running Modern3D demo. below is the exception. any ideas why this happens ? this is a ubuntu 8.04 on a toshiba sattelite laptop with an onboard intel chipset. i got the same exception at Win XP on a similar toshiba laptop.

SlickDemo runs ok although layout is a bit garbaged (texts does not fit into components)

i've also posted the problem to LWJGL forum

1  
2  
3  
4  
5  
6  
Exception in thread "main" java.lang.IllegalStateException: Function is not supported
   at org.lwjgl.BufferChecks.checkFunctionAddress(BufferChecks.java:64)
   at org.lwjgl.opengl.EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.java:170)
   at cz.advel.modern3d.opengl.LWJGLContext.flush(LWJGLContext.java:175)
   at cz.advel.modern3d.opengl.LWJGLContext.<init>(LWJGLContext.java:93)
   at cz.advel.pureswing.test.Modern3DDemo.main(Modern3DDemo.java:82)

Offline CommanderKeith
« Reply #43 - Posted 2009-11-27 06:14:59 »

As a guess, I think the problem is that modern3d uses shaders which your intel video card doesn't support. If you look into the requirements of modern3d you'd be able to find out

Offline jezek2
« Reply #44 - Posted 2009-11-27 07:43:37 »

however i'm having difficulty running Modern3D demo. below is the exception. any ideas why this happens ? this is a ubuntu 8.04 on a toshiba sattelite laptop with an onboard intel chipset. i got the same exception at Win XP on a similar toshiba laptop.

Modern3D requires some minimum functionality, not good option for general/web usage. Best would be to port Graphics2D implementation from Modern3D to pure LWJGL and fixed function pipeline instead of shaders, this is not problem as it uses just Pixel Shaders 2.0 in more or less the same way like fixed function pipeline. I'll look into it for next release.

SlickDemo runs ok although layout is a bit garbaged (texts does not fit into components)

Slick support needs little more work.
Offline raft

Senior Newbie




aptalkarga.com


« Reply #45 - Posted 2009-11-27 15:27:41 »

i see. thanks.

I'll look into it for next release.

any plans when to do it ?

Offline jezek2
« Reply #46 - Posted 2009-11-27 16:33:49 »

i see. thanks.

any plans when to do it ?

I'll look into it somewhere between tommorow and end of next week probably.
Offline raft

Senior Newbie




aptalkarga.com


« Reply #47 - Posted 2009-11-27 16:50:55 »

great. i can't wait it Smiley

Offline raft

Senior Newbie




aptalkarga.com


« Reply #48 - Posted 2009-11-30 05:53:08 »

I've tried porting Karga to PureSwing (with default Desktop). Most went quite smootly Smiley

below are some issues i've faced (some important some not)
* ImageIcon(url) waits indefinetely if given url is an animated gif
* JDesktopPane does not correctly stack (render and dispatch mouse events) components
* JLabel doesn't support multilines (separated with \n) 
* JFrame.pack() does not take window decorations (title bar, borders) into account
* JFrame.setDefaultCloseOperation(CloseOperation.EXIT_ON_CLOSE) does not work
* switching to another window and coming back results in losing keyboard focus. we even can not regain it by clicking
* pressing Tab does not iterate over focusable components

and some opinions:
* re-adding JOptionPane.showInternalXXDialog makes sense to show the dialogs embedded in same window
* re-adding basic HTML support can make sense (JEditorPane, JTextPane, html in JLabel) they are very handy to create multi color/line/format texts.   

and below is a test case:
Quote
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Rectangle;

import cz.advel.pureswing.CloseOperation;
import cz.advel.pureswing.EventQueue;
import cz.advel.pureswing.JDesktopPane;
import cz.advel.pureswing.JFrame;
import cz.advel.pureswing.JPanel;
import cz.advel.pureswing.JTextField;
import cz.advel.pureswing.event.MouseAdapter;
import cz.advel.pureswing.event.MouseEvent;

public class MultiLayer {
    public static final Integer BACKGROUND_LAYER = new Integer(10);
    public static final Integer HELPERS_LAYER = new Integer(30);
   
   public static void main(String[] args) {
      JDesktopPane desktop = new JDesktopPane();
      desktop.setPreferredSize(new Dimension(800, 600));
      
      JPanel backgroundPanel = new JPanel();
      backgroundPanel.setBackground(Color.LIGHT_GRAY);
      desktop.add(backgroundPanel, BACKGROUND_LAYER);
      // this should be centered in frame but is not
      backgroundPanel.setBounds(new Rectangle(50, 50, 700, 500));
      backgroundPanel.addMouseListener(new MouseAdapter() {
         @Override
         public void mouseClicked(MouseEvent event) {
            System.out.println("mouse clicked on background");
         }
      });
      
      // this text field should be rendered on top of background but is not
      JTextField textField = new JTextField();
      desktop.add(textField, HELPERS_LAYER);
      textField.setBounds(0, 50, 200, 20);
      textField.addMouseListener(new MouseAdapter() {
         @Override
         public void mouseClicked(MouseEvent event) {
            System.out.println("mouse clicked on textField");
         }
      });
      
      JFrame frame = new JFrame("PureSwing - test");
      frame.setDefaultCloseOperation(CloseOperation.EXIT_ON_CLOSE);
      frame.add(desktop);
      frame.pack();
      frame.setVisible(true);
      
      EventQueue.runLoop();
   }
}

hope this helps,
r a f t

Offline jezek2
« Reply #49 - Posted 2009-11-30 06:37:50 »

I've tried porting Karga to PureSwing (with default Desktop). Most went quite smootly Smiley

Nice, though expect for API changes in each new release. This project is currently still in early state.

* JFrame.setDefaultCloseOperation(CloseOperation.EXIT_ON_CLOSE) does not work

I'll remove this property. The default action will be dispose() and once all windows are closed the runLoop() method will exit (immediatelly not with delay like in AWT/Swing). This should work better and be simpler.

* switching to another window and coming back results in losing keyboard focus. we even can not regain it by clicking

Yeah, AWT backend is not fully finished.

and some opinions:
* re-adding JOptionPane.showInternalXXDialog makes sense to show the dialogs embedded in same window

You can embed normal JFrame/JDialog/JWindow in JDesktopPane. Just use the desktop instance provided by JDesktopPane. Though you can currently do it for JOptionPane only by using PureSwing.setDesktop(). I'll look into how to improve it, maybe by just adding parameter for desktop or something.

* re-adding basic HTML support can make sense (JEditorPane, JTextPane, html in JLabel) they are very handy to create multi color/line/format texts.   

This will take some time. I have richtext editor component in development with focus on simplicity/extendability and 100% deterministic and expected behaviour when editing by user. I started development in 2006 when I've found no such Swing component exist (commercial or not), but found later I didn't needed it so development became freezed, also it needs some changes to structure as the old structure wasn't best (though almost good). I plan to add it to PureSwing replacing JEditorPane and other text stuff and also use the rendering part for "HTML" (it will be simplified HTML) support for labels and other components.
Offline i30817

Junior Member





« Reply #50 - Posted 2009-12-03 01:12:09 »

Sorry already there. Deleted to hide my stupidity.

Actually, no it doesn't appear to be.
In short, a composable JPopupMenu if setInheritsPopupMenu == true, with the composed JPopupMenu got from the parent.

Must be lazy and non-persistent though, in getting the composed one. Why? Because the main component is built before adding to the parent, the popupmenu can change etc.
Offline i30817

Junior Member





« Reply #51 - Posted 2009-12-03 04:30:40 »

When i first used Actions, i expected the enabled state (indeed all visualization properties) to be checked whenever the action using component needed. So i overrided isEnabled() to return state appropriate to that delta Time. Little did i know that swing uses a push event model, so altering the visualization requires a setEnabled(false) from someone so notification happens.

Got tripped in this again right now. Pathetic really.

Edit: Because i rambled without making a point.
Make abstract action getters and setters final!!!!!! Counsel in the javadoc adding a listener to the observed object by the action!!!!
Offline i30817

Junior Member





« Reply #52 - Posted 2009-12-05 05:24:40 »

Speaking of action. I think the setActionCommand and setActionListener and friends should be deprecated in favor of the new Action interface always.
Offline i30817

Junior Member





« Reply #53 - Posted 2009-12-05 06:26:38 »

JPopupMenu has a hilarious bug.
It's position is always (0,0).

It is also not added to the normal component hierarchy (under it) so getMousePostion also return 0,0.
You would think that adding a mouselistener to the component the popupmenu is going to be over and listening for the click you want would work, and it does ... the first time. If you do right click, it does send the first even and show the popup, then move the mouse outside the popup and right click again, it doesn't send the event to the component (i assume the popup installs something funky or catches the event.

Since 1.4
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4527633

This is a discussion:
http://markmail.org/message/effistg6dcs2d5aq#query:JPopupMenu%20parent+page:1+mid:vwodpxiuahvjkdlg+state:results

Can be worked around with a PopupMenuListener, getting the invoker directly (instead of getParent) and using that on the swing utility methods. Strangely getMousePosition on the invoker still returns null, but the other appears to work.
            Component c = ((JPopupMenu)e.getSource()).getInvoker();
            if(c == yourPreferredComponent){
                lastVisiblePoint = MouseInfo.getPointerInfo().getLocation();
                SwingUtilities.convertPointFromScreen(lastVisiblePoint, c);
                ...
            }else{
                ...
            }
Offline raft

Senior Newbie




aptalkarga.com


« Reply #54 - Posted 2009-12-12 04:21:00 »

any plans for date of next release ?  Roll Eyes i'm not in a hurry, just for wonder..

Offline jattra

Junior Newbie





« Reply #55 - Posted 2010-01-28 18:55:53 »

Hello,
I have downloaded the PureSwing ZIP distro.
Trying to run demo classes in gnu.classpath.examples.swing package with no success.
The main method starts, does nothing and exits immediately.

I have run it in debug mode and learned that the runnable passed to SwingUtilities.invokeLater in demo main method is never started.

Any hints? Thx.

Ubuntu 9.04 , SUN Java 1.6
Offline jezek2
« Reply #56 - Posted 2010-01-29 15:31:14 »

Trying to run demo classes in gnu.classpath.examples.swing package with no success.
The main method starts, does nothing and exits immediately.

I have run it in debug mode and learned that the runnable passed to SwingUtilities.invokeLater in demo main method is never started.

Nice catch, I forgot to update main() method for individual demos. Please use main Demo or move the code from invokeLater directly to main() and add EventQueue.runLoop() at the end.

SwingUtilities.invokeLater is not needed to start the GUI as it uses main thread directly, event queue loop is also explicit, see the EventQueue.runLoop() method and it's javadoc.
Offline i30817

Junior Member





« Reply #57 - Posted 2010-02-16 07:13:06 »

JTooltip mouseevents bitching, by myself.

http://forums.java.net/jive/thread.jspa?messageID=386908&#386908
Offline jezek2
« Reply #58 - Posted 2010-02-16 18:56:43 »


What is your use case? Normally the tooltip should hide or reposition when the mouse hits it. I don't know if it works that way in Swing generally now, but it's the way it should work Smiley

EDIT: Oh I now see the description of the bug... interesting behaviour indeed...
Offline i30817

Junior Member





« Reply #59 - Posted 2010-02-16 22:39:48 »

What really hurts is the usability. I mean it's probably bad idea to allow a general even passthorugh, because when i tried, it messed with the repaint buffer, since one of my mouselisteners called repaint on the list underneath the tooltip, but at least for some of them, like the ultra useful mousewheelevent on a JScrollpane underneath the tooltip, it should pass.

In my app i made it pass even if the tooltip is outside the bounds (my tooltips are at a specified place, for a JList alone inside the JScrollpane and it was easier YMMV).

The real solution is to make the tooltips invisible to everything, including events and damaging repaint requests.
Pages: 1 [2] 3
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (62 views)
2014-04-15 18:08:23

BurntPizza (60 views)
2014-04-15 03:46:01

UprightPath (73 views)
2014-04-14 17:39:50

UprightPath (56 views)
2014-04-14 17:35:47

Porlus (73 views)
2014-04-14 15:48:38

tom_mai78101 (99 views)
2014-04-10 04:04:31

BurntPizza (159 views)
2014-04-08 23:06:04

tom_mai78101 (254 views)
2014-04-05 13:34:39

trollwarrior1 (208 views)
2014-04-04 12:06:45

CJLetsGame (215 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!