When I attempt to rescale a JFrame, which has no listeners, and has two JPanels in it, the layout takes a bit to resize itself. It's not slowness due to long calculations, since there's nothing that would take that long. I've stripped out everything that has to do with the underlying simulation it's supposed to display (and replaced it with plain colors), and it still has that small lag. EDIT: Kinda forgot the main point. How can this be stopped?
Main window:Workspace panel:Code:package graphics; import java.awt.BorderLayout; import java.awt.Dimension; import javax.swing.JFrame; /** * Represents the top-level window for the GUI of the logic toolkit * * @author Henry Swanson * @version 1.0 Apr 3, 2011 */ public class MainWindow extends JFrame { /** Serial ID. What is this? */ private static final long serialVersionUID = -3880026026104218593L; /** * Creates a {@link MainWindow} and the {@link WorkspacePanel} and * {@link ActionPanel} within. */ public MainWindow() { super("Logic Toolkit"); WorkspacePanel w = new WorkspacePanel(); ActionPanel a = new ActionPanel(); add(w, BorderLayout.CENTER); add(a, BorderLayout.LINE_END); setMinimumSize(new Dimension(400, 300)); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); setVisible(true); } }Action panel:Code:package graphics; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JPanel; /** * The panel where all the gates are shown. * * @author Henry Swanson * @version 1.0 Apr 3, 2011 */ public class WorkspacePanel extends JPanel { /** Serial ID. What is this? */ private static final long serialVersionUID = 6634247456369380795L; /** * Creates a {@link WorkspacePanel}. */ public WorkspacePanel() { super(null); setPreferredSize(new Dimension(400, 300)); } @Override public void paintComponent(Graphics g) { super.paintComponents(g); Graphics2D g2d = (Graphics2D) g; g2d.setColor(Color.GREEN); g2d.fillRect(0, 0, 1024, 1024); } }Code:package graphics; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JPanel; /** * The panel where buttons for actions such as adding and removing gates are. * * @author Henry Swanson * @version 1.0 Apr 3, 2011 */ public class ActionPanel extends JPanel { /** Serial ID. what is this? */ private static final long serialVersionUID = 9139567862742794039L; /** * Creates a {@link ActionPanel}. */ public ActionPanel() { super(null); setPreferredSize(new Dimension(100, 300)); } @Override public void paintComponent(Graphics g) { super.paintComponents(g); Graphics2D g2d = (Graphics2D) g; g2d.setColor(Color.CYAN); g2d.fillRect(0, 0, 1024, 1024); } }




Reply With Quote
