Flashing undecorated JDialog on resize+setLocation

Hi everyone

I have a undecorated JDialog with custome resize code. Here is a part of my code

frame.setUndecorated(true);

frame.addMouseListener(new MouseListener()

{

publicvoid mousePressed(MouseEvent e)

{

sp = e.getPoint();

compStartHeight = frame.getSize().height;

compStartWidth = frame.getSize().width;

frameLoc = frame.getLocation();

}

publicvoid mouseEntered(MouseEvent e)

{

}

publicvoid mouseExited(MouseEvent e)

{

if (sp ==null)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

}

}

publicvoid mouseClicked(MouseEvent e)

{

}

publicvoid mouseReleased(MouseEvent e)

{

sp =null;

}

});

frame.addMouseMotionListener(new MouseMotionListener()

{

publicvoid mouseMoved(MouseEvent e)

{

Point p = e.getPoint();

if (p.y > e.getComponent().getSize().height - 5)

{

if (p.x < 5)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR));

}

elseif (p.x > e.getComponent().getSize().width - 5)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));

}

else

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));

}

//

}

elseif (p.y < 5)

{

if (p.x < 5)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR));

}

elseif (p.x > e.getComponent().getSize().width - 5)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR));

}

else

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR));

}

}

else

{

if (p.x < 5)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));

}

elseif (p.x > e.getComponent().getSize().width - 5)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));

}

}

}

publicvoid mouseDragged(MouseEvent e)

{

Point p = e.getPoint();

int compWidth = frame.getSize().width;

int compHeight = frame.getSize().height;

if (frame.getCursor().getType() == Cursor.S_RESIZE_CURSOR)

{

int nextHeight = compStartHeight+p.y-sp.y;

if (nextHeight > Share.MINIMIZED_HEIGHT)

{

frame.setSize(compWidth,nextHeight);

frame.validate();

}

}

elseif (frame.getCursor().getType() == Cursor.N_RESIZE_CURSOR)

{

int nextHeight = compStartHeight+sp.y-p.y;

if (nextHeight > Share.MINIMIZED_HEIGHT)

{

frame.setLocation(frameLoc.x, frameLoc.y-(sp.y-p.y));

frame.setSize(compWidth,nextHeight);

frame.validate();

//frame.repaint();

}

}

elseif (frame.getCursor().getType() == Cursor.E_RESIZE_CURSOR)

{

int nextWidth = compStartWidth+p.x-sp.x;

if (nextWidth > Share.MINIMIZED_HEIGHT)

{

frame.setSize(nextWidth,compHeight);

frame.validate();

//frame.repaint();

}

}

elseif (frame.getCursor().getType() == Cursor.W_RESIZE_CURSOR)

{

int nextWidth = compStartWidth+(sp.x-p.x);

if (nextWidth > Share.MINIMIZED_HEIGHT)

{

frame.setLocation(frameLoc.x-(sp.x-p.x), frameLoc.y);

frame.setSize(nextWidth,compHeight);

frame.validate();

//frame.repaint();

}

}

elseif (frame.getCursor().getType() == Cursor.SE_RESIZE_CURSOR)

{

int nextWidth = compStartWidth+(p.x-sp.x);

int nextHeight = compStartHeight+(p.y-sp.y);

if (nextWidth > Share.MINIMIZED_HEIGHT)

{

frame.setSize(nextWidth,nextHeight);

frame.validate();

//frame.repaint();

}

}

elseif (frame.getCursor().getType() == Cursor.SW_RESIZE_CURSOR)

{

int nextWidth = compStartWidth+(sp.x-p.x);

int nextHeight = compStartHeight+(p.y-sp.y);

if (nextWidth > Share.MINIMIZED_HEIGHT)

{

frame.setLocation(frameLoc.x-(sp.x-p.x), frameLoc.y);

frame.setSize(nextWidth,nextHeight);

frame.validate();

//frame.repaint();

}

}

elseif (frame.getCursor().getType() == Cursor.NW_RESIZE_CURSOR)

{

int nextWidth = compStartWidth+(sp.x-p.x);

int nextHeight = compStartHeight+(sp.y-p.y);

if (nextWidth > Share.MINIMIZED_HEIGHT)

{

frame.setLocation(frameLoc.x-(sp.x-p.x), frameLoc.y-(sp.y-p.y));

frame.setSize(nextWidth,nextHeight);

frame.validate();

//frame.repaint();

}

}

elseif (frame.getCursor().getType() == Cursor.NE_RESIZE_CURSOR)

{

int nextWidth = compStartWidth+p.x-sp.x;

int nextHeight = compStartHeight+(sp.y-p.y);

if (nextWidth > Share.MINIMIZED_HEIGHT)

{

frame.setLocation(frameLoc.x, frameLoc.y-(sp.y-p.y));

frame.setSize(nextWidth,nextHeight);

frame.validate();

//frame.repaint();

}

}

else

{

int x = frame.getX()+p.x-sp.x;

int y = frame.getY()+p.y-sp.y;

setLocation(x,y);

}

}

});

Here is the code that can be compile if you want to try ou

import java.awt.*;

import javax.swing.*;

import javax.swing.table.*;

import java.awt.event.*;

import java.util.*;

import javax.swing.event.*;

import java.text.SimpleDateFormat;

import java.text.DateFormat;

import java.net.URL;

publicclass TrdHistForm

