paint

JButton not visible until mouseover

為{幸葍}努か 提交于 2019-12-01 20:17:57
问题 I'm creating a gui for my project. When the gui is first loaded only background is visible, so buttons are not visible, but when mouse over them, they are visible. What is the solve this problem? public class Home extends JFrame{ //New JPanel private JPanel home; //Creating image url. You must be change url ImageIcon icon = new ImageIcon("img//home1.jpeg"); //Home Class public Home(){ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 960, 640); setTitle("LoneyTunes Crush");

How to draw Windows Classic style window elements

纵饮孤独 提交于 2019-12-01 18:42:36
We create a few custom 'windows' in our program and when VisualStyles are enabled we are able to find each element of the window and their size and paint them ourselves including the minimize and close buttons using the appropriate Renderers. We'd like to do that same thing when VisualStyles are disabled and currently draw our own windows but they're quite ugly. Is it possible in WinForms C# to draw the Windows Classic style windows? I've found the ClassicBorderDecorator but it's for WPF. Or, failing that, how can we get the pixel sizes of the window decorations which we do in the following

Win32 application windows eventually stop painting on Windows 7

雨燕双飞 提交于 2019-12-01 17:44:50
问题 I have a large, complex application written in C++ (no MFC or .NET). The client that uses the software most aggressively will, within an hour or so of starting it, get to a state where all the windows stop painting. We get reports that the application has "hung" because as far as they can tell nothing is happening. In reality, the application is functioning, just not displaying anything. I've tried a lot of different things to no avail. I'm out of ideas... 回答1: You probably already have a

Java applet does not display anything

喜你入骨 提交于 2019-12-01 17:35:29
问题 Does anyone know why my Java applet does not display anything? This is my first Java applet so I am new to creating one. I researched this problem and haven't found an answer specific to the current problem. import java.applet.Applet; import java.awt.Graphics; import java.awt.Font; import java.awt.Color; public class JavaRocksApplet extends Applet { public void paint( Graphics screen ) { Font f = new Font( "TimesRoman", Font.ITALIC, 36 ); screen.setFont( f ); Color c = new Color( 40, 80, 120

My overriden paint method is not getting called

前提是你 提交于 2019-12-01 14:40:06
I have a JPanel that is meant to act as a HUD for my game, naturally, I have overridden the paint method to do my own custom display, this does get called, but only upon resizing or maximizing, minimizing the frame, and not when my game loop tells it to repaint(). It seems particularly strange to me on account of my two other panels being repainted completely fine. Here is my HUD class: package base; import java.awt.Color; import java.awt.Graphics; import javax.swing.BoxLayout; import javax.swing.JPanel; public class HUD extends JPanel { private Shiphud[] shiphuds; public HUD(Ship[] ships) {

Repainting Continuously in Java

有些话、适合烂在心里 提交于 2019-12-01 13:28:56
I have a Java program that uses threads. In my run method, I have: public void run() { while(thread != null){ repaint(); System.out.println("hi"); try { Thread.sleep(1000); } catch (InterruptedException e) { break; } } } public void paintComponent(Graphics g) { // painting stuff } The problem is that the run method is executed, but the paintComponent section is not called. If this is not the right way to keep repainting the component, then how should I repaint it? Cal repaint from a Swing Timer . That will not block the GUI, and will happen at whatever interval specified in the timer. Of

Using threads to paint panel in java

泪湿孤枕 提交于 2019-12-01 10:41:07
I am writing a program that has a number of different views. One of which is fairly graphics intensive (it displays an interconnected graph). Others just display small but complex diagrams. I'm finding the paint time for the main view is quite long (even just painting the currently visible area) and while it is being painted, the rest of the interface becomes very slow. My question is this, can I create a new thread to handle the painting - and if so, will it result in a performance increase, my suspicion is that it wont. I have tried the following: creating an abstract classs

Repaint without clearing

拟墨画扇 提交于 2019-12-01 09:51:53
问题 I am working on a program that mimics Paint. The problem is when I draw a new shape the previous shape gets deleted. I tried to comment out my super call of paintComponents which works but leaves behind too much drawing. import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import javax.swing.JOptionPane; import javax.swing.JPanel; public class Canvas1

How to achieve multi-layered drawing with OpenGL ES on iOS?

你离开我真会死。 提交于 2019-12-01 08:41:59
问题 I wanted to very quickly to make a simple drawing app for iOS, but I can't quite get the drawing to work - well, to save the content on each layer and restore the layers. It appears like all layers save the same pixels.. The idea was to have three layers and use OpenGL ES to draw on each layer. With no experience in the matter, I just tiled three UIViews and added a OpenGL drawing canvas to each UIView (a modified version of the PaintingView from the tutorial). When the user swapped drawing

Android canvas - Draw a hole

随声附和 提交于 2019-12-01 06:16:40
Is it possible to realize the following picture in Android with canvas? I want to have a hole and not only a Circle over the red layer which is yellow colored. I tried this (and failed) with the following Code in my onDraw() -Method: canvas.drawBitmap(yellow, 0, 0, paint); canvas.drawBitmap(red, 0, 200, paint); Paint p = new Paint(); p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); canvas.drawCircle(300, 300, radius, p); But when I use this code, it makes a hole through both bitmap's. At the end, this App should be a Maze with a ball, holes and other stuff. When the ball would