Prevent scrollbars disappearing when exiting component inside the JScrollPane - java

I made a JPanel that contains a JScrollPane that surrounds a JTextArea. I want to hide the scrollbars when the mouse exits the JScrollPane.
If I set the MouseListener on the JScrollPane, then nothing happens. If I set it on the JTextArea then the scrollbars hide/unhide correctly, but you cannot click them because they are outside the bounds of the JTextArea.\
How can I prevent the scrollbars from disappearing when you try to click them?
Code example 1. Hiding and unhiding + changing transparency works.
Problem: You cannot click the scrollbars, they disappear because you exit the JTextArea.
public class TransparentTextArea extends JTextArea {
private static final Color LIGHT_TRANSPARENT = new Color(0, 0, 0, 150);
private static final Color HEAVY_TRANSPARENT = new Color(0, 0, 0, 50);
public TransparentTextArea(final GameModel model) {
setOpaque(false);
setForeground(Color.WHITE);
setBackground(HEAVY_TRANSPARENT);
setEditable(false);
addMouseListener(new MouseListener() {
#Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
#Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
#Override
public void mouseExited(MouseEvent e) {
model.setLogActive(false);
setBackground(HEAVY_TRANSPARENT);
}
#Override
public void mouseEntered(MouseEvent e) {
model.setLogActive(true);
setBackground(LIGHT_TRANSPARENT);
}
#Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
}
});
}
}
public class Logger extends JScrollPane implements PanelObserver,
ChangeListener {
private GameModel model;
public Logger(final GameModel model) {
super(new TransparentTextArea(model));
this.model = model;
setOpaque(false);
getViewport().setOpaque(false);
setBorder(BorderFactory.createEmptyBorder());
setViewportBorder(BorderFactory.createEmptyBorder());
model.addPanelObserver(this);
model.addChangeListener(this);
}
#Override
public void panelResized() {
float x = model.getPanelWidth() * 0.01f;
float y = model.getPanelHeight() * 0.70f;
float width = model.getPanelWidth() * 0.30f;
float height = model.getPanelHeight() * 0.28f;
setBounds((int) x, (int) y, (int) width, (int) height);
}
#Override
public void stateChanged(ChangeEvent e) {
if (model.isLogActive()) {
setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
} else {
setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
}
}
}
Code example 2.
Problem I tried to fix this by creating a Panel around it and using that MouseExited, but it does not work since the childs consume it.
public class Logger extends JPanel implements PanelObserver, MouseListener {
private static final Color LIGHT_TRANSPARENT = new Color(0, 0, 0, 150);
private static final Color HEAVY_TRANSPARENT = new Color(0, 0, 0, 50);
private GameModel model;
private JTextArea textArea;
private JScrollPane scrollPane;
public Logger(GameModel model) {
super(null);
this.model = model;
setOpaque(false);
textArea = new JTextArea();
textArea.setOpaque(false);
textArea.setForeground(Color.WHITE);
textArea.setBackground(HEAVY_TRANSPARENT);
textArea.setEditable(false);
scrollPane = new JScrollPane(textArea);
scrollPane.setOpaque(false);
scrollPane.getViewport().setOpaque(false);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
scrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
add(scrollPane);
model.addPanelObserver(this);
addMouseListener(this);
}
#Override
public void panelResized() {
float x = model.getPanelWidth() * 0.01f;
float y = model.getPanelHeight() * 0.70f;
float width = model.getPanelWidth() * 0.30f;
float height = model.getPanelHeight() * 0.28f;
setBounds((int) x, (int) y, (int) width, (int) height);
scrollPane.setBounds(0, 0, (int) width, (int) height);
}
#Override
public void mouseClicked(MouseEvent e) {}
#Override
public void mousePressed(MouseEvent e) {}
#Override
public void mouseReleased(MouseEvent e) {}
#Override
public void mouseEntered(MouseEvent e) {
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
textArea.setBackground(LIGHT_TRANSPARENT);
}
#Override
public void mouseExited(MouseEvent e) {
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
textArea.setBackground(HEAVY_TRANSPARENT);
}
}

