awt

Collision detection tutorials [closed]

戏子无情 提交于 2019-12-06 11:45:25
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. ins0m A strong tutorial on 2d collision detection can be found at metanetsoftware (makes of N) The authors write about the theoretical fundamentals and the challenges. They give you some

how to get mouse position of a Java application?

狂风中的少年 提交于 2019-12-06 11:37:37
问题 documentDOM.addEventListener("click", new EventListener() { public void handleEvent(Event evt) { if (evt.getType().equals("click")) { System.out.println("hello"); MouseEvent mouseIvent = (MouseEvent) evt; int screenX = mouseIvent.getXOnScreen(); int screenY = mouseIvent.getYOnScreen(); System.out.println("screen(X,Y) = " + screenX + "\t" + screenY); } } }, true); I need to locate a specific pixel location on my Java application. This Java application can be windowed or maximized window. My

KeyListener - do I need to call the keyPressed Method in my main?

两盒软妹~` 提交于 2019-12-06 10:52:22
Here is what's inside my keyPressed : public class Movie extends JFrame implements KeyListener { public static Sprite star1 = new Sprite("Assets/star1.png"); public static Sprite star2 = new Sprite("Assets/star2.png"); public static Sprite star3 = new Sprite("Assets/star3.png"); public void init(){ this.addKeyListener(this); } @Override public void keyReleased(KeyEvent e) { // TODO Auto-generated method stub } @Override public void keyTyped(KeyEvent e) { // TODO Auto-generated method stub } public void keyPressed(KeyEvent e) { System.out.println("KEY PRESSED: " + e.getKeyChar()); animation

How to make a JTable column to contain not JTextFields, but JTextAreas?

被刻印的时光 ゝ 提交于 2019-12-06 09:49:13
问题 Please tell me, how to make a JTable column to contain JTextAreas, so the cell's height will increase when user types a lot of text and we can see more than one line (cell gets expanded; as result, row will expand too) 回答1: You need to write your own cell renderer and editor based on JTextArea: public class Start { public static class JTextPaneCellEditor extends AbstractCellEditor implements TableCellEditor, KeyListener { private JViewport viewport; private JTable table; private int row;

Two Different Panels in One Frame - Java

拜拜、爱过 提交于 2019-12-06 09:43:20
问题 I have a question. I have one main frame, and to the left i have a sidebar with menus. My question is, is it possible to make another panel within the main frame, so that if menu1 is clicked, the related contents should be displayed to the second half of the main frame, and when other menus are pressed then obviously the relevant stuff according to what is selected. its a bit hard to explain, sorry. Has anyone got an idea, whether that is possible in Java with Eclipse? 回答1: yes this's pretty

converting AWT image to SVG Image

做~自己de王妃 提交于 2019-12-06 09:14:39
问题 I am ingesting an AWT image (from PDF, through PDFBox) with the following code: private java.awt.Graphics2D graphics; public void drawImage(java.awt.Image awtImage, java.awt.geom.AffineTransform at) { graphics.setComposite(getGraphicsState().getStrokeJavaComposite()); graphics.setClip(getGraphicsState().getCurrentClippingPath()); graphics.drawImage( awtImage, at, null ); } and wish to capture/output the image as SVG. I have been using the Batik library which produces svg of the form <image x=

Java window not setting background color?

丶灬走出姿态 提交于 2019-12-06 08:40:01
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(JFrame.EXIT_ON_CLOSE); f.setTitle("Window"); f.setBackground(Color.RED); } } mKorbel 1) JFrame can't do

How to handle the height of the tab title in JTabbedPane

时光毁灭记忆、已成空白 提交于 2019-12-06 07:33:39
问题 I am preparing a window with some horizontal tabs using JTabbedPane, Tabs And window are prepared properly. Now I need to setup these tabs in level basis, based on my requirement (My logic returns integer value based on that I need to setup levels ). Levels look like : Can you please advise? 回答1: Just the sight of screenshot: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TabHeightTest { public JComponent makeUI() { JTabbedPane tabbedPane = new JTabbedPane(

Automatically find frame sizes from png sprite sheet [duplicate]

喜你入骨 提交于 2019-12-06 06:26:26
This question already has an answer here : Closed 6 years ago . Possible Duplicate: PySide: Separating a spritesheet / Separating an image into contiguous regions of color Given a .png image with transparent pixels and a grid of individual animation frames (where the last row need not be full), how would you automatically find the dimensions of each individual frame, and detect how many frames are in the .png? I am trying to convert the resources from the creative-commons treasure-trove of Glitch into our internal format, and I am having problems isolating frame information from the raw .pngs.

Copy Image to Clipboard not working on Linux (Java AWT & SWT)

巧了我就是萌 提交于 2019-12-06 06:06:31
I am developing an Eclipse RCP Application which includes JFreeChart. One of its features is to copy graphs to the clipboard in order to paste them into other applications but it does not work on Linux, There is a SWT sample where you can find a snippet that does not work in Linux. On the other hand JFreeChart implemented this on AWT as: Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Insets insets = getInsets(); int w = getWidth() - insets.left - insets.right; int h = getHeight() - insets.top - insets.bottom; ChartTransferable selection = new ChartTransferable