awt

How to make java.awt.Label background transparent?

删除回忆录丶 提交于 2019-12-10 11:25:03
问题 I used to do the transparent background with javax.swing.JLabel this way: lbl.setBackground(new Color(0, 0, 0, 0)); . But it doesn't work with java.awt.Label. Is there any simple way to make the label transparent? Update: public class SplashBackground extends Panel { private static final long serialVersionUID = 1L; private Image image = null; /** * This is the default constructor */ public SplashBackground() { super(); initialize(); } /** * This method initializes this * */ private void

Can I use multiple ActionListeners in a single class?

…衆ロ難τιáo~ 提交于 2019-12-10 11:21:34
问题 Consider the overly simplified example below; some of it written with pseudocode for brevity. When I try running this as is, I get a compiler error stating the actionPerformed is already found in my main method. However, if I rename it, say to actionPerformed2 it's no longer recognized by ActionListener . Do I need to combine the listeners for both the foo and foo2 methods into a single ActionListener method?? How do I properly differentiate listeners from each other when using multiple

Java window not setting background color?

杀马特。学长 韩版系。学妹 提交于 2019-12-10 10:58:44
问题 This is probably a really stupid error but iv'e just started learning the .awt package. I followed a tutorial to the letter, in the video his window's background is red, there are no errors in my code yet it won't change the background color. Thanks for any help! import java.awt.Color; import javax.swing.*; public class Test { public static void main(String[] args) { // TODO Auto-generated method stub JFrame f = new JFrame(); f.setVisible(true); f.setSize(350,350); f.setDefaultCloseOperation

Collision detection tutorials [closed]

馋奶兔 提交于 2019-12-10 10:35:10
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I'm supposed to develop a Java game using AWT. I'm stuck with the concept of "collision detection". If you can help me with any tutorials that explain the concept (how it works) or give examples (source code), I'd be grateful. 回答1: A strong tutorial on 2d collision detection can be found at metanetsoftware

Program to create shapes and show them on console

别来无恙 提交于 2019-12-10 09:52:34
问题 I was given small assignment as below . Can you please throw some light on how to implement this Write a simple structured program and simple oo program that implements display shape function. Your program should simply print out (to console ) the number if shapes and then ask each shape to display itself which will also cause a line of output to be generated to the console , one for each shape . It is perfectly OK for your main program to create a collection of shapes before on to sorting

Rounded borders on a JPanel

淺唱寂寞╮ 提交于 2019-12-10 09:47:35
问题 What I've got here is a JPanel with a rounded border that is set up as such: panel.setBorder(new LineBorder(PanelColor, 5, true)); The problem is, in each of the corners there are 2 diagonal opaque lines going from the outer corner to the inner corner that is the length of the border. Whatever is behind the border shows through. Is there any way to get rid of these lines and make the entire border one solid color? Thanks! I'd attach a picture but I don't have enough rep to do so :P 回答1: Maybe

How to configure Google AppEngine to work with vector graphic?

时光毁灭记忆、已成空白 提交于 2019-12-10 09:36:40
问题 In AppEngine standard environment with Java8 during attempt to use SVG next error appears. I get this error when I try to draw SVG on a XSLFSlide with POI like slide.draw(graphics2D) or to convert SVG to PNG with Batik. The problem seems to appear because fontconfig cannot find fonts. In debian distribution it solves by installing libfontconfig1 . How to solve it on AppEngine? java.lang.NullPointerException at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264) at sun.awt

How to properly use the MouseMotionListener to press JButtons?

ぃ、小莉子 提交于 2019-12-10 09:23:33
问题 I have made a small Conway Game of Life program. I'm about 80% done. I have used a grid of JButtons as the cells. Right now I have a ButtonListener on every button so you have to one-by-one draw the pattern you want by clicking on individual buttons. I want to be able to click and drag the mouse and select buttons quickly. I used the MotionListener class, implementing the MouseMotionListener and coded the mouseDragged method in an identical fashion as my actionPerformed method in my

Converting an AWT application to SWT/JFace

末鹿安然 提交于 2019-12-10 08:46:29
问题 I am currently toying with the idea of converting a small/medium sized project from AWT to SWT, although Swing is not totally out of the picture yet. I was thinking about converting the main window to an SWT_AWT bridge object, but I have no idea how the semantics for this work. After that, I plan to update dialog for dialog, but not necessarily within one release. Is this possible? Has someone done a conversion like this and can give me some hints? Is there maybe even a tutorial somewhere out

Malformed Farsi characters on AWT

浪子不回头ぞ 提交于 2019-12-10 08:17:52
问题 When I started programming with the JDK6, I had no problem with text components , neither in AWT nor in Swing. But for labels or titles of AWT components I do have a problem. I can't display Farsi characters on AWTs components (in Swing I type them into the source code). Here's my sample code: import javax.swing.*; import java.awt.*; import java.io.*; import java.util.Properties; public class EmptyFarsiCharsOnAWT extends JFrame{ public EmptyFarsiCharsOnAWT() { super("مثال");