works for me, but there are a few mistakes
JScrollPane (in the case that is container) react to only one pixel around its child (1pixel Border)
mouse event are consumed by its childs, then whatever added to JScrollPane inside JPanel to consume() mouse event
JPanel has FlowLayout implementer in API, change that
don't to use NullLayout, use proper LayourManager for JPanel (BorderLayout, GridLayout)
JComponents can quite to easilly returns PreferredSize back to the container override getPreferredSize for JPanel, JTextArea(20, 20) etc
JPanel must be larger that JViewport in JScrollPane, otherwise (without override JScrollBars) JScrollBar never will be visible
near to true were #Omid +1
. . . . .
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
//http://stackoverflow.com/q/16344529/714968
public class MyLogger {
private JTextArea textArea;
private JScrollPane scrollPane;
public MyLogger() {
textArea = new JTextArea(20, 20);
scrollPane = new JScrollPane(textArea);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
textArea.addMouseListener(new MouseListener() {
#Override
public void mouseClicked(MouseEvent e) {
}
#Override
public void mousePressed(MouseEvent e) {
}
#Override
public void mouseReleased(MouseEvent e) {
}
#Override
public void mouseEntered(MouseEvent e) {
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
}
#Override
public void mouseExited(MouseEvent e) {
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
}
});
JFrame frame = new JFrame();
frame.add(scrollPane);
frame.setPreferredSize(new Dimension(100, 100));// JFrame must be smaller
frame.pack();
frame.setLocation(150, 150);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
#Override
public void run() {
MyLogger myLogger = new MyLogger();
}
});
}
}
EDIT
again back to answer posted by #Omid, see what happens
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
//http://stackoverflow.com/q/16344529/714968
public class MyLogger {
private JTextArea textArea;
private JScrollPane scrollPane;
public MyLogger() {
textArea = new JTextArea(20, 20);
textArea.setText("This text pane contains no html. It supports letter wrapping, "
+ "\nThis text pane contains no html. It supports letter wrapping!, "
+ "\nThis text pane contains no html. It supports letter wrapping!, "
+ "\nThis text pane contains no html. It supports letter wrapping!, "
+ "\nThis text pane contains no html. It supports letter wrapping!, "
+ "\nThis text pane contains no html. It supports letter wrapping!");
textArea.addMouseListener(new MouseAdapter() {
#Override
public void mouseEntered(MouseEvent e) {
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
}
});
scrollPane = new JScrollPane(textArea);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.addMouseListener(new MouseAdapter() {
#Override
public void mouseExited(MouseEvent e) {
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
}
});
JFrame frame = new JFrame();
frame.add(scrollPane);
frame.setPreferredSize(new Dimension(100, 100));// JFrame must be smaller
frame.pack();
frame.setLocation(150, 150);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
#Override
public void run() {
MyLogger myLogger = new MyLogger();
}
});
}
}

Just tried this and it works fine:
textArea.addMouseMotionListener(new MouseMotionAdapter() {
#Override
public void mouseMoved(MouseEvent arg0) {
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
}
});
scrollPane.addMouseListener(new MouseAdapter() {
#Override
public void mouseExited(MouseEvent e) {
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
}
});
The idea is that as long as the mouse is moving within the textArea, the ScrollBar is visible and works fine. As soon as it moves outside the ScrollPane it's not visible anymore.

You may have to put the listener on the JScrollPane itself rather than on the backing JPanel. The JScrollPane encapsulates your JPanel so adding the mouse listener to the JPanel only will only tell you when the mouse enters/leaves that JPanel specifically, not the encapsulating JScrollPane.
scrollPane.addMouseListener(this);
You may actually have to have listeners in both, depending on how you want this all to work, and maybe set up a lock so that as long as the mouse is in at least one of them, the scroll bars will show, but if the mouse is in neither then make them invisible.

Related

Gui graphic does not appear in Panel

