• Post Reply Bookmark Topic Watch Topic
  • New Topic

JInternalFrames + JSliders  RSS feed

Marie Henry
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
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() {
//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,
//Quit this app when the big window closes.
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
//Set up the GUI.
desktop = new JDesktopPane(); //a specialized layered pane
createFrame(); //Create first window
//Make dragging faster:
desktop.putClientProperty("JDesktopPane.dragMode", "outline");
protected void createFrame() {
MyInternalFrame frame = new MyInternalFrame();
MyInternalFrame frame2 = new MyInternalFrame();
frame2.setVisible(true); //necessary as of kestrel
frame.setLocation(200, 10);
frame2.setLocation(200, 400);
try {
} catch (java.beans.PropertyVetoException e) {}
public static void main(String[] args) {
InternalFrameDemo frame = new InternalFrameDemo();

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
//...Create the GUI and put it in the window...
//...Then set the window size or call pack...
//Set the window's location.
slider = new JSlider(0, 100, 50);
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!