Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
When I run my program, I have a button called "Create new account" that opens a new jframe (bad design I know), and when this new window opens, it suddenly distorts and changes the color of some of the text on tabbed panels from the previous jframe.
Here are some images of the problem I'm experiencing. Look at the tabs labeled administration, create new account, and modify existing account
Before:
After:
Any help or insight as to why the text gets distorted would really be appreciated.
You should not have JFrames launching JFrames. If a JFrame needs to launch another window that behaves as its child window, it should be a dialog such as a JDialog or JOptionPane. Note that dialogs can be shown in both modal and non-modal fashion, the former (modal) freezes the code flow from the calling program until the dialog has been dealt with, preventing users from interacting with the parent window while the latter (non-modal) doesn't.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 months ago.
Improve this question
I have the following, code which almost does what I want except it doesn't automatically stretch to the right, so the whole label can be seen. I've tried different constrains on it, but it doesn't change, setting the JFrame bigger works, but I would like it to resize depending on the label length, so it doesn't occupy more space on the screen than needed.
The UI Window
Run JFrame.pack() to resize the frame according to it's components.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm pretty new to Java and I'm currently attempting to make a simple work scheduling program. I'm trying to implement a way to add employee's and their info into but I'm a little stuck.
What I wanted to do was have a button that opens up a new window that will let me input their name (string), total hours to work per week (int), and their availability (array, check boxes that will translate to an array). Is it possible to customize a JDialog to do this or is there a better way to go about doing this? I tried reading tutorials on JDialogs but none of it explains how to implement multiple inputs.
I currently have it to where I'm opening up a new JFrame but I've read from multiple sources that I shouldn't do that.
Thanks for any help.
I tried reading tutorials on JDialogs but none of it explains how to implement multiple inputs.
This is no different than adding multiple components such as JTextFields, JRadioButtons, JComboBoxes in a JFrame. For both you'd create a main JPanel to hold the GUI, and then give it components and or other JPanels each using its own layout manager. Then create your JDialog or JFrame (using the API to see which constructor to use), add your main JPanel to the top level window (actually to its contentPane) by calling add(myMainPanel), pack the top level window by calling pack(), and display it via setVisible(true).
The key issue for a dialog window is often when to query its contents. If it's a modal dialog, then that's easy -- you query the contents (the state of its fields) after the call to display the dialog, since that code flow will resume once the dialog is no longer visible. For a non-modal dialog, then you'd need to add a WindowListener to notify you when the dialog is no longer visible.
For more specific help, you need to ask a more specific question and show code.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a problem with my project. I'm making a tool for numerical methods (a lesson in college). I have done nearly all of the project but I have a problem with my design.
When I resize it before making anything it resizes well but, if I set the size of the matrix after the matrice processes the panel isn't resizing.
The code works well if the rank is <=5, but the bigger matrices cause that problem.
I'm using window builder and the code is messy but I'll be glad if you try to help me.
Thanks for your helps!
Some of things that I noticed in your code.
Don't use null layout at all and avoid setBounds() method
Always hand over it to Layout manager to set the position and size the components.
Use ActionListener for JButton instead of MouseListener if you want to capture click event only.
Note: I can't run your code on my system due to character encoding issue. You have used some character other than English in your code.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm trying to program a game that has a title screen, and when you press Enter it advances to the game. The issue that I'm running into is that you can't put add a JPanel from a KeyPressed method.
I have one panel for the title and another for the game board, what is likely the best way to go about this?
I have one panel for the title and another for the game board, what is likely the best way to go about this?
Use a Card Layout so you can easily switch from the title panel to the game panel.
Your title panel should also probably have a button like "Start Game" so the user knows what to do. Then they can either click the button or press Enter.
and when you press Enter it advances to the game
To make the button the default button (so it responds to Enter) for the panel you can use:
frame.getRootPane().setDefaultButton(gameButton);
If you don't like the idea of adding a button then you will need to use Key Bindings.
You might want to take a look at CardLayout.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm doing simple ATM transaction application using java swing. I'm using Jframe form as the front end design. All i need is to create a custom jframe window like avast antivirus window having different close, maximize and minimize buttons on the top.
Thats all thank you.
create undecorated JFrame, put there JPanel with Borders, change the LayoutManager to BorderLayout
put another JPanel to NORTH area, with three undecorated JButtons and to set setIcons, setRolloverIcon, setPressedIcon with desired Icons
have to use proper LayoutManager for JPanel with three JButtons, but, probably, maybe FlowLayout (default LayoutManager for JPanel) is proper for this job, and/or you would need to set alignment for FlowLayout
for every those JButtons is required to override proper event from WindowListener, the same event as for standard decorated JFrame
every of my steps (that I'm talking about) are described in Oracles tutorials