{

privatestaticfinalint MAX_LINE = Share.MAX_HIST_LINE;

privatestaticfinalint ROW_HEIGHT = 20;

private JDialog frame =new JDialog();

private JPanel mainPane =new JPanel(new BorderLayout());

private JPanel titleBar =new JPanel();

private JLabel title =new JLabel("", JLabel.LEFT);

private JTable table;

private TableView view;

private Vector t;

privateboolean minimized =false;// starts up as normal size window, not minimized

private Point loc =new Point(0,0);

private Dimension size =new Dimension(0,0);

private Point sp;

private Point frameLoc =new Point(0,0);

//private Dimension frameSize = new Dimension(0,0);

privateintcompStartHeight;

privateint compStartWidth;

privatestatic SimpleDateFormat sdf =new SimpleDateFormat("d/MM/yyyy h:mm:ss a");

privatestatic SimpleDateFormat sdf1 =new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");

privatestatic DateFormat format =new SimpleDateFormat("HH:mm:ss");

privatestaticint PRICE_C = 0;

privatestaticint VOL_C = 1;

privatestaticint TIME_C = 2;

privatestaticint PRICE_W = 70;

privatestaticint VOL_W = 55;

privatestaticint TIME_W = 60;

privatestaticint[] colWidth =

{

PRICE_W, VOL_W, TIME_W

};

privatestatic String[] colOrgName =

{

"price","vol","time"

};

private String PRICE_N ="Price";

private String VOL_N ="Volume";

private String TIME_N ="Time";

private String[] colName =

{

PRICE_N, VOL_N, TIME_N

};

private Color rowColor =new Color(0x00, 0x80, 0x00);//VERY DARK GREEN

public TrdHistForm()

{

minimized =false;

loc =new Point(0,0);

size =new Dimension(0,0);

Dimension butDim =new Dimension(15,15);

//mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS));

//mainPane.setLayout(new BorderLayout());

//mainPane.setOpaque(false);

//JPanel upPane = new JPanel();

setupTitleBar();

URL url = TrdHistForm.class.getResource("tvbg.JPG");

ImageIcon icon =new ImageIcon(url);

mainPane.add(Share.wrapInBackgroundImage(titleBar, icon), BorderLayout.NORTH);

/*

JPanel butPane = new JPanel(new FlowLayout(FlowLayout.RIGHT));

JButton but = new JButton("_");

but.setActionCommand("Minimized");

but.setToolTipText("Minimized this window");

but.setMargin(new Insets(0,0,0,0));

but.setMaximumSize(butDim);

but.setMinimumSize(butDim);

but.setPreferredSize(butDim);

but.addActionListener(this);

but.setFocusPainted(false);

butPane.add(but);

but = new JButton("\u25FB");

but.setActionCommand("Restore");

but.setToolTipText("Restore this window to previous location and size");

but.setMaximumSize(butDim);

but.setMinimumSize(butDim);

but.setPreferredSize(butDim);

but.setMargin(new Insets(0,0,0,0));

but.addActionListener(this);

but.setFocusPainted(false);

butPane.add(but);

mainPane.add(butPane);

mainPane.add(Box.createRigidArea(new Dimension(0,1)));

*/

t =new Vector();

view =new TableView();

int colNum = colName.length;

table =new JTable(view.model);

// Call custom rendering

TableColumn column =null;

for(int i = 0; i < colNum; i++)

{

column = table.getColumnModel().getColumn(i);

column.setCellRenderer(new CustomRenderer());

}

// Set up columns' widths

for (int i = 0; i < colNum; i++)

{

column = table.getColumnModel().getColumn(i);

column.setPreferredWidth(colWidth[i]);

}

int i = 0;

for (int j = 0; j < colWidth.length; j++)

{

i = i + colWidth[j];

}

//table.setShowGrid(false);

//table.setOpaque(false);

//table.setPreferredScrollableViewportSize(new Dimension(i, 500));

table.setRowHeight(ROW_HEIGHT);

table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

//table.setGridColor(new Color(239, 239, 239));

JScrollPane scrollPane =new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

//scrollPane.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));

//scrollPane.setOpaque(false);

//scrollPane.getViewport().setOpaque(false);

//scrollPane.getVerticalScrollBar().setOpaque(false);

//scrollPane.getHorizontalScrollBar().setOpaque(false);

mainPane.add(scrollPane, BorderLayout.CENTER);

mainPane.setBorder(BorderFactory.createLineBorder(new Color(0x00, 0x66, 0xCC), 3));

//URL url = AtBestForm.class.getResource("tvbg.JPG");

//ImageIcon icon = new ImageIcon(url);

//frame.setContentPane(Share.wrapInBackgroundImage(mainPane, icon));

frame.setContentPane(mainPane);

frame.setVisible(false);

//frame.pack();

frame.setSize(new Dimension(i, 500));

//frame.setDoubleBuffered(true);

//frame.setResizable(false);

frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

frame.setLocation(0,0);

frame.setUndecorated(true);

frame.addMouseListener(new MouseListener()

{

publicvoid mousePressed(MouseEvent e)

{

sp = e.getPoint();

compStartHeight = frame.getSize().height;

compStartWidth = frame.getSize().width;

frameLoc = frame.getLocation();

}

publicvoid mouseEntered(MouseEvent e)

{

}

publicvoid mouseExited(MouseEvent e)

{

if (sp ==null)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

}

}

publicvoid mouseClicked(MouseEvent e)

{

}

publicvoid mouseReleased(MouseEvent e)

{

sp =null;

}

});

frame.addMouseMotionListener(new MouseMotionListener()

{

publicvoid mouseMoved(MouseEvent e)

{

Point p = e.getPoint();

if (p.y > e.getComponent().getSize().height - 5)

{

if (p.x < 5)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR));

}

elseif (p.x > e.getComponent().getSize().width - 5)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));

}

else

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));

}

//

}

elseif (p.y < 5)

{

if (p.x < 5)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR));

}

elseif (p.x > e.getComponent().getSize().width - 5)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR));

}

else

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR));

}

}

else

{

if (p.x < 5)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));

}

elseif (p.x > e.getComponent().getSize().width - 5)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));

}

}

}

publicvoid mouseDragged(MouseEvent e)