I am trying to make a drawOval moving by using the two buttons that I set to be North and East so the ball will move between the JButtons, at the center.
Why does not appear at the panel?
Also I am thinking using a function that make this x=x+; and y=y+1 when I pressed left or right.
I do not figure out what can I do.
So this is the code I made:
public class Main extends JFrame implements ActionListener {
JButton left;
JButton right;
JPanel p;
Main(){
JButton left = new JButton("left");
left.addActionListener(this);
left.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent ae) {
//The first way I think is better to make it move.
}
});
JButton right = new JButton("right");
right.addActionListener(this);
Panel p = new Panel();
p.setLayout(new BorderLayout());
p.add("West",left);// to the left
p.add("East",right);//to the right
Container c = getContentPane();
c.add(p);
}
public static void main(String[] args) {
Main f=new Main();
f.setTitle("Heracles");
f.setSize(500, 500);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true); //this is the window
}
public void paintComponent (Graphics g) {
super.paintComponents(g);
Graphics2D g1=(Graphics2D) g;
g.drawOval(3, 5, 45, 46); // The ball
g.fillOval(20, 30, 40, 40);
}
#Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
}
To understand why it's not working, you need to understand how the paint system actually works
Just by looking at this snippet it should be obvious something is wrong.
public class Main extends JFrame implements ActionListener {
//...
public void paintComponent (Graphics g) {
super.paintComponents(g);
//...
}
}
You've declare a method called paintComponent but are calling the super method paintComponents (note the s at the end).
Further, when ever you "think" you're overriding a method, you should make use of the #Override attribute, this will cause a compiler error when you've done something wrong
public class Main extends JFrame implements ActionListener {
//...
#Overrride
public void paintComponent (Graphics g) {
super.paintComponents(g);
//...
}
}
The above code will now fail to compile, as JFrame doesn't declare a paintComponent method.
As a general rule, you should avoid extending directly from JFrame (or other top level containers), they are compound components and have a complex hierarchy and functionality.
A better place to start might be with a JPanel
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class Main {
public static void main(String[] args) {
new Main();
}
public Main() {
EventQueue.invokeLater(new Runnable() {
#Override
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
ex.printStackTrace();
}
JFrame frame = new JFrame("Testing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new TestPane());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
}
public class TestPane extends JPanel {
JButton left;
JButton right;
JPanel paintPane;
public TestPane() {
JButton left = new JButton("left");
left.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent ae) {
}
});
JButton right = new JButton("right");
right.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent e) {
}
});
paintPane = new PaintPane();
setLayout(new BorderLayout());
add(left, BorderLayout.WEST);
add(right, BorderLayout.EAST);
add(paintPane);
}
}
public class PaintPane extends JPanel {
#Override
public Dimension getPreferredSize() {
return new Dimension(200, 200);
}
public void paintComponent(Graphics g) {
super.paintComponents(g);
Graphics2D g1 = (Graphics2D) g;
g1.drawOval(3, 5, 45, 46); // The ball
g1.fillOval(20, 30, 40, 40);
}
}
}
You should take the time to have a look at Painting in Swing and Performing Custom Painting for more details.
Some other concepts you might like to take the time to learn:
Single Responsibility Principle - a class should do one thing and do it well
Observer Pattern - This typically represent in Swing as the listener API
Model-View-Controller - this encompasses the above and defines different layers of responsibility for different parts of the program, it will helper you understand the basic structure of Swing as well
Also I am thinking using a function that make this x=x+; and y=y+1 when I pressed left or right.
Ok, so this is where the "model" part of the MVC will play it's part.
So lets start by defining the basic properties we expect the model to support...
public interface ShapeModel {
public Point getPoint();
public void addChangeListener(ChangeListener listener);
public void removeChangeListener(ChangeListener listener);
}
Here is supports a Point to act as the location and a ChangeListener to act as the observer pattern, which will notify interested parties that the state of the model has changed.
Why start with a interface? As a general concept, you should always prefer to code to interface instead of implementation. In this case, one aspect of the interface which hasn't been defined is, how does the Point get updated? That's of little interest to most parties who want to work with the model, they just want to know when it changes, the mutation of the model can be expressed either directly via the implementation or a "mutable" interface which extends from the this interface
Next, we define a default implementation...
public class DefaultShapeModel implements ShapeModel {
private Point point = new Point(40, 40);
private List<ChangeListener> listeners = new ArrayList<>(25);
#Override
public Point getPoint() {
return point;
}
public void setPoint(Point point) {
this.point = point;
fireStateChanged();
}
protected void fireStateChanged() {
ChangeEvent evt = new ChangeEvent(this);
for (ChangeListener listener : listeners) {
listener.stateChanged(evt);
}
}
#Override
public void addChangeListener(ChangeListener listener) {
listeners.add(listener);
}
#Override
public void removeChangeListener(ChangeListener listener) {
listeners.remove(listener);
}
}
This does define how the paint is to be updated.
Finally, we update the TestPane and PaintPane to support the model...
public class TestPane extends JPanel {
JButton left;
JButton right;
JPanel paintPane;
private DefaultShapeModel model;
public TestPane() {
model = new DefaultShapeModel();
JButton left = new JButton("left");
left.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent ae) {
Point p = model.getPoint();
p.x--;
if (p.x > 0) {
p.x = 0;
}
model.setPoint(p);
}
});
JButton right = new JButton("right");
right.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent e) {
Point p = model.getPoint();
p.x++;
if (p.x + 40 > paintPane.getWidth()) {
p.x = paintPane.getWidth() - 40;
}
model.setPoint(p);
}
});
paintPane = new PaintPane(model);
setLayout(new BorderLayout());
add(left, BorderLayout.WEST);
add(right, BorderLayout.EAST);
add(paintPane);
}
}
public class PaintPane extends JPanel {
private ShapeModel model;
public PaintPane(ShapeModel model) {
this.model = model;
this.model.addChangeListener(new ChangeListener() {
#Override
public void stateChanged(ChangeEvent e) {
repaint();
}
});
}
public ShapeModel getModel() {
return model;
}
#Override
public Dimension getPreferredSize() {
return new Dimension(200, 200);
}
public void paintComponent(Graphics g) {
super.paintComponents(g);
Graphics2D g1 = (Graphics2D) g;
Point p = getModel().getPoint();
g1.fillOval(p.x, p.y, 40, 40);
g1.setColor(Color.WHITE);
g1.drawOval(p.x, p.y, 40, 40);
}
}
Why does not appear at the panel?
To display graphic you created, use follow these steps,
Remove paintComponent method and replace it with below code..
public JComponent createOvel() {
return new JComponent() {
#Override
protected void paintComponent(Graphics g) {
Graphics2D g1 = (Graphics2D) g;
g.drawOval(3, 5, 45, 46); // The ball
g.fillOval(20, 30, 40, 40);
}
};
}
Then call it in Main() constructor,
p.add("Center", createOvel());
This will display the graphic you created.

