IntelliJ Java IDE
The moose likes Swing / AWT / SWT / JFace and the fly likes JInternalFrames + JSliders Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "JInternalFrames + JSliders" Watch "JInternalFrames + JSliders" New topic
Author

JInternalFrames + JSliders

Marie Henry
Greenhorn

Joined: Sep 06, 2001
Posts: 2
I am currently working on an application that uses JInternalFrames with JSliders. However, when I try to move a slider on an unselected frame by clicking and dragging it, it only selects the frame and then I must click again to use the slider.
To check this behavior I took some simple JInternalFrame code off the java.sun site and added JSliders to two InternalFrames. The code is included below. To witness this behavior, click on "InternalFrame #1" and then on "InternalFrame#2." Then try to move the slider on InternalFrame#1 by clicking and dragging the slider head. The frame will become selected but the slider will not move until you click on it again.
Just as a note this does not happen with all components...any type of AbstractButton seems to work fine in the situations of switching back and forth between frames.
Has anyone encountered this behavior before? Is there some kind of a workaround? Am I not noticing something?
Thanks in advance,
Marie
import javax.swing.JInternalFrame;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import java.awt.event.*;
import java.awt.*;
public class InternalFrameDemo extends JFrame {
JDesktopPane desktop;
public InternalFrameDemo() {
super("InternalFrameDemo");
//Make the big window be indented 50 pixels from each edge
//of the screen.
int inset = 50;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(inset, inset,
screenSize.width - inset*2,
screenSize.height-inset*2);
//Quit this app when the big window closes.
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
//Set up the GUI.
desktop = new JDesktopPane(); //a specialized layered pane
createFrame(); //Create first window
setContentPane(desktop);
//Make dragging faster:
desktop.putClientProperty("JDesktopPane.dragMode", "outline");
}
protected void createFrame() {
MyInternalFrame frame = new MyInternalFrame();
MyInternalFrame frame2 = new MyInternalFrame();
frame.setVisible(true);
frame2.setVisible(true); //necessary as of kestrel
frame.setLocation(200, 10);
frame2.setLocation(200, 400);
desktop.add(frame);
desktop.add(frame2);
try {
frame.setSelected(true);
} catch (java.beans.PropertyVetoException e) {}
}
public static void main(String[] args) {
InternalFrameDemo frame = new InternalFrameDemo();
frame.setVisible(true);
}
}

import javax.swing.JInternalFrame;
import java.awt.*;
import javax.swing.*;
public class MyInternalFrame extends JInternalFrame {
static int openFrameCount = 0;
JSlider slider;
public MyInternalFrame() {
super("InternalFrame #" + (++openFrameCount),
true, //resizable
true, //closable
true, //maximizable
true);//iconifiable
//...Create the GUI and put it in the window...
//...Then set the window size or call pack...
setSize(300,300);
//Set the window's location.
slider = new JSlider(0, 100, 50);
getContentPane().add(slider);
}
}
 
 
subject: JInternalFrames + JSliders
 
Threads others viewed
Adding Components in to JInternalFrame
InternalFrame not resizing
Awt vs. Swing error
adding an InternalFrameListener to a JMenu Item
JDesktopPane creates inner frame menuItem actionPerformed does not.
MyEclipse, The Clear Choice

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture