awt

JTextArea ArrayList string data and JTextField input data not matching

…衆ロ難τιáo~ 提交于 2019-12-13 21:13:18
问题 so I am trying to have my program read a list of lines from a txt file. This is then displayed in a JTextArea. The user can input data using the JTextField and the goal is to display "Hooray" if the user matches the text in the JArea and "Wrong!" if they do not. Any help is appreciated. public class TextArea1 { JTextArea text; JFrame frame; JTextField textField; public int k; public ArrayList aList; public String correctAnswer; public static void main(String[] args) { TextArea1 gui = new

Java: mouseDragged and moving around in a graphical interface

落花浮王杯 提交于 2019-12-13 20:22:58
问题 newbie programmer here. I'm making a program that renders user-inputted equations in a Cartesian coordinate system. At the moment I'm having some issues with letting the user move the view around freely in the coordinate. Currently with mouseDragged the user can drag the view around a bit, but once the user releases the mouse and tries to move the view again the origin snaps back to the current position of the mouse cursor. What is the best way to let the user move around freely? Thanks in

How can I prevent a LayoutManager from shrinking my components too much?

血红的双手。 提交于 2019-12-13 19:28:03
问题 How can I prevent GUI components from shrinking on resizing in a BorderLayout Manager? Is it possible to set a minimum size so that components do not shrink beyond it? It seems using setBounds does not work with Layout Managers. Just one more question: If I used nested panels, is it possible to assign them fixed positions and let the layout manager takes care of the components inside these panels? I'm trying to prevent GUI components from moving around. 回答1: Unfortunately, whether a layout

How do you make text in a frame change dependent on cursor position?

僤鯓⒐⒋嵵緔 提交于 2019-12-13 17:39:42
问题 I have a program that is basically just supposed to change the text of a label when your cursor enters a polygon that is shown on the JPanel . I have tried a few different things with nothing working. Currently I am trying an if statement to make it choose which button to add but it still doesn't change if i move my cursor into the polygon. when the cursor is outside of the polygon the label should say "point is not in the polygon" and when inside it should say "point is in the polygon". Any

How to add intellisense to a search line in java swing

安稳与你 提交于 2019-12-13 17:16:08
问题 This is my first time with intellisense so please go easy on me :) I'm using Java swing for building a search engine for viewing XML files . At the moment the XML file is uploaded and searched successfully , however I still would like to add the intellisense element to the project . It's very hard to be specific since the code is pretty big , then I'll do my best to be as specific as I could . Here is a visual picture of the XML search engine : Now , after the user uploaded the XML file

JNA causing EXCEPTION_ACCESS_VIOLATION?

回眸只為那壹抹淺笑 提交于 2019-12-13 16:32:00
问题 My Java UI unexpectly terminated and dumped an hs_err_pid file. The file says "The crash happened outside the Java Virtual Machine in native code." JNA is the only native code we use. Does anyone know of any know issues or bugs with any JNA version that might cause this. I've included some of the contents from the error file below. An unexpected error has been detected by Java Runtime Environment: EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d02bcbd, pid=312, tid=3616 Java VM: Java

Java cannot find symbol in List

若如初见. 提交于 2019-12-13 15:41:43
问题 OK so I switched from JList to List because 1.) It doesn't overlap my drawn images 2.) It can have focus disabled yet track what's selected Anyway, here's the error I get when I try to compile: C:\Users\Dan\Documents\DanJavaGen\inventory.java:30: cannot find symbol symbol : constructor List(java.lang.Object[]) location: class java.awt.List list = new List(arr.toArray()); ^ C:\Users\Dan\Documents\DanJavaGen\inventory.java:50: cannot find symbol symbol : method getSelectedValue() location:

Enable drop just for specific targets in Swing

点点圈 提交于 2019-12-13 14:25:55
问题 I'm trying to implement drag & drop in java with two JList instances. The basic flow works fine. However, when I'm dragging a string from one list, I want to restrict the drop target only for the second list. I noticed that when I'm dragging a string from one list to my desktop so it creates a file containing this string. Is there any way to avoid such situations? public class SampleDnD extends JFrame{ public static void main(String[] args) { new SampleDnD(); } /** * new form of frame sample

Getting drawable area of an AWT frame in Mac OS X?

只谈情不闲聊 提交于 2019-12-13 13:25:00
问题 I have subclassed java.awt.Frame and have overridden the paint() method as I wish to draw the entire contents of the window manually. However, on the graphics object, (0,0) corresponds to the upper left hand corner of the window inside the title bar decoration, not the first drawable pixel. Can I determine the co-ordinate of the first drawable pixel (ie, the height of the decoration) in a cross-platform manner, avoiding using a Mac OS X-specific fudge factor? Will I be forced to nest a Panel

how to display JFrame in full screen display mode at a multi-monitor environment?

 ̄綄美尐妖づ 提交于 2019-12-13 12:21:54
问题 There is a JFrame, when it in a multi-monitor environment, how to display this JFrame in full screen display? For example, now the JFrame is displaying in monitor 1, when it is going to change to full screen display mode,it must be displayed in the monitor 1; if is displaying in monitor 2,when it is going to change to full screen display mode, it must be displayed in the monitor 2. 回答1: Try this, For Single Screen Toolkit tool = Toolkit.getDefaultToolkit(); Dimension dim = tool.getScreenSize(