paint method is not being called

I don't know why, but I can't call the method paint(Graphics g) from code. I have MouseListeners:
#Override
public void mouseReleased(MouseEvent e) {
pointstart = null;
}
#Override
public void mousePressed(MouseEvent e) {
pointstart = e.getPoint();
}
and MouseMotionListeners:
#Override
public void mouseMoved(MouseEvent e) {
pointend = e.getPoint();
}
#Override
public void mouseDragged(MouseEvent arg0) {
pointend = arg0.getPoint();
// ==========================================================================
// call repaint:
repaint();
// ==========================================================================
}
and my paint method:
public void paint(Graphics g){
super.paint(g); //here I have my breakpoint in debugger
g.translate(currentx, currenty);
if(pointstart!=null){
g.setClip(chartPanel.getBounds());
g.setColor(Color.BLACK);
g.drawLine(pointstart.x, pointstart.y, pointend.x, pointend.y);
}
}
in the initialize method:
currentx = chartPanel.getLocationOnScreen().x;
currenty = Math.abs(chartPanel.getLocationOnScreen().y - frame.getLocationOnScreen().y);
All in class, which is my work frame, it extends JFrame.
Problem is, that program doesn't call paint method. I checked that in debugger.
I tried do this by paintComponent , without super.paint(g).
And the best is that, that code I copied from my other project, where it works fine.
UPDATE:
This is code which I want to draw line on panel (no matter - panel/chartpanel/etc). And it doesn't paint. I tried do this by paint(Graphics g){super.paint(g) ..... } and it doesn't too. Painting should be aneble after clicking button "line".
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Point;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;
import javax.swing.JScrollPane;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
public class Window extends JFrame {
private JFrame frame;
public JPanel panelbuttons;
public JPanel panelscrollpane;
public JButton btnLine;
public JToolBar toolBar;
public JScrollPane scrollPane;
public JPanel panel;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Window window = new Window();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public Window() {
initialize();
}
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 644, 430);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel = new JPanel();
panelbuttons = new JPanel();
frame.getContentPane().add(panelbuttons, BorderLayout.WEST);
panelbuttons.setLayout(new BorderLayout(0, 0));
toolBar = new JToolBar();
toolBar.setOrientation(SwingConstants.VERTICAL);
panelbuttons.add(toolBar, BorderLayout.WEST);
btnLine = new JButton("line");
btnLine.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
panel.addMouseListener(mouselistenerLine);
panel.addMouseMotionListener(mousemotionlistenerLine);
}
});
toolBar.add(btnLine);
panelscrollpane = new JPanel();
frame.getContentPane().add(panelscrollpane, BorderLayout.CENTER);
panelscrollpane.setLayout(new BorderLayout(0, 0));
scrollPane = new JScrollPane(panel);
panel.setLayout(new BorderLayout(0, 0));
scrollPane.setViewportBorder(null);
panelscrollpane.add(scrollPane);
panelscrollpane.revalidate();
}
Point pointstart = null;
Point pointend = null;
private MouseListener mouselistenerLine = new MouseListener() {
#Override
public void mouseReleased(MouseEvent e) {
System.out.println("I'm in first listener. - mouse Released");
pointstart = null;
}
#Override
public void mousePressed(MouseEvent e) {
System.out.println("I'm in first listener. - mousePressed");
pointstart = e.getPoint();
}
#Override
public void mouseExited(MouseEvent e) {
}
#Override
public void mouseEntered(MouseEvent e) {
}
#Override
public void mouseClicked(MouseEvent e) {
}
};
private MouseMotionListener mousemotionlistenerLine = new MouseMotionListener() {
#Override
public void mouseMoved(MouseEvent e) {
System.out.println("I'm in second listener. - mouseMoved");
pointend = e.getPoint();
}
#Override
public void mouseDragged(MouseEvent arg0) {
System.out.println("I'm in second listener. - mouseDragged");
pointend = arg0.getPoint();
repaint();
}
};
public void paintComponent(Graphics g){
System.out.println("I'm in paintComponent method.");
if(pointstart!=null){
System.out.println("I'm drawing.");
g.setClip(scrollPane.getBounds());
g.setColor(Color.BLACK);
g.drawLine(pointstart.x, pointstart.y, pointend.x, pointend.y);
}
}
}
You are creating two separate instances of JFrame and showing only one.
One instance is created because Window class extends JFrame, and the second is created inside initialize method.
To fix this without a lot of changes in code do this:
private void initialize() {
frame = this;
frame.setBounds(100, 100, 644, 430);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
BTW. change paintComponent(Graphic g) to paint(Graphic g) because JFrame is not a JComponent.
In a ChartPanel context, consider one of the org.jfree.chart.annotations such as XYLineAnnotation, illustrated here and here.
Calling repaint() will trigger your paint(Graphics g) method to be called. So, you don't have to explicitly call paint().

How do I set hard limit on a JComponent when setMaximumSize() and setPrefferedSize() don't work?

I'm trying to make an image processing frame similar to one found in something like Photoshop or Paint Shop Pro and I'm running into problems.
Right now I have a JFrame window with a JDesktopPane. When I click a button, a JInternalFrame is made with the following components in it:
imageLabel = new JLabel("picture.png");
scrollPane.setViewPort(imageLabel);
internalFrame.add(scrollPane); // I also tried with a BorderLayout()
desktopPane.add(internalFrame);
My problem is this: I don't want the JLabel or the JScrollPane to stretch to the size of the JInternalFrame if the JLabel is smaller than the JInternalFrame.
I've tried padding the space around the JLabel with "empty" JLabels. I've tried switching layout styles of the JScrollPane. I've tried setting the preferred and maximum sizes of the JLabel and the JScrollPane to that of picture.png. None of it works for what I need. I don't want the blank "space" around the JLabel to be a part of the JScrollPane or the JLabel so that I can use various MouseEvents to trigger on the picture itself rather than the space left by the "stretched" JLabel or JScrollPane whenever I resize the JInternalFrame.
Thanks in advance.
Edit1: Here is a bit of code that highlights the problem.
import java.awt.*;
import java.awt.event.*;
class fooFrame extends JFrame implements MouseListener
{
private static fooFrame frame;
JLabel fooLabel;
public fooFrame()
{
JDesktopPane background = new JDesktopPane();
JInternalFrame internalFrame = new JInternalFrame("Internal Frame", true, true, true, true);
internalFrame.setSize(500, 500);
internalFrame.setLocation(20, 20);
internalFrame.setVisible(true);
Image image = Toolkit.getDefaultToolkit().getImage("test.gif");
fooLabel = new JLabel(new ImageIcon("test.gif"));
fooLabel.setPreferredSize(new Dimension(image.getWidth(null), image.getHeight(null)));
JScrollPane fooScrollPane = new JScrollPane(fooLabel, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
fooScrollPane.setPreferredSize(new Dimension(fooLabel.getWidth(), fooLabel.getHeight()));
fooScrollPane.setViewportView(fooLabel); // add JLabel to JScrollPane
internalFrame.add(fooScrollPane); // add JScrollPane to JInternalFrame
background.add(internalFrame); // add JInternalFrame to JDesktopPanel
this.setContentPane(background); // add JDesktopPanel to JFrame
fooLabel.addMouseListener(this);
}
public void mouseClicked(MouseEvent me)
{
if (me.getSource() == fooLabel)
System.out.println("Clicked the picture.");
}
public void mouseEntered(MouseEvent me)
{
if (me.getSource() == fooLabel)
System.out.println("Entered the picture.");
}
public void mouseExited(MouseEvent me)
{
if (me.getSource() == fooLabel)
System.out.println("Exited the picture.");
}
public void mousePressed(MouseEvent me){}
public void mouseReleased(MouseEvent me){}
public static void createAndShowGUI()
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e) { }
frame = new fooFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("foo");
frame.setSize(800,600);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
You will have to get your own "test.gif" and if you make the internalFrame larger than the picture it fills the remaining space with the label. As all the mouseEvents fire when I cross the internalFrame rather than onto the picture like I want to have happen.
Edit2: Code modified with Kleopatra's suggestions.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.LineBorder;
public class a1
{
public static void main(String[] args)
{
fooFrame.createAndShowGUI();
}
}
class fooFrame extends JFrame implements MouseListener
{
private static fooFrame frame;
JLabel fooLabel;
public fooFrame()
{
JDesktopPane background = new JDesktopPane();
JInternalFrame internalFrame = new JInternalFrame("Internal Frame", true, true, true, true);
internalFrame.setLocation(20, 20);
internalFrame.setVisible(true);
internalFrame.pack();
Image image = Toolkit.getDefaultToolkit().getImage("test.gif");
fooLabel = new JLabel(new ImageIcon(image));
fooLabel.setBorder(new LineBorder(Color.PINK));
JScrollPane fooScrollPane = new JScrollPane((fooLabel), JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
internalFrame.setLayout(new BoxLayout(internalFrame.getContentPane(), BoxLayout.LINE_AXIS));
fooScrollPane.setViewportView(fooLabel); // add JLabel to JScrollPane
internalFrame.add(fooScrollPane); // add JScrollPane to JInternalFrame
background.add(internalFrame); // add JInternalFrame to JDesktopPanel
this.setContentPane(background); // add JDesktopPanel to JFrame
fooLabel.addMouseListener(this);
}
public void mouseClicked(MouseEvent me)
{
if (me.getSource() == fooLabel)
System.out.println("Clicked the picture.");
}
public void mouseEntered(MouseEvent me)
{
if (me.getSource() == fooLabel)
System.out.println("Entered the picture.");
}
public void mouseExited(MouseEvent me)
{
if (me.getSource() == fooLabel)
System.out.println("Exited the picture.");
}
public void mousePressed(MouseEvent me)
{
}
public void mouseReleased(MouseEvent me)
{
}
#Override
public Dimension getMaximumSize()
{
return getPreferredSize();
}
public static void createAndShowGUI()
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e)
{
}
frame = new fooFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("foo");
frame.setSize(800, 600);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
In this example, the internal frame will initially be no more than MAX_SIZE pixels. Smaller pictures will be sized so that scrolling is not required.
Addendum: Reading the title more closely, you may also want to limit the internal frame's maximum size:
internalFrame.setMaximumSize(new Dimension(fooLabel.getPreferredSize()));
Addendum: This variation may help clarify the problem. With the default layout, BorderLayout.CENTER, the scroll bars appear as required, but the MouseListener does not behave as desired. With a layout that respects preferred sizes, FlowLayout, the MouseListener reports correctly, but the the scroll bars never appear, as the label's preferred size never changes. I've added synthetic images for convenience.
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import javax.swing.*;
class PictureFrame extends JFrame {
private static final String NAME = "image.jpg";
public PictureFrame() {
JDesktopPane dtp = new JDesktopPane();
dtp.add(new MyFrame("Large", FauxImage.create(300, 500), 50));
dtp.add(new MyFrame("Small", FauxImage.create(200, 200), 25));
this.add(dtp);
}
private static class MyFrame extends JInternalFrame {
private static final int MAX_SIZE = 256;
public MyFrame(String title, Image image, int offset) {
super(title, true, true, true, true);
//this.setLayout(new FlowLayout());
final JLabel label = new JLabel(new ImageIcon(image));
this.add(new JScrollPane(label));
this.pack();
int w = Math.min(MAX_SIZE, image.getWidth(null));
int h = Math.min(MAX_SIZE, image.getHeight(null));
Insets i = this.getInsets();
this.setSize(w + i.left + i.right, h + i.top + i.bottom);
this.setLocation(offset, offset);
this.setVisible(true);
label.addMouseListener(new MouseAdapter() {
#Override
public void mouseEntered(MouseEvent me) {
if (me.getSource() == label) {
System.out.println("Entered.");
}
}
#Override
public void mouseExited(MouseEvent me) {
if (me.getSource() == label) {
System.out.println("Exited.");
}
}
});
}
}
private static class FauxImage {
static public Image create(int w, int h) {
BufferedImage bi = new BufferedImage(
w, h, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = bi.createGraphics();
g2d.setPaint(Color.lightGray);
g2d.fillRect(0, 0, w, h);
g2d.setColor(Color.black);
String s = w + "\u00D7" + h;
int x = (w - g2d.getFontMetrics().stringWidth(s)) / 2;
g2d.drawString(s, x, 24);
g2d.dispose();
return bi;
}
}
public static void createAndShowGUI() {
PictureFrame frame = new PictureFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("PictureFrame");
frame.setSize(640, 400);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
#Override
public void run() {
createAndShowGUI();
}
});
}
}
The answer to layout problems is LayoutManager. Always. It's never setXXSize (though nothing is absolutely absolute :-)
Just to be sure I understand what you are after:
always have the label at its pref size (which by default is the size of its icon)
allow scrolling if the internalFrame is smaller than the pref, that is the scrollpane is resized to smaller, label remains at its pref
disallow strectching of the scrollPane and its content if the internalframe is larger than pref
The important LayoutManager in this scenario is the one which control the size of the scrollpane: that's the LayoutManager of the internalFrame's contentPane. The default manager is a BorderLayout: sizing its center to whatever space is available. We need to replace that with one that respects max and make the center component (the scrollpane) report a max (which typically is Short.MAX)
internalFrame.setLayout(new BoxLayout(internalFrame.getContentPane(), BoxLayout.LINE_AXIS));
Image image = Toolkit.getDefaultToolkit().getImage("test.gif");
fooLabel = new JLabel(new ImageIcon(image));
JScrollPane fooScrollPane = new JScrollPane(fooLabel),
JScrollPane.VERTICAL_SCROLLBAR_NEVER,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) {
#Override
public Dimension getMaximumSize() {
return getPreferredSize();
}
};
internalFrame.add(fooScrollPane); // add JScrollPane to JInternalFrame

java statusbar resize corner (handle)

I try to make a window with a resize handle at the bottom right.
So far I managed to detect the mouse hover and dragging.
The mouse cursor is changing to resize cursor successfully.
But the actually resize operation I'm unsure how to solve.
The Idea I testet at first place is to just setsize on parent when dragging on resize handle.
It works, but then the window get's resize immediately, that's not how the standard resize looks.
The standard resize is a transparent window with white border (may be different on different systems and look and feel).
Is it possible to trigger/use the built in resize mechanism?
Below you have a sample code.
Thanks!
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.RenderingHints;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
public class main extends JFrame {
private JPanel contentPane;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
main frame = new main();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public class StatusBar extends JPanel implements MouseListener, MouseMotionListener {
private Polygon resizeCorner = new Polygon();
private int offsetX;
private int offsetY;
private Dimension offsetSize;
private Cursor resizeCursor = new Cursor(Cursor.SE_RESIZE_CURSOR);
private Cursor defaultCursor = new Cursor(Cursor.DEFAULT_CURSOR);
public StatusBar() {
super();
setPreferredSize(new Dimension(200,40));
this.addMouseListener(this);
this.addMouseMotionListener(this);
}
private void createResizeHandle() {
resizeCorner.reset();
resizeCorner.addPoint(getWidth()-2, getHeight()-2);
resizeCorner.addPoint(getWidth()-40, getHeight()-2);
resizeCorner.addPoint(getWidth()-2, getHeight()-40);
}
#Override
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2;
g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
g2.setColor(Color.red);
createResizeHandle();
g2.drawPolygon(resizeCorner);
}
#Override
public void mouseDragged(MouseEvent e) {
if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {
int width = (int) (this.offsetSize.getWidth() - this.offsetX + e.getXOnScreen());
int height = (int) (this.offsetSize.getHeight() - this.offsetY + e.getYOnScreen());
this.getRootPane().getParent().setSize(width, height);
createResizeHandle();
}
}
#Override
public void mouseMoved(MouseEvent e) {
if (resizeCorner.contains(e.getX(), e.getY())) {
setCursor(resizeCursor);
} else {
setCursor(defaultCursor);
}
}
#Override
public void mouseClicked(MouseEvent arg0) {
}
#Override
public void mouseEntered(MouseEvent arg0) {
}
#Override
public void mouseExited(MouseEvent arg0) {
}
#Override
public void mousePressed(MouseEvent e) {
if (resizeCorner.contains(e.getX(), e.getY())) {
this.offsetX = e.getXOnScreen();
this.offsetY = e.getYOnScreen();
this.offsetSize = this.getRootPane().getParent().getSize();
}
}
#Override
public void mouseReleased(MouseEvent arg0) {
}
}
public main() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
JLabel lblNewLabel = new JLabel("New label");
StatusBar bar = new StatusBar();
contentPane.add(lblNewLabel, BorderLayout.NORTH);
contentPane.add(bar, BorderLayout.SOUTH);
}
}
lots of small mistakes, starts with correct naming for ClassName ... end with usage java reserved words for class/void/method's name(s)
minor changes (now it works for me), with one my mistake against Swing rules, I set there setPreferredSize(new Dimension(400, 300));, lets childrens returns PreferredSize for Container
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
public class MyToolBar extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel contentPane;
public class StatusBarX extends JPanel implements MouseListener, MouseMotionListener {
private static final long serialVersionUID = 1L;
private Polygon resizeCorner = new Polygon();
private int offsetX;
private int offsetY;
private Dimension offsetSize;
private Cursor resizeCursor = new Cursor(Cursor.SE_RESIZE_CURSOR);
private Cursor defaultCursor = new Cursor(Cursor.DEFAULT_CURSOR);
public StatusBarX() {
super();
setPreferredSize(new Dimension(200, 40));
this.addMouseListener(this);
this.addMouseMotionListener(this);
}
private void createResizeHandle() {
resizeCorner.reset();
resizeCorner.addPoint(getWidth() - 2, getHeight() - 2);
resizeCorner.addPoint(getWidth() - 40, getHeight() - 2);
resizeCorner.addPoint(getWidth() - 2, getHeight() - 40);
}
#Override
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2;
g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2.setColor(Color.red);
createResizeHandle();
g2.drawPolygon(resizeCorner);
}
#Override
public void mouseDragged(MouseEvent e) {
if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {
int width = (int) (this.offsetSize.getWidth() - this.offsetX + e.getXOnScreen());
int height = (int) (this.offsetSize.getHeight() - this.offsetY + e.getYOnScreen());
this.getRootPane().getParent().setSize(width, height);
createResizeHandle();
}
}
#Override
public void mouseMoved(MouseEvent e) {
if (resizeCorner.contains(e.getX(), e.getY())) {
setCursor(resizeCursor);
} else {
setCursor(defaultCursor);
}
}
#Override
public void mouseClicked(MouseEvent arg0) {
}
#Override
public void mouseEntered(MouseEvent arg0) {
}
#Override
public void mouseExited(MouseEvent arg0) {
}
#Override
public void mousePressed(MouseEvent e) {
if (resizeCorner.contains(e.getX(), e.getY())) {
this.offsetX = e.getXOnScreen();
this.offsetY = e.getYOnScreen();
this.offsetSize = this.getRootPane().getParent().getSize();
}
}
#Override
public void mouseReleased(MouseEvent arg0) {
}
}
public MyToolBar() {
JLabel lblNewLabel = new JLabel("New label");
StatusBarX bar = new StatusBarX();
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
contentPane.add(lblNewLabel, BorderLayout.NORTH);
contentPane.add(bar, BorderLayout.SOUTH);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocation(100, 100);
setPreferredSize(new Dimension(400, 300));
add(contentPane);
pack();
setVisible(true);
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
#Override
public void run() {
try {
MyToolBar frame = new MyToolBar();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
The standard resize is a transparent window with white border (may be different on different systems and look and feel).
When using Windows XP the standard is to resize top level components (frame, dialog etc) immediately. It doesn't matter what the LAF is.
In general other components don't have resizing functionality built in. The only exception to this that I can think of is JInternalFrame. In this case is does support the "outline" resizing of a component.
So if you want to add this type of functionality to your component then you would need to look at the internal frame UI to find the resizing code.
I would guess that the code would display a Glass Pane when dragging starts and then do the outline custom painting on the Glass Plane. Then on mouseReleased the frame size would be changed.
In case you are interested, Component Resizing shows how I do resizing for any component. It does immediate resizing, not outline resizing.

Drawing a static image over the viewport of a JScrollPane

I am trying to draw a red square over a JScrollPane. The code I have below does an okay job of this, but sometimes when I scroll the viewport too fast, the red square jumps up or down.
This struck me as odd since the JScrollPane itself is stationary, so I assumed Swing would not try to move around the components painted within it. I'm guessing that what's actually happening is that the the red square gets associated with viewport, which display graphics that do move.
Anyway, how do I prevent the red square from jumping around and successfully draw a red square over the list? Maybe I'm taking the wrong approach altogether.
package components;
import java.awt.*;
import java.util.Vector;
import javax.swing.*;
import javax.swing.event.*;
#SuppressWarnings("serial")
public class DialogWithScrollPane extends JFrame {
public DialogWithScrollPane() {
super();
setResizable(false);
Container pane = getContentPane();
Vector<Object> listOfStuff = new Vector<Object>();
for (int i = 0; i < 100; i++) {
listOfStuff.add(Integer.toString(i));
}
final JScrollPane scrollPane = new JScrollPane() {
public void paint(Graphics g) {
System.out.println("JScrollPane.paint() called.");
super.paint(g);
g.setColor(Color.red);
g.fillRect(20, 50, 100, 200);
}
};
JList list = new JList(listOfStuff) {
public void paint(Graphics g) {
System.out.println("JList.paint() called.");
super.paint(g);
// Well, I could do this...
//
// scrollPane.repaint();
//
// ...and it would solve the problem, but it would also result in an
// infinite recursion since JScrollPane.paint() would call this
// function again.
}
};
// Repaint the JScrollPane any time the viewport is moved or an item in the
// list is selected.
scrollPane.getViewport().addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
scrollPane.repaint();
}
});
list.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
scrollPane.repaint();
}
});
scrollPane.setViewportView(list);
pane.add(scrollPane);
setMinimumSize(new Dimension(300, 300));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocation(500, 250);
setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
new DialogWithScrollPane();
}
});
}
}
The JScrollPane should be painting behind the JViewport which should be painting behind the list. I'm guessing that this is only working because you're overriding paint and not paintComponent and calling repaint on the JScrollPane all the time so that it paints itself again after its components are painted.
Perhaps you want to use a JLayeredPane and have it hold the JScrollPane, and paint on it.
edit: or the glasspane as I now see that mre suggests, but I'm afraid if you do that, and set the glasspane visible, you'll lose the ability to interact with the underlying scrollpane.
Edit 2
For e.g.,
import java.awt.*;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.Vector;
import javax.swing.*;
#SuppressWarnings("serial")
public class DialogWithScrollPane2 extends JFrame {
public DialogWithScrollPane2() {
super();
//setResizable(false);
final JPanel pane = (JPanel) getContentPane();
Vector<Object> listOfStuff = new Vector<Object>();
for (int i = 0; i < 100; i++) {
listOfStuff.add(Integer.toString(i));
}
final JScrollPane scrollPane = new JScrollPane();
JList list = new JList(listOfStuff);
scrollPane.setViewportView(list);
final JPanel blueRectPanel = new JPanel() {
#Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.blue);
g.fillRect(20, 50, 100, 200);
}
};
blueRectPanel.setOpaque(false);
final JLayeredPane layeredPane = new JLayeredPane();
layeredPane.add(scrollPane, JLayeredPane.DEFAULT_LAYER);
layeredPane.add(blueRectPanel, JLayeredPane.PALETTE_LAYER);
layeredPane.addComponentListener(new ComponentAdapter() {
private void resizeLayers() {
final JViewport viewport = scrollPane.getViewport();
scrollPane.setBounds(layeredPane.getBounds());
blueRectPanel.setBounds(viewport.getBounds());
SwingUtilities.invokeLater(new Runnable() {
public void run() {
blueRectPanel.setBounds(viewport.getBounds());
}
});
}
#Override
public void componentShown(ComponentEvent e) {
resizeLayers();
}
#Override
public void componentResized(ComponentEvent e) {
resizeLayers();
}
});
pane.add(layeredPane);
setPreferredSize(new Dimension(300, 300));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setLocation(500, 250);
setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
new DialogWithScrollPane2();
}
});
}
}

Categories