{

Point p = e.getPoint();

int compWidth = frame.getSize().width;

int compHeight = frame.getSize().height;

if (frame.getCursor().getType() == Cursor.S_RESIZE_CURSOR)

{

int nextHeight = compStartHeight+p.y-sp.y;

if (nextHeight > Share.MINIMIZED_HEIGHT)

{

frame.setSize(compWidth,nextHeight);

frame.validate();

}

}

elseif (frame.getCursor().getType() == Cursor.N_RESIZE_CURSOR)

{

int nextHeight = compStartHeight+sp.y-p.y;

if (nextHeight > Share.MINIMIZED_HEIGHT)

{

frame.setLocation(frameLoc.x, frameLoc.y-(sp.y-p.y));

frame.setSize(compWidth,nextHeight);

frame.validate();

//frame.repaint();

}

}

elseif (frame.getCursor().getType() == Cursor.E_RESIZE_CURSOR)

{

int nextWidth = compStartWidth+p.x-sp.x;

if (nextWidth > Share.MINIMIZED_HEIGHT)

{

frame.setSize(nextWidth,compHeight);

frame.validate();

//frame.repaint();

}

}

elseif (frame.getCursor().getType() == Cursor.W_RESIZE_CURSOR)

{

int nextWidth = compStartWidth+(sp.x-p.x);

if (nextWidth > Share.MINIMIZED_HEIGHT)

{

frame.setLocation(frameLoc.x-(sp.x-p.x), frameLoc.y);

frame.setSize(nextWidth,compHeight);

frame.validate();

//frame.repaint();

}

}

elseif (frame.getCursor().getType() == Cursor.SE_RESIZE_CURSOR)

{

int nextWidth = compStartWidth+(p.x-sp.x);

int nextHeight = compStartHeight+(p.y-sp.y);

if (nextWidth > Share.MINIMIZED_HEIGHT)

{

frame.setSize(nextWidth,nextHeight);

frame.validate();

//frame.repaint();

}

}

elseif (frame.getCursor().getType() == Cursor.SW_RESIZE_CURSOR)

{

int nextWidth = compStartWidth+(sp.x-p.x);

int nextHeight = compStartHeight+(p.y-sp.y);

if (nextWidth > Share.MINIMIZED_HEIGHT)

{

frame.setLocation(frameLoc.x-(sp.x-p.x), frameLoc.y);

frame.setSize(nextWidth,nextHeight);

frame.validate();

//frame.repaint();

}

}

elseif (frame.getCursor().getType() == Cursor.NW_RESIZE_CURSOR)

{

int nextWidth = compStartWidth+(sp.x-p.x);

int nextHeight = compStartHeight+(sp.y-p.y);

if (nextWidth > Share.MINIMIZED_HEIGHT)

{

frame.setLocation(frameLoc.x-(sp.x-p.x), frameLoc.y-(sp.y-p.y));

frame.setSize(nextWidth,nextHeight);

frame.validate();

//frame.repaint();

}

}

elseif (frame.getCursor().getType() == Cursor.NE_RESIZE_CURSOR)

{

int nextWidth = compStartWidth+p.x-sp.x;

int nextHeight = compStartHeight+(sp.y-p.y);

if (nextWidth > Share.MINIMIZED_HEIGHT)

{

frame.setLocation(frameLoc.x, frameLoc.y-(sp.y-p.y));

frame.setSize(nextWidth,nextHeight);

frame.validate();

//frame.repaint();

}

}

else

{

int x = frame.getX()+p.x-sp.x;

int y = frame.getY()+p.y-sp.y;

setLocation(x,y);

}

}

});

}

privatevoid setupTitleBar()

{

titleBar.setLayout(new BorderLayout());

//titleBar.setToolTipText("Double click here to minimize the window");

titleBar.setOpaque(false);

titleBar.setBackground(Color.BLUE);

titleBar.setBorder(BorderFactory.createLineBorder(new Color(0x00, 0x66, 0xCC), 2));

title.setForeground(Color.WHITE);

title.setOpaque(false);

titleBar.add(title, BorderLayout.WEST);

FlowLayout flow =new FlowLayout(FlowLayout.LEFT);

flow.setVgap(0);

flow.setHgap(0);

JPanel conPane =new JPanel(flow);

conPane.setOpaque(false);

// Setup minimize label

JLabel lab =new JLabel(" _ ");

lab.setForeground(Color.WHITE);

lab.setOpaque(false);

lab.addMouseListener(new MouseListener()

{

publicvoid mousePressed(MouseEvent e)

{

}

publicvoid mouseReleased(MouseEvent e)

{

//frame.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

}

publicvoid mouseEntered(MouseEvent e)

{

//frame.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

}

publicvoid mouseExited(MouseEvent e)

{

//frame.setCursor(Cursor.getDefaultCursor());

}

publicvoid mouseClicked(MouseEvent e)

{

if (minimized ==false)

{

size = frame.getSize();

//titleBar.setToolTipText("Double click here to restore the window");

frame.setSize(((int)size.getWidth()), Share.MINIMIZED_HEIGHT);

minimized =true;

}

}

});

conPane.add(lab);

// Setup restore label

lab =new JLabel(" " +"\u25FB" +" ", JLabel.RIGHT);

lab.setOpaque(false);

lab.setForeground(Color.WHITE);

lab.addMouseListener(new MouseListener()

{

publicvoid mousePressed(MouseEvent e)

{

}

publicvoid mouseReleased(MouseEvent e)

{

//frame.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

}

publicvoid mouseEntered(MouseEvent e)

{

//frame.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

}

publicvoid mouseExited(MouseEvent e)

{

//frame.setCursor(Cursor.getDefaultCursor());

}

publicvoid mouseClicked(MouseEvent e)

{

if (minimized ==true)

{

frame.setSize(size);

//titleBar.setToolTipText("Double click here to minimize the window");

minimized =false;

}

}

});

conPane.add(lab);

// Setup close label

lab =new JLabel(" x ", JLabel.RIGHT);

lab.setForeground(Color.WHITE);

lab.setOpaque(false);

lab.addMouseListener(new MouseListener()

{

publicvoid mousePressed(MouseEvent e)

{

}

publicvoid mouseReleased(MouseEvent e)

{

//frame.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

}

publicvoid mouseEntered(MouseEvent e)

{

//frame.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

}

publicvoid mouseExited(MouseEvent e)

{

//frame.setCursor(Cursor.getDefaultCursor());

}

publicvoid mouseClicked(MouseEvent e)

{

//frame.setVisible(false);

System.exit(0);

}

});

conPane.add(lab);

titleBar.add(conPane, BorderLayout.EAST);

titleBar.addMouseMotionListener(new MouseMotionListener()

{

publicvoid mouseDragged(MouseEvent e)

{

//int x = ((int)frame.getLocation().getX());

//int y = ((int)frame.getLocation().getY());

//frame.setLocation(e.getX() + (x-e.getX()), e.getY() + (y-e.getY()));

Point p = frame.getLocationOnScreen();

frame.setLocation(p.x + e.getX() - loc.x,p.y + e.getY() - loc.y);

}

publicvoid mouseMoved(MouseEvent e)

{

}

});

titleBar.addMouseListener(new MouseListener()

{

publicvoid mousePressed(MouseEvent e)

{

loc.x = e.getPoint().x;

loc.y = e.getPoint().y;

}

publicvoid mouseReleased(MouseEvent e)

{

//frame.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

}

publicvoid mouseEntered(MouseEvent e)

{

//frame.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

}

publicvoid mouseExited(MouseEvent e)

{

//frame.setCursor(Cursor.getDefaultCursor());

}

publicvoid mouseClicked(MouseEvent e)

{

}

});

}

publicvoid setFrameTitle(String s)

{

title.setText(" " + s);

}

publicvoid setVisible(boolean b)

{

frame.setVisible(b);

}

privateclass TableView

{

MyTableModel model;

private TableView()

{

try

{

model =new MyTableModel();

}

catch (Exception exc)

{

Share.d("TableView E: " + exc.toString());

}

}

class MyTableModelextends AbstractTableModel

{

publicint getColumnCount()

{

return colName.length;

}

publicint getRowCount()

{

if (t ==null)

{

return 0;

}

else

{

return t.size();

}

}

public String getColumnName(int col)

{

return colName[col];

}

public Object getValueAt(int row,int col)

{

String[] data = t.get(row).toString().split(",");

return data[col];

}

publicboolean isCellEditable(int row,int col)

{

returnfalse;

}

publicvoid setValueAt(Object value,int row,int col)

{

String[] data = t.get(row).toString().split(",");

data[col] = value.toString();

String s ="";

for (int i = 0; i < data.length; i++)

{

s = s + data;

if (i != data.length - 1)

{

s = s +",";

}

}

t.set(row, s);

fireTableCellUpdated(row, col);

}

publicvoid setData(Vector newData)

{

t = newData;

fireTableDataChanged();

}

}

}

privateclass CustomRendererextends JLabelimplements TableCellRenderer

{

public Component getTableCellRendererComponent(JTable table, Object value,boolean isSelected,boolean hasFocus,int rowIndex,int vColIndex)

{

try

{

// 08/06/2007 18:54:44,62000,4,,

setOpaque(true);

setForeground(Color.WHITE);

if (vColIndex == PRICE_C)

{

setText(" " + value.toString());

setHorizontalAlignment(JLabel.LEFT);

if (rowIndex == 0)

{

//setForeground(new Color(0x00, 0x80, 0x00)); //VERY DARK GREEN

//setForeground(Color.green);

setBackground(new Color(0x00, 0x80, 0x00));//VERY DARK GREEN

rowColor =new Color(0x00, 0x80, 0x00);

}

else

{

Double d = getPrice(rowIndex - 1) - getPrice(rowIndex);

if (d < 0.0)

{

//setForeground(new Color(0x00, 0x80, 0x00)); //VERY DARK GREEN

//setForeground(Color.green);

setBackground(new Color(0x00, 0x80, 0x00));//VERY DARK GREEN

rowColor =new Color(0x00, 0x80, 0x00);

}

elseif (d > 0.0)

{

//setForeground(new Color(0xcc, 0xcc, 0x00));

setBackground(Share.sellCol);//VERY DARK GREEN

rowColor = Share.sellCol;

}

elseif (d == 0.0)

{

setForeground(Color.BLACK);

setBackground(null);

rowColor = Color.WHITE;

//setForeground(Color.WHITE);

}

}

}

elseif (vColIndex == TIME_C)

{

Date d;

if (value.toString().split(" ").length == 3)

{

d = sdf.parse(value.toString());

}

else

{

d = sdf1.parse(value.toString());

}

setText(format.format(d));

setHorizontalAlignment(JLabel.RIGHT);

setBackground(rowColor);

if (rowColor == Color.WHITE)

{

setForeground(Color.BLACK);

}

else

{

setForeground(Color.WHITE);

}

}

elseif (vColIndex == VOL_C)

{

setText(value.toString() +" ");

setHorizontalAlignment(JLabel.RIGHT);

setBackground(rowColor);

if (rowColor == Color.WHITE)

{

setForeground(Color.BLACK);

}

else

{

setForeground(Color.WHITE);

}

}

else

{

// For future buyer and seller info

}

}

catch (Exception exc)

{

Share.d("CustomRenderer E: " + exc.toString());

}

returnthis;

}

}

publicvoid addRow(String s)

{

if (t.size() == MAX_LINE)

{

t.remove(MAX_LINE - 1);

}

t.add(0, s);

view.model.setData(t);

}

publicdouble getPrice(int i)

{

return(Double.parseDouble((t.get(i).toString().split(","))[0]));

}

public Point getLocation()

{

return frame.getLocation();

}

publicvoid setLocation(int x,int y)

{

frame.setLocation(x, y);

}

publicvoid setOnTop(boolean b)

{

frame.setAlwaysOnTop(b);

}

publicvoid removeAll()

{

t.clear();

view.model.setData(t);

}

