1

I would like to ask for help. I want something like this: http://docs.oracle.com/javase/tutorial/uiswing/components/rootpane.html#glasspane

enter image description here

I have this application with map and i want to have a small picture in an new invisible layer. Small picture could move by JSliders up and left. That layer should be only over "label". A have this code:

 private JPanel mujPanel5() {
    JSlider [] posuvniky = new JSlider[2];
    posuvniky[0] = new JSlider(SwingConstants.HORIZONTAL, 0, 100, 30);
    posuvniky[1] = new JSlider(SwingConstants.VERTICAL, 0, 100, 60);
    for (int i = 0; i < posuvniky.length; i++) {
        posuvniky[i].addChangeListener(new ZmenaPosuvniku5()); //Listener do nothing
    }

    URL umisteniMapy = this.getClass().getResource("map.jpg");
    Icon obrazek = new ImageIcon(umisteniMapy);
    JLabel label = new JLabel(obrazek, SwingConstants.CENTER);
    label.setOpaque(true);
    label.setBackground(Color.white);

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(posuvniky[0], BorderLayout.NORTH);
    panel.add(posuvniky[1], BorderLayout.WEST);
    panel.add(label, BorderLayout.CENTER);
    return panel;
}

Thanks to everybody.

MmM ...

mKorbel
  • 109,525
  • 20
  • 134
  • 319
MmM ...
  • 131
  • 1
  • 2
  • 14

1 Answers1

1

I do not know how to create described invisible layer

See How to Use Layered Panes.

camickr
  • 321,443
  • 19
  • 166
  • 288
  • This related [example](http://stackoverflow.com/a/2562685/230513) and [variation](http://stackoverflow.com/a/2563350/230513) illustrate moving a small image by mouse on a `JLayeredPane`. – trashgod Mar 16 '13 at 18:48