swing

MouseDragged & MouseMoved not working in Java Applet

谁说胖子不能爱 提交于 2021-02-16 16:25:30
问题 I'm currently working on a map generation program for a game I'm creating, and so I'm trying to be able to modify the individual tiles on the map using my mouse. I've successfully implemented the ability to click on a tile and change its value (from say a 4 way tile to a 2 way tile), but I am having trouble getting mouseDragged to work. According to the Java docs I've done the correct implementation of the mouseDragged interface into my MouseEventHandler, but I when I drag my mouse and move

Generating multiple shapes in Java…?

你说的曾经没有我的故事 提交于 2021-02-16 15:16:05
问题 How do I generate multiple type of shape like stars, triangles, etc..I've run the code and it compiles and runs with only showing one star. (I want around 10) what function do I use to generate multiple shapes in a Graphical User Interface..? import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.GeneralPath; import java.util.Random; import javax.swing.JFrame; import javax.swing.JPanel; public class Shapes2JPanel extends JPanel { // draw general

How to draw snakes in Swing?

时光怂恿深爱的人放手 提交于 2021-02-16 14:30:10
问题 I'm rather new to Java Swing, and working on a ladders and snaked project for my college course. The instructor has told us to implement a game in which the player can choose exactly how many snakes are on the game board, and where the snakes are. So is for the ladders! So I cannot use one, or several fixed images in my game, so that the player cannot change them anymore. I need a way to draw such snakes and ladders in my game. The question is what is the best option to do this in Java? By

JScrollPane and JPanel

拈花ヽ惹草 提交于 2021-02-16 13:44:45
问题 So, I'm making a kind of text editor, and I need a JScrollPane for vertical navigation. But I can't get it to work. I have read every freaking tutorial on first ten pages of google results, and I can't get it to work. Lets say I have JFrame (size 1000x800). I want to put a JPanel (1000x2000) in it so that it horizontally alignes with the JFrame. I want to stick a simple scroll bar to the right side of the JPanel so I can get to the rest of it. I have reduced sizes, I have added JPanel to

Browser using JEditorPane forcing blue background

老子叫甜甜 提交于 2021-02-16 10:05:23
问题 This is the code I'm using to display google in a JEditorPane String url="http://google.com"; editorPane.setEditable(false); try { editorPane.setPage(url); } catch (IOException e) {} But for some reason the background will always be a blue colour, doesn't matter if I call setBackgroundColor(Color.WHITE); 回答1: As @AndrewThompson noted in the comments JEditorPane is really behind, it supports only a subset of HTML 3.2 and CSS1, and isn't really cable of rendering any modern web pages. I

Browser using JEditorPane forcing blue background

一曲冷凌霜 提交于 2021-02-16 10:02:10
问题 This is the code I'm using to display google in a JEditorPane String url="http://google.com"; editorPane.setEditable(false); try { editorPane.setPage(url); } catch (IOException e) {} But for some reason the background will always be a blue colour, doesn't matter if I call setBackgroundColor(Color.WHITE); 回答1: As @AndrewThompson noted in the comments JEditorPane is really behind, it supports only a subset of HTML 3.2 and CSS1, and isn't really cable of rendering any modern web pages. I

Browser using JEditorPane forcing blue background

折月煮酒 提交于 2021-02-16 10:02:08
问题 This is the code I'm using to display google in a JEditorPane String url="http://google.com"; editorPane.setEditable(false); try { editorPane.setPage(url); } catch (IOException e) {} But for some reason the background will always be a blue colour, doesn't matter if I call setBackgroundColor(Color.WHITE); 回答1: As @AndrewThompson noted in the comments JEditorPane is really behind, it supports only a subset of HTML 3.2 and CSS1, and isn't really cable of rendering any modern web pages. I

Incude command prompt in Java panel

≡放荡痞女 提交于 2021-02-16 05:31:45
问题 I have a batch file that checks out code from SVN and calls few commands on it.This happens on the windows command prompt. I want to call this batch file from my java program and the command prompt must be present in the console of my application window and not as a separate window so I can see the output of the batch from my application. Can anyone tell me how to include the command prompt to my console? I am using Swing. 回答1: If all you want is to see the output, forget the command prompt.

Incude command prompt in Java panel

岁酱吖の 提交于 2021-02-16 05:31:04
问题 I have a batch file that checks out code from SVN and calls few commands on it.This happens on the windows command prompt. I want to call this batch file from my java program and the command prompt must be present in the console of my application window and not as a separate window so I can see the output of the batch from my application. Can anyone tell me how to include the command prompt to my console? I am using Swing. 回答1: If all you want is to see the output, forget the command prompt.

Incude command prompt in Java panel

北战南征 提交于 2021-02-16 05:30:18
问题 I have a batch file that checks out code from SVN and calls few commands on it.This happens on the windows command prompt. I want to call this batch file from my java program and the command prompt must be present in the console of my application window and not as a separate window so I can see the output of the batch from my application. Can anyone tell me how to include the command prompt to my console? I am using Swing. 回答1: If all you want is to see the output, forget the command prompt.