logical problem with opening a Sliding Window(Custom window) from 'RIGHT' - LEFT
for a common approach regarding with Top-Level containers such as JFrame or JDialogs, everything is manipulated from a LEFT-to-RIGHT orientation, i have a custom window, with some animated opening with a an Orientation of Left-to-Right, i was trying to make it a Right-To-Left opening with this basic logic, like decrementing the 'x' position twice than the 'width' of the component (i.e for every single decrement of width by '1' the 'x' will have a twice or 3 times decrement update), but i ended up with a Jaggy animated window and it somehow starts with the middle
here is a sample working code for the sliding window (LEFT to RIGHT).
Code :
import com.sun.awt.AWTUtilities;
import java.awt.*;
import java.util.List;
import java.util.*;
import javax.swing.*;
public class TransparentSlideDialog1 extends JDialog {
private Panel panel;
private int widthLimit;
private int heightLimit;
public TransparentSlideDialog1() {
panel = new Panel();
getContentPane().add(panel);
}
public void setDialogSize(int w, int h) {
widthLimit = w;
heightLimit = h;
setSize(w, h);
}
private class Panel extends JPanel implements Runnable {
private Thread runner;
private boolean stop;
private int width;
private int height;
public Panel() {
setLayout(null);
setOpaque(false);
width = 0;
height = 50;
}
public void paintComponent(Graphics g) {
int arc = 20;
Paint p = new GradientPaint(0.0f, 0.000f, new Color(0, 0, 0, 240), width - 50, height - 50, new Color(0, 0, 0, 255), true);
Graphics2D g2 = (Graphics2D) g.create();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setPaint(p);
g2.fillRoundRect(getX() + 20, getY() + 35, width - 50, height - 50, arc, arc);
g2.setStroke(new BasicStroke(2f));
g2.setColor(new Color(150, 150, 150, 255));
g2.drawRoundRect(getX() + 20, getY() + 35, width - 50, height - 50, arc, arc);
}
public void open() {
runner = new Thread(this);
runner.start();
}
public void run() {
while (!stop) {
if (width <= getWidth()) {
width += 5;
}
if (height <= getHeight() && width >= getWidth()) {
height += 3;
}
if (height >= heightLimit && width >= widthLimit) {
runner.interrupt();
stop = true;
}
repaint();
try {
Thread.sleep(2);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
e.printStackTrace();
}
}
}
}
public synchronized void openSlidePanel() {
panel.open();
}
public static void main(String[] args) {
final TransparentSlideDialog1 d = new TransparentSlideDialog1();
d.setDialogSize(1200, 640);
d.openSlidePanel();
d.setModal(true);
d.setLocationRelativeTo(null);
d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
d.setUndecorated(true);
AWTUtilities.setWindowOpaque(d, false);
d.setVisible(true);
}
}
i just need some guide on the logical part on how can i accomplish a RIGHT-TO-LEFT opening of this window, or maybe is there any technical concerns i need to consider.
Re: logical problem with opening a Sliding Window(Custom window) from 'RIGHT' - LEFT
i got an article although not technically relevant(Java code), but the logic implies a major concern
Quote:
Top of a web page is zero so any negative value is off the page.
Left of a web page also zero so any negative value is off the page.
Right and bottom of a web page are infinite so any positive value is on the page.
There is no value that will take an object off of the right or bottom of a web page.
the problem was a Transition regarding with an animated opening window