Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: Light Box Effect (2 Windows, 1 Smaller And Active Above Inactive

Reply
Thread Tools

Re: Light Box Effect (2 Windows, 1 Smaller And Active Above Inactive

 
 
clusardi2k
Guest
Posts: n/a
 
      08-08-2012
To: markspace
From: "clusardi2k" <clusardi2k@1:261/38.remove-p82-this>

To: markspace
From: "clusardi2k" <clusardi2k@1:261/38.remove-jwh-this>

To: markspace
From: "clusardi2k" <clusardi2k@1:261/38.remove-sao-this>

To: markspace
From: http://www.velocityreviews.com/forums/(E-Mail Removed)

Is there another way besides using JLayer. Is JLayer the best way.

Thank you,

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

--- BBBS/Li6 v4.10 Dada-1
* Origin: Prism bbs (1:261/3
--- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24
 
Reply With Quote
 
 
 
 
markspace
Guest
Posts: n/a
 
      08-08-2012
To: clusardi2k
From: "markspace" <markspace@1:261/38.remove-p82-this>

To: clusardi2k
From: "markspace" <markspace@1:261/38.remove-jwh-this>

To: clusardi2k
From: "markspace" <markspace@1:261/38.remove-sao-this>

To: clusardi2k
From: markspace <-@.>

On 8/6/2012 8:54 AM, (E-Mail Removed) wrote:
> Is there another way besides using JLayer. Is JLayer the best way.



I think it might be the only way, short of doing it yourself like that Swing
Hacks books shows you. "Best" is a hard thing to determine without careful
analysis. But JLayer is certainly the way I would start, even if I decided
later I had to change. Can't go too badly wrong re-using code someone else
already wrote.

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

--- BBBS/Li6 v4.10 Dada-1
* Origin: Prism bbs (1:261/3
--- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24
 
Reply With Quote
 
 
 
 
clusardi2k
Guest
Posts: n/a
 
      08-19-2012
To: markspace
From: "clusardi2k" <clusardi2k@1:261/38.remove-7rm-this>

To: markspace
From: "clusardi2k" <clusardi2k@1:261/38.remove-rj6-this>

To: markspace
From: "clusardi2k" <clusardi2k@1:261/38.remove-4g4-this>

To: markspace
From: (E-Mail Removed)

The book is here:

http://www.scribd.com/doc/15490884/S...or-Killer-GUIs

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

--- BBBS/Li6 v4.10 Dada-1
* Origin: Prism bbs (1:261/3
--- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24
 
Reply With Quote
 
clusardi2k
Guest
Posts: n/a
 
      08-19-2012
To: markspace
From: "clusardi2k" <clusardi2k@1:261/38.remove-7rm-this>

To: markspace
From: "clusardi2k" <clusardi2k@1:261/38.remove-rj6-this>

To: markspace
From: "clusardi2k" <clusardi2k@1:261/38.remove-4g4-this>

To: markspace
From: (E-Mail Removed)

On Friday, August 17, 2012 8:30:58 AM UTC-4, (unknown) wrote:
> The book is here: http://www.scribd.com/doc/15490884/S...s-Tips-and-Too

ls-for-Killer-GUIs

Here's the HACK #45 code from the book. It has two buttons. If you press one of
th buttons everything on the screen will move away and the screen will become
blank.

Question: How on Earth do I convert this into a light box effect.

Here is a link to other fun JLayer examples:

http://docs.oracle.com/javase/tutori...sc/jlayer.html

//File: SheetTest.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package anisheetablejframe;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;

public class SheetTest extends Object
implements PropertyChangeListener {

JOptionPane optionPane;
AniSheetableJFrame frame;

public static void main (String[] args) {
new SheetTest( );
}

public SheetTest ( ) {
frame = new AniSheetableJFrame ("Sheet test");
// put an image in the frame's content pane
ImageIcon icon = new ImageIcon ("keagy-lunch.png");
JLabel label = new JLabel (icon);
frame.getContentPane( ).add(label);
// build JOptionPane dialog and hold onto it
optionPane = new JOptionPane ("Do you want to save?",

JOptionPane.QUESTION_MESSAGE,

JOptionPane.YES_NO_OPTION);
frame.pack( );
frame.setVisible(true);
optionPane.addPropertyChangeListener (this);
// pause for effect, then show the sheet
try {Thread.sleep(1000);}
catch (InterruptedException ie) {}
JDialog dialog =
optionPane.createDialog (frame, "irrelevant");
frame.showJDialogAsSheet (dialog);
}

public void propertyChange (PropertyChangeEvent pce) {
if (pce.getPropertyName( ).equals
(JOptionPane.VALUE_PROPERTY)) {
System.out.println ("Selected option " +
pce.getNewValue( ));
frame.hideSheet( );
}
}
}

//---------------------------
//File AnimatingSheet.java
package anisheetablejframe;

import java.awt.*;
import java.awt.image.BufferedImage; import javax.swing.JComponent; import
javax.swing.JPanel;

class AnimatingSheet extends JPanel {
Dimension animatingSize = new Dimension (0, 1);
JComponent source;
BufferedImage offscreenImage;
public AnimatingSheet ( ) {
super( );
setOpaque(true);
}
public void setSource (JComponent source) {
this.source = source;
animatingSize.width = source.getWidth( );
makeOffscreenImage(source);
}
public void setAnimatingHeight (int height) {
animatingSize.height = height;
setSize (animatingSize);
}
private void makeOffscreenImage(JComponent source) {
GraphicsConfiguration gfxConfig =
GraphicsEnvironment.getLocalGraphicsEnvironment
( )
.getDefaultScreenDevice( )
.getDefaultConfiguration( );
offscreenImage =
gfxConfig.createCompatibleImage(source.getWidth
( ),

source.getHeight( ));
Graphics2D offscreenGraphics =
(Graphics2D) offscreenImage.getGraphics( );
source.paint (offscreenGraphics);
}
public Dimension getPreferredSize( ) { return animatingSize; }
public Dimension getMinimumSize( ) { return animatingSize; }
public Dimension getMaximumSize( ) { return animatingSize; }
public void paint (Graphics g) {
// get the bottom-most n pixels of source and
// paint them into g, where n is height

int x = 0;
int y = offscreenImage.getHeight() - animatingSize.height;
int w = source.getWidth();
int h = animatingSize.height;

BufferedImage fragment =
offscreenImage.getSubimage (x,y,w,h);
// g.drawImage (fragment, 0, 0, this);
g.drawImage (fragment, 0, 0, this);
}
}

//---------------------------
//File AniSheettableJFrame.java
package anisheetablejframe;

import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;

public class AniSheetableJFrame extends JFrame
implements ActionListener {

public static final int INCOMING = 1;
public static final int OUTGOING = -1;
public static final float ANIMATION_DURATION = 1000f;
public static final int ANIMATION_SLEEP = 50;

JComponent sheet;
JPanel glass;
AnimatingSheet animatingSheet;
boolean animating;
int animationDirection;
Timer animationTimer;
long animationStart;
BufferedImage offscreenImage;

public AniSheetableJFrame (String name) {
super(name);
glass = (JPanel) getGlassPane( );
glass.setLayout (new GridBagLayout( ));
animatingSheet = new AnimatingSheet( );
animatingSheet.setBorder (new LineBorder(Color.black,
1));
}
public JComponent showJDialogAsSheet (JDialog dialog) {
sheet = (JComponent) dialog.getContentPane( );
sheet.setBorder (new LineBorder(Color.black, 1));
glass.removeAll( );
animationDirection = INCOMING;
startAnimation( );
return sheet;
}

public void hideSheet( ) {
animationDirection = OUTGOING;
startAnimation( );
}

private void startAnimation( ) {
glass.repaint( );
// clear glasspane and set up animatingSheet
animatingSheet.setSource (sheet);
glass.removeAll( );
GridBagConstraints gbc = new GridBagConstraints( );
gbc.anchor = GridBagConstraints.NORTH;
glass.add (animatingSheet, gbc);
gbc.gridy=1;
gbc.weighty = Integer.MAX_VALUE;
glass.add (Box.createGlue( ), gbc);
glass.setVisible(true);

// start animation timer
animationStart = System.currentTimeMillis( );
if (animationTimer == null)
animationTimer = new Timer (ANIMATION_SLEEP,
this);
animating = true;
animationTimer.start( );
}

private void stopAnimation( ) {
animationTimer.stop( );
animating = false;
}

// used by the Timer
public void actionPerformed (ActionEvent e) {
if (animating) {
// calculate height to show
float animationPercent =
(System.currentTimeMillis( ) - animationStart)
/
ANIMATION_DURATION;
animationPercent = Math.min (1.0f,
animationPercent);
int animatingHeight = 0;

if (animationDirection == INCOMING) {
animatingHeight =
(int) (animationPercent * sheet.getHeight( ));
} else {
animatingHeight =
(int) ((1.0f - animationPercent) * sheet.getHeight( ));
}
// clip off that much from sheet and blit it
// into animatingSheet
animatingSheet.setAnimatingHeight (animatingHeight);
animatingSheet.repaint( );

if (animationPercent >= 1.0f) {
stopAnimation( );
if (animationDirection == INCOMING) {
finishShowingSheet( );
} else {
glass.removeAll( );
glass.setVisible(false);
}
}
}
}
private void finishShowingSheet( ) {
glass.removeAll( );
GridBagConstraints gbc = new GridBagConstraints( );
gbc.anchor = GridBagConstraints.NORTH;
glass.add (sheet, gbc);
gbc.gridy=1;
gbc.weighty = Integer.MAX_VALUE;
glass.add (Box.createGlue( ), gbc);
glass.revalidate( );
glass.repaint( );
}
// inner class AnimatedSheet goes here
}

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

--- BBBS/Li6 v4.10 Dada-1
* Origin: Prism bbs (1:261/3
--- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Light Box Effect (2 Windows, 1 Smaller And Active Above Inactive clusardi2k Java 3 08-18-2012 07:37 PM
Re: Light Box Effect (2 Windows, 1 Smaller And Active Above Inactive clusardi2k Java 3 08-18-2012 06:36 PM
Re: Light Box Effect (2 Windows, 1 Smaller And Active Above Inactive markspace Java 2 08-17-2012 06:56 PM
Light Box Effect (2 Windows, 1 Smaller And Active Above Inactive clusardi2k Java 6 08-06-2012 06:08 PM
Re: Light Box Effect (2 Windows, 1 Smaller And Active Above Inactive clusardi2k Java 3 08-04-2012 06:41 PM



Advertisments