/*

public void actionPerformed(ActionEvent e)

{

String item = e.getActionCommand();

if (item.equals("Minimized"))

{

if (minimized == false)

{

loc = frame.getLocation();

size = frame.getSize();

if (Share.MINIMIZED_WIDTH + size.getWidth() > Share.SCREEN_WIDTH)

{

Share.MINIMIZED_ROW++;

Share.MINIMIZED_WIDTH = 0;

//frame.setLocation(Share.MINIMIZED_WIDTH, Share.MINIMIZED_START_POS);

frame.setSize(((int)size.getWidth()), Share.MINIMIZED_HEIGHT);

frame.setLocation(Share.MINIMIZED_WIDTH, Share.MINIMIZED_START_POS-(Share.MINIMIZED_ROW*Share.MINIMIZED_HEIGHT));

Share.MINIMIZED_WIDTH = Share.MINIMIZED_WIDTH + ((int)size.getWidth());

}

else

{

//frame.setLocation(Share.MINIMIZED_WIDTH, Share.MINIMIZED_START_POS);

frame.setSize(((int)size.getWidth()), Share.MINIMIZED_HEIGHT);

frame.setLocation(Share.MINIMIZED_WIDTH, Share.MINIMIZED_START_POS-(Share.MINIMIZED_ROW*Share.MINIMIZED_HEIGHT));

Share.MINIMIZED_WIDTH = Share.MINIMIZED_WIDTH + ((int)size.getWidth());

}

Share.MINIMIZED_NUM++;

minimized = true;

}

}

else if (item.equals("Restore"))

{

if (minimized == true)

{

frame.setLocation(loc);

frame.setSize(size);

frame.setVisible(true);

if (Share.MINIMIZED_WIDTH - size.getWidth() < 0)

{

Share.MINIMIZED_WIDTH = Share.SCREEN_WIDTH;

Share.MINIMIZED_ROW--;

}

else

{

Share.MINIMIZED_WIDTH = Share.MINIMIZED_WIDTH - ((int)size.getWidth());

}

Share.MINIMIZED_NUM--;

minimized = false;

}

}

}

*/

publicstaticvoid main(String[] args)

{

System.getProperties().put("sun.awt.noerasebackground","true");

TrdHistForm form =new TrdHistForm();

form.setFrameTitle("TEST");

form.addRow("2,69000,2007/07/07 05:05:05");

form.setVisible(true);

}

}

The problem is that when a resize that needs a setLocation() to go with it, the frame flash/flicker a lot. I already tried to set "sun.awt.noerasebackground" to "true" but it didn't help me. Is there another way to solve the flickering problem?

I notice on normal frames, there is an outline drawn as the mouse moves around, then the windows resize/setLocation at mouse release events. How can I do this (if the flash/flicker problem can't be solved)?

Thank you very much for your time!!

Cheers!

[53331 byte] By [BuggyVBa] at [2007-11-27 11:54:02]
# 1

Well, I'm not going to read through all that unnecessary code to see what you are doing.

You need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)",

see http://homepage1.nifty.com/algafield/sscce.html,

Here is a SSCCE that shows how to move a window without flickering:

http://forum.java.sun.com/thread.jspa?forumID=57&threadID=599181

camickra at 2007-7-29 18:53:38 > top of Java-index,Desktop,Core GUI APIs...
# 2

Thanks for the reply! But I don't have a problem with moving the undecorated JDialog. It's the resize operations that I try to do. If the resize operations need to resize and setLocation (i.e NW, SW, NE, W, N resize) then my JDialog will flash... I doubt that you need to read it... If you are familiar with this kind of things then once you compile and run it, you will probably know the fix right away...

Here is the compilable code

import java.awt.*;

import javax.swing.*;

import javax.swing.table.*;

import java.awt.event.*;

import java.util.*;

import javax.swing.event.*;

import java.text.SimpleDateFormat;

import java.text.DateFormat;

import java.net.URL;

public class MoveWindow

