jframe

get set Text from one JFrame to another pop up JFrame with a textArea

柔情痞子 提交于 2019-12-14 04:23:07
问题 I need to take all the textField, comboBox, jlst, and jslider input from the first frame and make it into a summary in the second frame after the Submit button is picked. I can't figure out the best way to do this. My assignment requires a popup second frame with a textArea and exit button that brings you back to the first frame. import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.Hashtable; public class Ch10Asg extends JFrame { private String[] flightNames = {

How to set the previous jframe visible when current jframe is disposed

和自甴很熟 提交于 2019-12-14 04:05:47
问题 I am making a Java gui project and it consists of two frames. The problem is that when I call the secondframe from the firstframe, I have set it such that the firstframe visibility is set to false. The problem is how do I make the firstframe visible again by using a button from the second frame. should i ditch this method and create a new jpanel instead??? Does jpanel have similar capabilities as jframe? 回答1: Consider using CardLayout . This way you can switch via multiple UIs without needing

How to put JFrame into existing JPanel in Java Swing?

那年仲夏 提交于 2019-12-14 03:48:26
问题 I have an open-source java swing application like this: http://i47.tinypic.com/dff4f7.jpg You can see in the screenshot, there is a JPanel divided into two area, left and right area. The left area has many text links. When I click the SLA Criteria link, it will pop-up the SLA Criteria window. The pop-up window is JFrame object. Now, I'm trying to put the pop-up window into right area of the JPanel, so that means no pop-up window anymore, i.e. when I click the SLA Criteria link, its contents

Adding JDesktopPane to JFrame using GridBagLayout

我的梦境 提交于 2019-12-14 03:29:28
问题 How do I add the JDesktopPane to JFrame using GridBagLayout and set its height and width. If I add JDesktopPane that contains JInternalFrame I don't get anything. But works well in case of GridLayout but the problem is I can't set my desired size in it as GridLayout splits equal space among each component added. 回答1: You will probably need to set the fill and weight attributes of the GridBagConstraints ... GridBagConstraints gbc = new GridBagConstraints(); gbc.weightx = 1; gbc.weighty = 1;

Insert a GIF image into JFrame and make it visible and invisible on demand

感情迁移 提交于 2019-12-14 03:29:05
问题 In my application I am extracting data from a project DB. When I do that I want to signal to user that data extraction is in progress. I want to achieve this by making my current frame view.getFrame2() invisible and making view.getFrame3() visible. Frame 3 will have GIF image with frame titled as "Extraction is in progress". I am able to achieve my target but I am not able to view the image in the frame. It's blank. Below is the code snippet I am using; one class is used for view, another one

How to know coordinates of java frame?

倾然丶 夕夏残阳落幕 提交于 2019-12-14 02:36:57
问题 I am trying to develop a very basic game and it involves mouse. So what i am trying to do is getting coordinates of mouse to write a integer. I searched internet and find this. mouse_x=MouseInfo.getPointerInfo().getLocation().getX(); mouse_y=MouseInfo.getPointerInfo().getLocation().getY(); It partially worked and gave me coordinates of mouse on desktop. But what i need is coordinates of mouse on frame. So if only i knew the coordinates of frame's starting (0,0) point (not the window's. the

.pack() causes the components to be in the wrong place but works after window resize

我与影子孤独终老i 提交于 2019-12-14 02:35:03
问题 I am creating a game in java using Swing. I am using mainJFrame.setExtendedState(mainJFrame.getExtendedState() | JFrame.MAXIMIZED_BOTH); on my JFrame to start it as a maximized window. After this I am using mainJFrame.pack(); to be able to get the correct x & y coordinates of components in the GUI. I need those coordinates since i'm painting custom images to the GUI. So far everything is fine. When a user has passed a level, i rebuild the GUI to updated it to the new level settings and then i

How To Add A MouseListener To A Frame

心已入冬 提交于 2019-12-14 00:23:15
问题 I want to add a mouselistener to mt JFrame frame but when i do frame.addMouseListener(this) i get an error that i cannot use this in a static method I am making an application that detects a click of the mouse then displays it in int clicks code import java.awt.BorderLayout; import java.awt.Color; import java.awt.FlowLayout; import java.awt.Font; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax

Can not complete drawline on JButton [closed]

被刻印的时光 ゝ 提交于 2019-12-13 23:18:23
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . So I am making a simple tic tac toe game and ran into a problem at the last minute I am trying to draw a line at the win location but on the final win location(index), the line gets hidden behind the JButton not entirly sure why it is doing this. I know alot of people say do not use getGraphics() , and I am

How to name JFrame in a constructor

做~自己de王妃 提交于 2019-12-13 22:47:10
问题 Question may be different than what you expected, but I'm creating a utility function for JFrames to make it easier for future me. public void setJframe(String title, int w,int h, JFrame name, Boolean maximize){ name.setSize(w, h); name.setTitle(title); if (maximize == true) { name.setExtendedState(name.getExtendedState()|JFrame.MAXIMIZED_BOTH); } else { name.setLocationRelativeTo(null); } } I want the ability to name the JFrame as I type in the parameters. At the moment, when I type in a