jframe

JFrame coloration should like to this picture

岁酱吖の 提交于 2019-12-09 07:10:34
问题 My question is a bit strange. I want my created form (with JFrame) coloration should be like to this picture: Should i use a special look and feel ? 回答1: Should i use a special look and feel ? there is no such built-in Look&Feel available as much as i know. However for "Look&Feel", "Look" refers to the appearance of GUI widgets (more formally, JComponents) and "feel" refers to the way the widgets behave. If so, then we can always make our Swing component to be appeared as we want in the GUI.

Java slow 2D performance - Resizing

好久不见. 提交于 2019-12-09 04:50:13
问题 I am using Windows 7 with Aero, and have a very fast graphics card (Radeon 6870) that I use for gaming. I have some issues when resizing very simple programs I make with java. For instance, this program does absolutely nothing. It has no action listeners, no loops. It's simply a GUI interface with buttons. Resizing with OpenGL acceleration off: [View fullscreen] It takes about a second to resize the components. For me that's very noticeable. Resizing with OpenGL acceleration on: I have tried

Accessing JComboBox data from separate JForm

南楼画角 提交于 2019-12-09 03:36:09
问题 I've spent a bit of time browsing Stack Overflow and the internet looking for the answer to my question, but I found all the answers hard to understand and I was quite unsure if any of them related to my problem, so I decided I needed help in the right context. I am creating a program that will give a series of solutions based on a particular type of graph inputted. I am sincerely struggling with taking the data from my JComboBox in the first JFrame, and displaying it in the second. I have

Refreshing a JLabel icon image

偶尔善良 提交于 2019-12-09 00:39:26
问题 I'm displaying an image in a JFrame using a JLabel and setting it's icon. It works the first time, but whenever I go to change the image, it remains what I set it the first time, so I've tried this and still the same result. contentPane.remove(lblPlaceholder); lblPlaceholder = null; lblPlaceholder = new JLabel(""); lblPlaceholder.setBounds(10, 322, 125, 32); contentPane.add(lblPlaceholder); lblPlaceholder.setIcon(new ImageIcon("tempimage.png")); How can I get it to change it's image? I've

Adding icon on JTabbedpane tab

余生长醉 提交于 2019-12-08 20:48:45
问题 I am having a JTabbedPane on my Form. The problem is I want to display icons to the Tabs of my TabbedPane. How can i do that? 回答1: Use the setIconAt method of the JTabbedPane : http://docs.oracle.com/javase/7/docs/api/javax/swing/JTabbedPane.html#setIconAt(int, javax.swing.Icon) 回答2: Please read the java tutorials first, they are really informative: http://docs.oracle.com/javase/tutorial/uiswing/components/tabbedpane.html 来源: https://stackoverflow.com/questions/11360964/adding-icon-on

Clear window from drawing objects

喜欢而已 提交于 2019-12-08 19:38:32
I have 4 classes: Draw, Rectangle (extends Draw), FreeHand (extends Draw) and a test class. I add rectangles and lines drawn by free hand to an arrayList. I have a menubar with choices Back and Clear. Back removes the last drawn object. It is done by removing the last object in the arraylist. Clear clears the windows. It is done by clear the arraylist from all items. Now to my problem: The window does not clear. I don't know how to write the code to make it repaint properly so that the items removes from the window. Can you please help me with how the code for this would look like, and where I

Full-Screen Exclusive mode error

余生长醉 提交于 2019-12-08 14:19:49
问题 I want to use Full Screen mode, but I keep getting a complicated error when I press "F". I am using eclipse and it does not show any errors and everything is imported. If anyone is good with code, can you tell me what I did wrong? A snippet of the code: GraphicsEnviroment ge = GraphicsEnviroment.getLocalGraphicsEnviroment(); GraphicsDevice gd = ge.GetDefaultScreenDevice(); private boolean FullScreen = false; JFrame frame = new JFrame(TITLE); // Not shown: The JFrame is set up etc., and a

How to set an icon for a frame in Java?

拟墨画扇 提交于 2019-12-08 12:59:33
问题 I have used this statement to set icon of a frame: frame.setIconImage(Toolkit.getDefaultToolkit().getImage("tictactoe.gif")); Unfortunately the frame icon still shows default java icon instead. How to fix this? 回答1: Check if Toolkit.getDefaultToolkit().getImage("tictactoe.gif") really reads the image. Try to split into 2 lines: Image img = Toolkit.getDefaultToolkit().getImage("tictactoe.gif"); frame.setIconImage (img); Then use debugger to check what is there inside img variable. 回答2: Try

Counter on JFrame

对着背影说爱祢 提交于 2019-12-08 11:55:35
问题 I am trying to make a JFrame and see the progress of the counter. int i = 1; while (i < 100000){ textField.setText(String.valueOf(i)); System.out.println(i); i++; } When I start it I can see the progress at the console but the value of the textField does not change. It changes to 100000 when the loop ends. How can I make it show the progress like in console? 回答1: There are a number of important differences between and other GUI toolkits like C#. Firstly, Swing components SHARE a common native

Java no response from other classes

人走茶凉 提交于 2019-12-08 11:50:22
问题 I have this GUI program where I'm trying to basically copy windows CMD. Since I have lots of features in this program, I decided to put parts of the code in different classes. But it doesn't respond. if(command.size()<2 && command.size()>0) { switch(command.get(0)) { case "dt": getDateTime a = new getDateTime(); a.Start(); break; // other case(s) down below } } Here is the geDateTime class public class getDateTime { public static void Start() { Terminal t = new Terminal(); try { DateFormat