jframe

How To Customize A JFileChooser

爱⌒轻易说出口 提交于 2019-12-12 00:45:38
问题 I want to customize my JFileChooser so that instead of saying "Folder Name" at the bottom I want to set it to say "Picture Name" and at the text field I don't want that to change based on where i'm clicking, i want it to just stay blank the whole time. Anyway I could do this. basically I just want to customize my JFileChooser: 回答1: The file chooser wasn't designed to be customized in this way. The proper solution would be to customize the UI of the file chooser. For a hack you can try using

How to make a rectangle with mouse listeners and add them to JFrame?

橙三吉。 提交于 2019-12-11 22:47:57
问题 Basically, I want to make a rectangle that contains a mouse listener for my tic tac toe game. I intend to place them in between the lines to serve as mouse listeners. I have already set up a JFrame, all that is left is for me to add the rectangle. How would I go about doing this? Here is my code so far: public class TicTacToe extends JFrame{ public static void main(String[] args) { // TODO Auto-generated method stub new TicTacToe(); } public TicTacToe(){ //Sets up the frame this.setTitle("Tic

Calling a JFrame of inner class and hiding the JFrame of outer class

限于喜欢 提交于 2019-12-11 21:27:13
问题 When i am calling the inner class JFrame , it is called and it is displaying, but the outer class JFrame is not hiding. here i am providing my code. To be very specific, I am trying to fill a form and then i want to preview the form what i have written. package com.vote.rmc; public class LRegister extends JFrame implements ActionListener { final public JFrame rframe = new JFrame(); JLabel public LRegister() { rframe.setSize(800, 600); rframe.setLocationRelativeTo(null); cp = getContentPane();

Full screen frame issue

元气小坏坏 提交于 2019-12-11 21:14:51
问题 I have this code, which basically initializes a new JFrame and sets it full screen public class FullScreenFrameTest extends JFrame { public FullScreenFrameTest() { super(); initFrame(); setVisible(true); //full screen GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice device = env.getDefaultScreenDevice(); device.setFullScreenWindow(this); //end full screen } public void initFrame() { Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();

what is the purpose of JFrame setBackground

二次信任 提交于 2019-12-11 21:06:09
问题 When you create JFrame instance, you have setBackground method available from this instance. However, regardless to what color you try to put there, you`ll receive gray background color. This happens (as i understood), because default JPanel instance is automatically created inside JFrame and lays over it . So, to get color set, you need to call JFrame.getContentPane().setBackground(Color.RED); that actually calls setBackground of default JPanel , that exists inside JFrame . I also tried to

How do I pause a JFrame while another is running [duplicate]

两盒软妹~` 提交于 2019-12-11 21:02:22
问题 This question already has an answer here : How to wait for a JFrame to close before continuing? (1 answer) Closed 6 years ago . I'm making a Server with a database inside, but while I'm loading the main JFrame and while I'm connecting to the database reading username & password from a .properties file I chosed to let the user know that the program is running, what the program is doing in that specific moment, and also let him create a .properties file if it not exists (first launch). The

JFrame adding Text not working. Two GUI appear

≡放荡痞女 提交于 2019-12-11 20:14:48
问题 I am trying to create a simple JFrame menu where there is a nice background, which works, along with some text. The text is a bit buggy. Here is how it looks (http://imgur.com/nRpzA30) As you can see, only one line of the text appears not the second line. Along with that. Two GUI's appear when I run the program. One is completley empty, and one looks like the picture above. Finally I can't use the method logo.setHorizontalAlignment(JLabel.NORTH); without getting an error, same with a few

Why do I have to use setvisible() on my JFrame when I change components?

只谈情不闲聊 提交于 2019-12-11 19:51:10
问题 So for the sake of simplicity I set up a little test code just to figure out this problem. Basically I have a JFrame and I added 'this' to it (I just extended my main class from JComponent to save time). this component fills in a red background. Then I have it sleep for 2 seconds and then type this. f.remove(this); thing t = new thing(); f.add(t); f.setVisible(true); f being my JFrame object and 'thing' is just another class extending JComponent that paints a blue background.. when I comment

Get mouse position of a JFrame even when its child component is focused

ⅰ亾dé卋堺 提交于 2019-12-11 19:23:30
问题 I want to get the mouse position of my JFrame. But when mouse is on its child component (such as a table, button that is added to the JFrame) MouseMotion event is no more listening. How can I get the mouse position? 回答1: Assuming the use-case in your comment is the real issue to solve, the answer is to implement the mouseExited such that it checks whether the mouse is still somewhere over the frame and hide it only if not. Something like: MouseListener closer = new MouseAdapter() { @Override

Clicking a button within a JFrame passes an data to a JPanel

夙愿已清 提交于 2019-12-11 18:32:24
问题 I have a Jframe with two buttons: '1' and '2'. Clicking the button '1' should display the capital letter A in the JPanel. Code fore my JFrame: import java.awt.BorderLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class DrawFrame extends JFrame{ private final int WIDTH = 500; private final int HEIGHT = 300; private JButton number1; private