repaint

Repaint is not functioning properly as required

匆匆过客 提交于 2019-12-02 05:15:13
I have built a tetris game. Now in that I have used a JPanel for displaying content and the blocks (using the paintComponents() method). The problem is whenever I try to call the tetris program from another JFrame it does not paint at all. The code for my tetris main menu is: import javax.swing.*; import sun.audio.AudioPlayer; import sun.audio.AudioStream; import java.awt.*; import java.awt.event.*; import java.io.FileInputStream; import java.io.InputStream; @SuppressWarnings("serial") public class Tetris_MainMenu extends JFrame implements ActionListener { @SuppressWarnings("unused") public

How to make repaint for JDialog in Swing?

∥☆過路亽.° 提交于 2019-12-02 03:56:28
How to make repaint for JDialog in Swing? If I click on convert button in JDialog I need to change GUI design of JDialog but it's not happening? Is their any solution? _convertAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { String para = new String(); _task.setBookTypeId(13); initComponents(); // validate(); // repaint(); setVisible(true); } }; I'm setting booking type id is 13 . if(_task.getBookTypeId()== 1){ String colnames[] = {"Leg","Departure", "Date","Time", "Arrival","Date", "Time","How","Aircraft","PIC","Copilot"}; MyTableModel mytablemodel = new

Keeping draw graphics - removing super.paintComponent

妖精的绣舞 提交于 2019-12-02 03:10:35
问题 I have a class named Foo that extends a class named Bar that extends JPanel and implements ActionListener. When I select Circle and click the draw button, I draw a circle, and when I press rectangle and click draw, it erases the previous shape and draws a rectangle. However, I want to keep all the shapes on the JPanel until I choose to click the erase button. So I removed the super.paintComponent(g) and it works, but it also causes buttons of class Bar to reappear in a glitchy manner. How can

no repaint while resizing when using .setPaint(gradient)

可紊 提交于 2019-12-02 03:08:35
As soon a I use gradients in my code, the repaint isn't done while resizing I get something like that while resizing (black rectangles where it has been resized, see image in the link below). And when i stop resizing, everything is drawn again, but only then. if I don't use g2d.setPaint(gradient); I have a quick redraw http://gui-builder.com/C41142775162.rar public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D)g; //sample of the code GradientPaint gradient = new GradientPaint(startX, startY, greyColor1, endX, endY, new Color(120,120,120)); g2d.setPaint

Can I be notified when a Item has finished repainting?

梦想与她 提交于 2019-12-02 02:10:47
问题 I'm making a snapshot (via a ShaderEffectSource with live: false ) of an Item, but I'm sometimes (1 cases in 200) getting a blank snapshot. I'm making the snapshot based on a signal like this: Image { onStatusChanged: { if (status == Image.Ready) { snapshotter.makeSnapshot(); } } } This is just as an overall context. I won't post a testcase for now because it's a big app and I haven't yet isolated a testcase. That might be material for a future question. So I'm not asking "where's the bug in

How to add time delay between adding components to JFrame?

大兔子大兔子 提交于 2019-12-02 01:59:10
I created a JFrame, and it contains a JPanel. I created a number of JLabels. I can add the JLabels to the JPanel, and display them correctly. But I want to implement them so as they displayed sequentially ; a time delay between each JLabel to be displayed. After searching the StackOverfLow, I tried some code, but it has no effect!. So How to use a timer to make components(Labels) displayed one after the other by setting a time delay. I Don't want a fix for my code particularly in the answer. Just show how to display any type of components in a delayed manner, each component displayed after a

Can I be notified when a Item has finished repainting?

微笑、不失礼 提交于 2019-12-02 00:22:20
I'm making a snapshot (via a ShaderEffectSource with live: false ) of an Item, but I'm sometimes (1 cases in 200) getting a blank snapshot. I'm making the snapshot based on a signal like this: Image { onStatusChanged: { if (status == Image.Ready) { snapshotter.makeSnapshot(); } } } This is just as an overall context. I won't post a testcase for now because it's a big app and I haven't yet isolated a testcase. That might be material for a future question. So I'm not asking "where's the bug in my code" yet. Instead I have a simple question that I think may help me fix the bug: Can I be notified

Java - repaint(x, y, w, h) doesn't call paintComponent? (with SSCCE)

独自空忆成欢 提交于 2019-12-02 00:09:30
问题 I asked this before, but only theoretically, without an SSCCE. Now, I've created one, and the problem persists. I'd like to know why paintComponent is not called on repaint(x, y, w, h) , but is called on repaint() . Two classes: SANDBOX import java.awt.Dimension; import java.awt.FlowLayout; import javax.swing.JFrame; public class Sandbox { public static void main(String[] args) { JFrame f = new JFrame(); f.setMinimumSize(new Dimension(800, 600)); f.setLocationRelativeTo(null); f

JPanel doesn't repaint if repaint() is called within JFrame code

瘦欲@ 提交于 2019-12-01 21:33:54
问题 I have a class Forest and CellularJPanel , which extends JPanel and displays Forest . I wrote a primitive code to create JFrame , Forest , CellularJPanel and add CellularJPanel to the JFrame . Next is an infinite loop, which makes Forest update and CellularJPanel repaint. JFrame jFrame = new JFrame(); Forest forest = new Forest(); CellularJPanel forestJPanel = new CellularJPanel(forest); jFrame.add(forestJPanel); jFrame.pack(); //jFrame.setResizable(false); jFrame.setLocationRelativeTo(null);

Java - repaint(x, y, w, h) doesn't call paintComponent? (with SSCCE)

二次信任 提交于 2019-12-01 20:35:27
I asked this before, but only theoretically, without an SSCCE. Now, I've created one, and the problem persists. I'd like to know why paintComponent is not called on repaint(x, y, w, h) , but is called on repaint() . Two classes: SANDBOX import java.awt.Dimension; import java.awt.FlowLayout; import javax.swing.JFrame; public class Sandbox { public static void main(String[] args) { JFrame f = new JFrame(); f.setMinimumSize(new Dimension(800, 600)); f.setLocationRelativeTo(null); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLayout(new FlowLayout()); // Add label f.getContentPane().add