{

private static final int MAX_LINE = 100;

private static final int ROW_HEIGHT = 20;

private JDialog frame = new JDialog();

private JPanel mainPane = new JPanel(new BorderLayout());

private JPanel titleBar = new JPanel();

private JLabel title = new JLabel("AA", JLabel.LEFT);

private JTable table;

private TableView view;

private Vector t;

private boolean minimized = false; // starts up as normal size window, not minimized

private Point loc = new Point(0,0);

private Dimension size = new Dimension(0,0);

private Point sp;

private Point frameLoc = new Point(0,0);

//private Dimension frameSize = new Dimension(0,0);

private intcompStartHeight;

private int compStartWidth;

private static SimpleDateFormat sdf = new SimpleDateFormat("d/MM/yyyy h:mm:ss a");

private static SimpleDateFormat sdf1 = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");

private static DateFormat format = new SimpleDateFormat("HH:mm:ss");

private static int PRICE_C = 0;

private static int VOL_C = 1;

private static int TIME_C = 2;

private static int PRICE_W = 70;

private static int VOL_W = 55;

private static int TIME_W = 60;

private static int[] colWidth =

{

PRICE_W, VOL_W, TIME_W

};

private static String[] colOrgName =

{

"price","vol","time"

};

private String PRICE_N = "Price";

private String VOL_N = "Volume";

private String TIME_N = "Time";

private String[] colName =

{

PRICE_N, VOL_N, TIME_N

};

private Color rowColor = new Color(0x00, 0x80, 0x00); //VERY DARK GREEN

private static final int MINIMIZED_HEIGHT = 50;

public MoveWindow()

{

minimized = false;

loc = new Point(0,0);

size = new Dimension(0,0);

Dimension butDim = new Dimension(15,15);

//mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS));

//mainPane.setLayout(new BorderLayout());

//mainPane.setOpaque(false);

//JPanel upPane = new JPanel();

setupTitleBar();

//URL url = TrdHistForm.class.getResource("tvbg.JPG");

//ImageIcon icon = new ImageIcon(url);

//mainPane.add(Share.wrapInBackgroundImage(titleBar, icon), BorderLayout.NORTH);

mainPane.add(titleBar,BorderLayout.NORTH);

/*

JPanel butPane = new JPanel(new FlowLayout(FlowLayout.RIGHT));

JButton but = new JButton("_");

but.setActionCommand("Minimized");

but.setToolTipText("Minimized this window");

but.setMargin(new Insets(0,0,0,0));

but.setMaximumSize(butDim);

but.setMinimumSize(butDim);

but.setPreferredSize(butDim);

but.addActionListener(this);

but.setFocusPainted(false);

butPane.add(but);

but = new JButton("\u25FB");

but.setActionCommand("Restore");

but.setToolTipText("Restore this window to previous location and size");

but.setMaximumSize(butDim);

but.setMinimumSize(butDim);

but.setPreferredSize(butDim);

but.setMargin(new Insets(0,0,0,0));

but.addActionListener(this);

but.setFocusPainted(false);

butPane.add(but);

mainPane.add(butPane);

mainPane.add(Box.createRigidArea(new Dimension(0,1)));

*/

t = new Vector();

view = new TableView();

int colNum = colName.length;

table = new JTable(view.model);

// Call custom rendering

TableColumn column = null;

for(int i = 0; i < colNum; i++)

{

column = table.getColumnModel().getColumn(i);

column.setCellRenderer(new CustomRenderer());

}

// Set up columns' widths

for (int i = 0; i < colNum; i++)

{

column = table.getColumnModel().getColumn(i);

column.setPreferredWidth(colWidth[i]);

}

int i = 0;

for (int j = 0; j < colWidth.length; j++)

{

i = i + colWidth[j];

}

//table.setShowGrid(false);

//table.setOpaque(false);

//table.setPreferredScrollableViewportSize(new Dimension(i, 500));

table.setRowHeight(ROW_HEIGHT);

table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

//table.setGridColor(new Color(239, 239, 239));

JScrollPane scrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

//scrollPane.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));

//scrollPane.setOpaque(false);

//scrollPane.getViewport().setOpaque(false);

//scrollPane.getVerticalScrollBar().setOpaque(false);

//scrollPane.getHorizontalScrollBar().setOpaque(false);

mainPane.add(scrollPane, BorderLayout.CENTER);

mainPane.setBorder(BorderFactory.createLineBorder(new Color(0x00, 0x66, 0xCC), 3));

//URL url = AtBestForm.class.getResource("tvbg.JPG");

//ImageIcon icon = new ImageIcon(url);

//frame.setContentPane(Share.wrapInBackgroundImage(mainPane, icon));

frame.setContentPane(mainPane);

frame.setVisible(false);

//frame.pack();

frame.setSize(new Dimension(i, 500));

//frame.setDoubleBuffered(true);

//frame.setResizable(false);

frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

frame.setLocation(0,0);

frame.setUndecorated(true);

frame.addMouseListener(new MouseListener()

{

public void mousePressed(MouseEvent e)

{

sp = e.getPoint();

compStartHeight = frame.getSize().height;

compStartWidth = frame.getSize().width;

frameLoc = frame.getLocation();

}

public void mouseEntered(MouseEvent e)

{

}

public void mouseExited(MouseEvent e)

{

if (sp == null)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

}

}

public void mouseClicked(MouseEvent e)

{

}

public void mouseReleased(MouseEvent e)

{

sp = null;

}

});

frame.addMouseMotionListener(new MouseMotionListener()

{

public void mouseMoved(MouseEvent e)

{

Point p = e.getPoint();

if (p.y > e.getComponent().getSize().height - 5)

{

if (p.x < 5)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR));

}

else if (p.x > e.getComponent().getSize().width - 5)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));

}

else

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));

}

//

}

else if (p.y < 5)

{

if (p.x < 5)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR));

}

else if (p.x > e.getComponent().getSize().width - 5)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR));

}

else

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR));

}

}

else

{

if (p.x < 5)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));

}

else if (p.x > e.getComponent().getSize().width - 5)

{

frame.setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));

}

}

}

public void mouseDragged(MouseEvent e)

{

Point p = e.getPoint();

int compWidth = frame.getSize().width;

int compHeight = frame.getSize().height;

if (frame.getCursor().getType() == Cursor.S_RESIZE_CURSOR)

{

int nextHeight = compStartHeight+p.y-sp.y;

if (nextHeight > MINIMIZED_HEIGHT)

{

frame.setSize(compWidth,nextHeight);

frame.validate();

}

}

else if (frame.getCursor().getType() == Cursor.N_RESIZE_CURSOR)

{

int nextHeight = compStartHeight+sp.y-p.y;

if (nextHeight > MINIMIZED_HEIGHT)

{

frame.setLocation(frameLoc.x, frameLoc.y-(sp.y-p.y));

frame.setSize(compWidth,nextHeight);

frame.validate();

//frame.repaint();

}

}

else if (frame.getCursor().getType() == Cursor.E_RESIZE_CURSOR)

{

int nextWidth = compStartWidth+p.x-sp.x;

if (nextWidth > MINIMIZED_HEIGHT)

{

frame.setSize(nextWidth,compHeight);

frame.validate();

//frame.repaint();

}

}

else if (frame.getCursor().getType() == Cursor.W_RESIZE_CURSOR)

{

int nextWidth = compStartWidth+(sp.x-p.x);

if (nextWidth > MINIMIZED_HEIGHT)

{

frame.setLocation(frameLoc.x-(sp.x-p.x), frameLoc.y);

frame.setSize(nextWidth,compHeight);

frame.validate();

//frame.repaint();

}

}

else if (frame.getCursor().getType() == Cursor.SE_RESIZE_CURSOR)

{

int nextWidth = compStartWidth+(p.x-sp.x);

int nextHeight = compStartHeight+(p.y-sp.y);

if (nextWidth > MINIMIZED_HEIGHT)

{

frame.setSize(nextWidth,nextHeight);

frame.validate();

//frame.repaint();

}

}

else if (frame.getCursor().getType() == Cursor.SW_RESIZE_CURSOR)

{

int nextWidth = compStartWidth+(sp.x-p.x);

int nextHeight = compStartHeight+(p.y-sp.y);

if (nextWidth > MINIMIZED_HEIGHT)

{

frame.setLocation(frameLoc.x-(sp.x-p.x), frameLoc.y);

frame.setSize(nextWidth,nextHeight);

frame.validate();

//frame.repaint();

}

}

else if (frame.getCursor().getType() == Cursor.NW_RESIZE_CURSOR)

{

int nextWidth = compStartWidth+(sp.x-p.x);

int nextHeight = compStartHeight+(sp.y-p.y);

if (nextWidth > MINIMIZED_HEIGHT)

{

frame.setLocation(frameLoc.x-(sp.x-p.x), frameLoc.y-(sp.y-p.y));

frame.setSize(nextWidth,nextHeight);

frame.validate();

//frame.repaint();

}

}

else if (frame.getCursor().getType() == Cursor.NE_RESIZE_CURSOR)

{

int nextWidth = compStartWidth+p.x-sp.x;

int nextHeight = compStartHeight+(sp.y-p.y);

if (nextWidth > MINIMIZED_HEIGHT)

{

frame.setLocation(frameLoc.x, frameLoc.y-(sp.y-p.y));

frame.setSize(nextWidth,nextHeight);

frame.validate();

//frame.repaint();

}

}

else

{

int x = frame.getX()+p.x-sp.x;

int y = frame.getY()+p.y-sp.y;

setLocation(x,y);

}

}

});

}

