awt

Moving Shapes along an arc path with java graphics

核能气质少年 提交于 2020-01-03 23:06:55
问题 Pardon my naivety, its my first time here and first time dealing with animation of graphics in java. I'm trying to accomplish an animation of star shapes that moves along a sort of arc(trying to simulate an orbit on a 2d wise). The orbit Action is used with a Timer to animate the stars. Simply put, I have drawn several stars at various positions in a jpanel. The translation of the stars y position depends on how far that star is away from the the x axis of decline which is initialized to 300

Two JPanels in JFrame , One under other

依然范特西╮ 提交于 2020-01-03 18:59:53
问题 I've got two panels in my frame, and I would like to set them one under other, and this first should have size like 9/10*screen frame, and this second 1/10. I've tried with GridLayout (2 rows and one column) but I can't set them specific size. How should I do that? ok maybe I will write some my code: I am writing game - pacman, and in the first panel there is a whole game, and in this second I would like to display player info(like score, name etc.) This first I would like to set on 80%

Using java.awt.image.BufferedImage for creating BIFF8 BITMAP record takes much time - Is there any better approach?

≡放荡痞女 提交于 2020-01-03 17:12:38
问题 So I am creating a HSSFSheet having a background bitmap set using apache poi and own low level code. The https://www.openoffice.org/sc/excelfileformat.pdf declares for the Record BITMAP, BIFF8 : Pixel data (array of height lines of the bitmap, from bottom line to top line, see below) ... In each line all pixels are written from left to right. Each pixel is stored as 3-byte array: the red, green, and blue component of the colour of the pixel, in this order. The size of each line is aligned to

Java/Swing: Desktop.open() causes GTK-ERROR

我是研究僧i 提交于 2020-01-03 16:47:03
问题 I am currently developing a Swing Desktop application. This application is also using a tray icon which is handled by SystemTray of dorkbox. Now I need to open a file with the default application. To achieve this I am using the Desktop.open() method of AWT like this. if (Desktop.isDesktopSupported()) { System.out.println("Get desktop."); Desktop desktop = Desktop.getDesktop(); System.out.println("Got desktop."); desktop.open(file); } But now here comes the problem: On some devices (which

How to do Font Smoothing for AWT/Swing Application?

故事扮演 提交于 2020-01-03 10:31:59
问题 I need to do font smoothing for a AWT application on Windows System. On doing googling I came to know that I can set following VM argument in Eclipse. -Dawt.useSystemAAFontSettings=gasp But this is not yielding any positive results. If anyone is having a better idea on how to achieve Font Smoothing, then kindly let me know. EDIT After Answer By Andrew I added the following snippet of code in paint method public class BottomSubmitButtons extends Canvas { @Override public void paint(Graphics g)

How to do Font Smoothing for AWT/Swing Application?

雨燕双飞 提交于 2020-01-03 10:31:51
问题 I need to do font smoothing for a AWT application on Windows System. On doing googling I came to know that I can set following VM argument in Eclipse. -Dawt.useSystemAAFontSettings=gasp But this is not yielding any positive results. If anyone is having a better idea on how to achieve Font Smoothing, then kindly let me know. EDIT After Answer By Andrew I added the following snippet of code in paint method public class BottomSubmitButtons extends Canvas { @Override public void paint(Graphics g)

How to create a Graphics2D instance?

徘徊边缘 提交于 2020-01-03 08:57:33
问题 What's the easiest way in Java SE 7 to obtain an instance just to plot a few points for debugging? Desktop environment. 回答1: You could use a BufferedImage : BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics2D = image.createGraphics(); 回答2: The easiest and safest way is to use to cast the Graphics reference in paintComponent and cast it as needed. That way the Object is correctly initialized. This reference can be passed to other custom

Multiple calls of paintComponent()

会有一股神秘感。 提交于 2020-01-03 05:51:04
问题 I have these two classes: public class Pencil extends JComponent implements MouseListener, MouseMotionListener{ Plansa plansa; Graphics g; public Pencil(Plansa newCanvas){ this.plansa = newCanvas; this.plansa.setFlagShape(false); } @Override public void mouseDragged(MouseEvent arg0) { plansa.setMouseDragged(arg0); this.plansa.setFlagShape(false); plansa.paintComponent(plansa.getGraphics()); } @Override public void mouseClicked(MouseEvent e) { } @Override public void mousePressed(MouseEvent

RoundRectangle2D clip is not very smooth

坚强是说给别人听的谎言 提交于 2020-01-03 05:14:31
问题 I have a JPanel that i want to clip the corners so that it has rounded edge. Here is what i am doing. ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(color); Shape s = new RoundRectangle2D.Double(0, 0, width, height, arc, arc); g.setClip(s); So notice that i am setting the clipping to a RoundRectangle2D. Also i am setting anti-aliasing still my rounded edges are really jagged. Soft clipping example this link has a way to do soft

How to print out specific rows/columns of a JTable?

徘徊边缘 提交于 2020-01-03 04:23:29
问题 I am able to print a full JTable, but actually I would like more to print just a specific part of a JTable, for example from Row 10 to Row 50 and Column 70 to Column 150. How to do it ? 回答1: Get cell bounds for the selected fragment and calculate desired region ( Rectangle ), define clip region to paint only desired region, in the printable use Graphics's translate() method to shift the rendering. 回答2: I've faced this problem too. Solved by hiding columns before printing and restoring columns