jframe

How do I close a JDialog window using a JButton?

你。 提交于 2019-12-24 12:18:16
问题 I've tried a bunch of different ways to close the window, but since you can't send additional parameters to to Action Listener method I can't dispose the frame due to a pointer exception for the frame. This is my current code. import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class errorRequiredFieldMissing extends JDialog{ JLabel error; JButton exit; public static JFrame frame; public errorRequiredFieldMissing()

Inefficient Java program when using date

守給你的承諾、 提交于 2019-12-24 12:06:11
问题 My program seem to be using 20% of the CPU and around 1GB of RAM. I think its because I am looping the date. I am trying to make a clock appear on my JFrame (hours, mins and seconds always updating). My question is, how can I make my program less hungry for power? Here's my code: while(true){ Date date = new Date(); time.setText(date.getHours() + " hours " + date.getMinutes() + " minutes " + date.getSeconds() + " seconds!"); } 回答1: How can I make my program less hungry for power? Make your

Sliding any JPanel

杀马特。学长 韩版系。学妹 提交于 2019-12-24 10:48:18
问题 Im trying to make a universal class for sliding two any-samesized JPanels but when I use it, the one to get slid just disappears. What I also noticed is that the JPanel "innerPanel"'s width is being reset (when transisting a 200,200 panel) from 400,200 that the size gets reset to 200,200 after the Thread is started package org.chimeras1684.ui.panels; import java.awt.Point; import java.util.Date; import java.util.Timer; import java.util.TimerTask; import javax.swing.JFrame; import javax.swing

Get notified when the user finishes resizing a JFrame

烈酒焚心 提交于 2019-12-24 09:56:31
问题 I have a fractal generation component (a subclass of JPanel) inside a JFrame. When the user resizes the window, it takes quite a while to update the fractal to the new size. I currently have a ComponentListener on the JPanel, but its componentResized event is called every time the user moves the mouse while dragging the window border. This means that the fractal is told to resize many times, and slowly (over the course of a few minutes) grows to the new size. Is there a way to be notified

java look and feel: windows server 2012 shows progress bar too thin

纵然是瞬间 提交于 2019-12-24 09:16:04
问题 I get very thin progress bar on **windows server 2012 ** , when I use UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); The bar look okay in windows 7, very thin on windows server 2012. java version every where is (both JDK and JRE) 1.6.0_25, 32 bit Here is the full code to demonstrate a problem (or documentation issue) I am on jdk 1.6.0_25 package demos; import javax.swing.*; import javax.swing.plaf.metal.DefaultMetalTheme; import javax.swing.plaf.metal.MetalLookAndFeel;

how to display a JFrame from an applet?

依然范特西╮ 提交于 2019-12-24 08:50:01
问题 I have this class called PollFrame that extends JFrame in a file called PollFrame.java . PollFrame contains a form. I have an applet, which has a button in it. When the button is clicked, I want the PollFrame to be displayed. I set the ActionPerformed as: Pollframe poll = new PollFrame(); // This initializes the form poll.setVisible(true); However, when I click the button, I get the following error : Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied

Wrap image to Jframe

萝らか妹 提交于 2019-12-24 07:50:03
问题 I'm trying to get my Jframe to match my image dimensions exactly, so that when i attempt to get the Rectangle2D co-ordinates of an area via drawing a rectangle, it's give me the true co-ordinates of where it would appear on the actual image. The objective with this solution is to convert a PDF to a image, identify a particular area using the visual mapper and then use PDFBox (PDFTextStripperbyArea) to extract against this area. The co-ordinates being given by the below code is not extracting

GrahicsDevice and JOptionPane Issue

Deadly 提交于 2019-12-24 06:07:42
问题 When I click the button, the application which is set to full screen will go to taskbar/minimized, so I need to click it first in the taskbar before seeing the JOptionPane that I triggered. What do you think is the problem with this? I'd like it to run smoothly without being minimized or going to taskbar. public static void main(String[] args) { final JFrame frame = new JFrame(); frame.setTitle("Sample"); GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment()

Pause execution until the child dialog is closed

时光总嘲笑我的痴心妄想 提交于 2019-12-24 05:54:28
问题 I am trying to open a JDialog from JFrame . I want to pause the execution until the child dialog is being closed, but the main frame is being executed continuously without any pause. I am using the following code. What is alternate solution? Class NewFrame extends JFrame NewFrame() try { NewDialog frm = new NewDialog(); frm.show(); JOptionPane.showMessageDialog(null,"yes"); } catch(Exception ex) { ex.printStackTrace(); } } } In the above program I want a message should be displayed when the

Save JFrame location in multi-display environment

时光毁灭记忆、已成空白 提交于 2019-12-24 05:46:54
问题 I want to store a JFrame's location (bounds, extendedState) when the user closes it. However, when the user moves the frame onto the 2nd screen and maximizes it, how can I store that information? My naive (and single display) implementation is like this: void saveFrame(JFrame frame) throws IOException { Properties props = new Properties(); props.setProperty("State", String.valueOf(frame.getExtendedState())); props.setProperty("X", String.valueOf(frame.getX())); props.setProperty("Y", String