private void setupTitleBar()

{

titleBar.setLayout(new BorderLayout());

//titleBar.setToolTipText("Double click here to minimize the window");

titleBar.setOpaque(true);

titleBar.setBackground(Color.BLUE);

titleBar.setBorder(BorderFactory.createLineBorder(new Color(0x00, 0x66, 0xCC), 2));

title.setForeground(Color.WHITE);

title.setOpaque(false);

titleBar.add(title, BorderLayout.WEST);

FlowLayout flow = new FlowLayout(FlowLayout.LEFT);

flow.setVgap(0);

flow.setHgap(0);

JPanel conPane = new JPanel(flow);

conPane.setOpaque(false);

// Setup minimize label

JLabel lab = new JLabel(" _ ");

lab.setForeground(Color.WHITE);

lab.setOpaque(false);

lab.addMouseListener(new MouseListener()

{

public void mousePressed(MouseEvent e)

{

}

public void mouseReleased(MouseEvent e)

{

//frame.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

}

public void mouseEntered(MouseEvent e)

{

//frame.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

}

public void mouseExited(MouseEvent e)

{

//frame.setCursor(Cursor.getDefaultCursor());

}

public void mouseClicked(MouseEvent e)

{

if (minimized == false)

{

size = frame.getSize();

//titleBar.setToolTipText("Double click here to restore the window");

frame.setSize(((int)size.getWidth()), MINIMIZED_HEIGHT);

minimized = true;

}

}

});

conPane.add(lab);

// Setup restore label

lab = new JLabel(" " + "\u25FB" + " ", JLabel.RIGHT);

lab.setOpaque(false);

lab.setForeground(Color.WHITE);

lab.addMouseListener(new MouseListener()

{

public void mousePressed(MouseEvent e)

{

}

public void mouseReleased(MouseEvent e)

{

//frame.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

}

public void mouseEntered(MouseEvent e)

{

//frame.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

}

public void mouseExited(MouseEvent e)

{

//frame.setCursor(Cursor.getDefaultCursor());

}

public void mouseClicked(MouseEvent e)

{

if (minimized == true)

{

frame.setSize(size);

//titleBar.setToolTipText("Double click here to minimize the window");

minimized = false;

}

}

});

conPane.add(lab);

// Setup close label

lab = new JLabel(" x ", JLabel.RIGHT);

lab.setForeground(Color.WHITE);

lab.setOpaque(false);

lab.addMouseListener(new MouseListener()

{

public void mousePressed(MouseEvent e)

{

}

public void mouseReleased(MouseEvent e)

{

//frame.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

}

public void mouseEntered(MouseEvent e)

{

//frame.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

}

public void mouseExited(MouseEvent e)

{

//frame.setCursor(Cursor.getDefaultCursor());

}

public void mouseClicked(MouseEvent e)

{

//frame.setVisible(false);

System.exit(0);

}

});

conPane.add(lab);

titleBar.add(conPane, BorderLayout.EAST);

titleBar.addMouseMotionListener(new MouseMotionListener()

{

public void mouseDragged(MouseEvent e)

{

//int x = ((int)frame.getLocation().getX());

//int y = ((int)frame.getLocation().getY());

//frame.setLocation(e.getX() + (x-e.getX()), e.getY() + (y-e.getY()));

Point p = frame.getLocationOnScreen();

frame.setLocation(p.x + e.getX() - loc.x,p.y + e.getY() - loc.y);

}

public void mouseMoved(MouseEvent e)

{

}

});

titleBar.addMouseListener(new MouseListener()

{

public void mousePressed(MouseEvent e)

{

loc.x = e.getPoint().x;

loc.y = e.getPoint().y;

}

public void mouseReleased(MouseEvent e)

{

//frame.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

}

public void mouseEntered(MouseEvent e)

{

//frame.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

}

public void mouseExited(MouseEvent e)

{

//frame.setCursor(Cursor.getDefaultCursor());

}

public void mouseClicked(MouseEvent e)

{

}

});

}

public void setFrameTitle(String s)

{

title.setText(" " + s);

}

public void setVisible(boolean b)

{

frame.setVisible(b);

}

private class TableView

