jframe

Detect which monitor shows the Window

☆樱花仙子☆ 提交于 2019-12-04 15:13:01
问题 I do have main application JFrame window which can include different components. I open a self implemented OnScreenKeyboard when the user select a editable textfield. The OSK is also a JFrame window. When the user drag the main window to another monitor, the OSK should also be shown on the same monitor. For this i have to detect the monitor the main JFrame is shown. I try to find a method in Toolkit.getDefaultToolkit() but was not able to find someting. Do you know how i can detect the

MouseEvent lost in JScrollPane

守給你的承諾、 提交于 2019-12-04 14:44:56
This is the code I am using to show the issue which I am facing in another project. I am not getting any line like this if I use JScrollPane as a wrapper for panel2. Why? I want to click on JscrollPane and got event printed as following. java.awt.event.MouseEvent[MOUSE_CLICKED,(800,469),absolute(808,499),button=1,modifiers=Button1,clickCount=1] on javax.swing.JPanel[,0,0,934x612,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.border.LineBorder@cc0e01,flags=9,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=880,height=630]] If now I change panel1.add

When you use Frame or JFrame in Java? [duplicate]

时间秒杀一切 提交于 2019-12-04 13:46:06
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: What is the difference between swing and awt? I often see that JFrame is used a lots. But sometimes, I also see that programmer use Frame in their example. So could you tell me the advantages/disadvantages of them? 回答1: Well let me break it up for you.............. Before jumping into Frame Vs JFrame, let me explain you about AWT and Swing. AWT : - It has a Platform Dependent Look and Feel . - So it uses the

Popup for JFrame close button

ⅰ亾dé卋堺 提交于 2019-12-04 13:29:58
问题 i am doing some basic Java Swing application (beginner level) . what i have to do is when i press close button on JFrame to colse the window i want a JOptionPane Confirm Dialog instead of straightforward close here is the code JFrame JFrame frame= new JFrame("frame"); frame.setSize(300,300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); frame.pack(); and JOptionPane code goes like this final JOptionPane optionPane = new JOptionPane("Are You sure?",JOptionPane

Why Timer does not work if we do not generate a window?

天涯浪子 提交于 2019-12-04 12:09:23
Here is the code: import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.Timer; public class TimerSample { public static void main(String args[]) { new JFrame().setVisible(true); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println("Hello World Timer"); } }; Timer timer = new Timer(500, actionListener); timer.start(); } } It generates a window and then periodically prints "Hello World Timer" in the terminal (Command Prompt). If I comment this line new

How to deploy swing application on web browser?

非 Y 不嫁゛ 提交于 2019-12-04 09:14:01
I have a big swing application that I have developed. There are several classes that each creates its own JFrame while closing the previous one which called this class. I wish to deploy this into a web browser and understand that I need to convert it to an applet. Do I have to add in code for creating applet in each of these classes? or is there some other way. In my current situation each of the class creates a JFrame which has some buttons which on being clicked will close the current JFrame and instantiate a new class which creates another JFrame . Could you please help me and advice me on

Trying to display URL image in JFrame

。_饼干妹妹 提交于 2019-12-04 07:55:22
Trying to display a URL-image in a JFrame window. If this works correctly, when the program runs, a window should open displaying an image. Trying to experiment with URL's and hard-drive paths. import java.awt.image.BufferedImage; import java.io.IOException; import java.net.URL; import javax.imageio.ImageIO; import javax.swing.*; class ImageInFrame { public static void main(String[] args) throws IOException { String path = "http://chart.finance.yahoo.com/z?s=GOOG&t=6m&q=l"; URL url = new URL(path); BufferedImage image = ImageIO.read(url); JLabel label = new JLabel(new ImageIcon(image)); JFrame

Difference between JPanel, JFrame, JComponent, and JApplet

允我心安 提交于 2019-12-04 07:30:24
问题 I'm making a physics simulator for fun and I was looking up graphics tutorials when I tried to figure out the difference between all these J's. Can somebody elaborate on them or perhaps provide a link to a helpful source? 回答1: Those classes are common extension points for Java UI designs. First off, realize that they don't necessarily have much to do with each other directly, so trying to find a relationship between them might be counterproductive. JApplet - A base class that let's you write

Swing: Change cursor to wait cursor

最后都变了- 提交于 2019-12-04 07:19:26
See also Java Swing GUI hour glass . However the provided answer does not seem to work. I have following code: private void loadFileMenuItemActionPerformed(java.awt.event.ActionEvent evt) { int returnVal = fileChoser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { try { this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // do stuff } finally { this.setCursor(Cursor.getDefaultCursor()); } } } This is called when user selects the according entry in the menu bar. However the cursor never changes. Note that loading the file takes a file and hence a change in the

Swing timers basic functionality [closed]

跟風遠走 提交于 2019-12-04 06:59:52
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . I'm new at java graphic design, and I would like you, if possible, to help me with an easy example to help me to get to understand the basic