{

MyTableModel model;

private TableView()

{

try

{

model = new MyTableModel();

}

catch (Exception exc)

{

//Share.d("TableView E: " + exc.toString());

}

}

class MyTableModel extends AbstractTableModel

{

public int getColumnCount()

{

return colName.length;

}

public int getRowCount()

{

if (t == null)

{

return 0;

}

else

{

return t.size();

}

}

public String getColumnName(int col)

{

return colName[col];

}

public Object getValueAt(int row, int col)

{

String[] data = t.get(row).toString().split(",");

return data[col];

}

public boolean isCellEditable(int row, int col)

{

return false;

}

public void setValueAt(Object value, int row, int col)

{

String[] data = t.get(row).toString().split(",");

data[col] = value.toString();

String s = "";

for (int i = 0; i < data.length; i++)

{

s = s + data;

if (i != data.length - 1)

{

s = s + ",";

}

}

t.set(row, s);

fireTableCellUpdated(row, col);

}

public void setData(Vector newData)

{

t = newData;

fireTableDataChanged();

}

}

}

private class CustomRenderer extends JLabel implements TableCellRenderer

{

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex)

{

try

{

// 08/06/2007 18:54:44,62000,4,,

setOpaque(true);

setForeground(Color.WHITE);

if (vColIndex == PRICE_C)

{

setText(" " + value.toString());

setHorizontalAlignment(JLabel.LEFT);

if (rowIndex == 0)

{

//setForeground(new Color(0x00, 0x80, 0x00)); //VERY DARK GREEN

//setForeground(Color.green);

setBackground(new Color(0x00, 0x80, 0x00)); //VERY DARK GREEN

rowColor = new Color(0x00, 0x80, 0x00);

}

else

{

Double d = getPrice(rowIndex - 1) - getPrice(rowIndex);

if (d < 0.0)

{

//setForeground(new Color(0x00, 0x80, 0x00)); //VERY DARK GREEN

//setForeground(Color.green);

setBackground(new Color(0x00, 0x80, 0x00)); //VERY DARK GREEN

rowColor = new Color(0x00, 0x80, 0x00);

}

else if (d > 0.0)

{

//setForeground(new Color(0xcc, 0xcc, 0x00));

setBackground(Color.red); //VERY DARK GREEN

rowColor = Color.red;

}

else if (d == 0.0)

{

setForeground(Color.BLACK);

setBackground(null);

rowColor = Color.WHITE;

//setForeground(Color.WHITE);

}

}

}

else if (vColIndex == TIME_C)

{

Date d;

if (value.toString().split(" ").length == 3)

{

d = sdf.parse(value.toString());

}

else

{

d = sdf1.parse(value.toString());

}

setText(format.format(d));

setHorizontalAlignment(JLabel.RIGHT);

setBackground(rowColor);

if (rowColor == Color.WHITE)

{

setForeground(Color.BLACK);

}

else

{

setForeground(Color.WHITE);

}

}

else if (vColIndex == VOL_C)

{

setText(value.toString() + " ");

setHorizontalAlignment(JLabel.RIGHT);

setBackground(rowColor);

if (rowColor == Color.WHITE)

{

setForeground(Color.BLACK);

}

else

{

setForeground(Color.WHITE);

}

}

else

{

// For future buyer and seller info

}

}

catch (Exception exc)

{

//Share.d("CustomRenderer E: " + exc.toString());

}

return this;

}

}

public void addRow(String s)

{

if (t.size() == MAX_LINE)

{

t.remove(MAX_LINE - 1);

}

t.add(0, s);

view.model.setData(t);

}

public double getPrice(int i)

{

return(Double.parseDouble((t.get(i).toString().split(","))[0]));

}

public Point getLocation()

{

return frame.getLocation();

}

public void setLocation(int x, int y)

{

frame.setLocation(x, y);

}

public void setOnTop(boolean b)

{

frame.setAlwaysOnTop(b);

}

public void removeAll()

{

t.clear();

view.model.setData(t);

}

/*

public void actionPerformed(ActionEvent e)

{

String item = e.getActionCommand();

if (item.equals("Minimized"))

{

if (minimized == false)

{

loc = frame.getLocation();

size = frame.getSize();

if (Share.MINIMIZED_WIDTH + size.getWidth() > Share.SCREEN_WIDTH)

{

Share.MINIMIZED_ROW++;

Share.MINIMIZED_WIDTH = 0;

//frame.setLocation(Share.MINIMIZED_WIDTH, Share.MINIMIZED_START_POS);

frame.setSize(((int)size.getWidth()), Share.MINIMIZED_HEIGHT);

frame.setLocation(Share.MINIMIZED_WIDTH, Share.MINIMIZED_START_POS-(Share.MINIMIZED_ROW*Share.MINIMIZED_HEIGHT));

Share.MINIMIZED_WIDTH = Share.MINIMIZED_WIDTH + ((int)size.getWidth());

}

else

{

//frame.setLocation(Share.MINIMIZED_WIDTH, Share.MINIMIZED_START_POS);

frame.setSize(((int)size.getWidth()), Share.MINIMIZED_HEIGHT);

frame.setLocation(Share.MINIMIZED_WIDTH, Share.MINIMIZED_START_POS-(Share.MINIMIZED_ROW*Share.MINIMIZED_HEIGHT));

Share.MINIMIZED_WIDTH = Share.MINIMIZED_WIDTH + ((int)size.getWidth());

}

Share.MINIMIZED_NUM++;

minimized = true;

}

}

else if (item.equals("Restore"))

{

if (minimized == true)

{

frame.setLocation(loc);

frame.setSize(size);

frame.setVisible(true);

if (Share.MINIMIZED_WIDTH - size.getWidth() < 0)

{

Share.MINIMIZED_WIDTH = Share.SCREEN_WIDTH;

Share.MINIMIZED_ROW--;

}

else

{

Share.MINIMIZED_WIDTH = Share.MINIMIZED_WIDTH - ((int)size.getWidth());

}

Share.MINIMIZED_NUM--;

minimized = false;

}

}

}

*/

public static void main(String[] args)

{

System.getProperties().put("sun.awt.noerasebackground", "true");

MoveWindow form = new MoveWindow();

form.setFrameTitle("TEST");

form.addRow("2,69000,2007/07/07 05:05:05");

form.setVisible(true);

}

}

Thanks again for your time and help!

BuggyVBa at 2007-7-29 18:53:38 > top of Java-index,Desktop,Core GUI APIs...