jframe

JTextField resizing upon minimize

天大地大妈咪最大 提交于 2019-12-13 15:11:53
问题 I have a JTextField as well as a JTextArea in a JFrame. When the application runs however, the JTextField gets resized if I minimize the window. It usually doubles or triples in height, but it's not consistent in how it resizes each time. I have no idea why this could be happening. I'm not really asking for a direct solution, just some possible things that could be causing the problem. If you could help me out here that'd be great. Thanks EDIT: here's the code I'm using to initialize it:

How do I add shadow to Undecorated JFrame in Netbeans

若如初见. 提交于 2019-12-13 11:35:08
问题 I want to add shadow to Undecorated jFrame. i have no idea about how to do that. anyone know about that? 回答1: This is a bit of a "cheat". This doesn't make a drop shadow behind the window so much as makes a drop shadow behind the content. This method not only makes the window undecorated, but also transparent. The replacement "content pane" is partially filled allowing the shadow effect to "appear" behind it. import com.jhlabs.image.GaussianFilter; import java.awt.AlphaComposite; import java

Java - Program with KeyListener isn't working [closed]

旧街凉风 提交于 2019-12-13 11:23:43
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . Main problem: When I created a norwegian calculator using the KeyListener , it didn't work properly. I've added a call to the JFrame's addKeyListener() method and I've implemented the KeyListener interface and

Displaying multiple images without creating new variables [closed]

。_饼干妹妹 提交于 2019-12-13 11:01:38
问题 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 6 years ago . I'm making a program in java to emulate a basic deck of cards; no specific game in mind, just a good old deck of cards that you can move around and flip over freely (of course, with the limit of 52 total cards). Here is my current code: package cards; import java.awt.Color; import java.awt.Graphics; import java

Why is nothing showing up in my Java GUI?

半城伤御伤魂 提交于 2019-12-13 10:28:15
问题 I am currently working on a calculator. Right now, I am trying to gain experience with coding Java GUI, by making a simple program that makes a window with a text field. The code can compile without errors, but when I execute the program, the window appears, but without the text field. How do I make the text field visible? The code is shown as follows: import javax.swing.*; import java.awt.*; public class Window { public static void main(String[] args) { JFrame Window = new JFrame("Window");

How to open this program on a window?

余生颓废 提交于 2019-12-13 10:26:59
问题 Can anyone help me with my if and else statements? It's only saying "Exit Goodbye" whenever I input something, which should only happen when I enter -0. My teacher is gone for the week, so I don't have anyone to ask for help. package game; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Random; import javax.swing.JOptionPane; public class GameFrame { /** * @param args */ public static void main(String[] args) { // num1 - Variable to store the first value //

KeyListener won't work?

妖精的绣舞 提交于 2019-12-13 09:03:21
问题 I am trying to make a very simple 2-frame program called Duck Simulator. This has a JFrame and 2 pictures. If you want to know what it does, it just is a JFrame with a starting picture of a duck sitting in a pond. It has a JLabel saying "Press D to drink water!" And when you press D, it is supposed to set the image to the duck drinking. It shows the opening image of the duck sitting in the pond in the JFrame, but when I press D, it doesn't do anything. Here is the code: package net

Java Text Field of form to new form

霸气de小男生 提交于 2019-12-13 08:36:53
问题 I'm new in Java, just want to ask a simple question I have my first form and a text field, I input a text there the once I click the button a new form will come out and the Text in the text Field will be come a Label the the new form I try this code but it doesn't work public class Data extends javax.swing.JFrame { public Data() { initComponents(); FrmLogIn f = new FrmLogIn(); User.setText(f.UName.getText()); User.setVisible(true); } 回答1: There are many ways you could tackle this problem. You

How add list(ArrayList) in JFrame? [closed]

﹥>﹥吖頭↗ 提交于 2019-12-13 08:36:29
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . how can I add a list from arraylist from a class created by me to a Jframe window? 回答1: Here is one (of many) ways. Convert the ArrayList to a Vector . Construct a JList using the Vector. Construct a JScrollPane

get a color name of JColorChooser

独自空忆成欢 提交于 2019-12-13 08:36:21
问题 i am working with JFrame. In design View i put One JBUtton , two JTextField and swing windows JColorChooser. than i write a code for this getting hex value and color name in a two JTextField.the process is if i click on JButton, it will open JColorChooser palette, After that i click on JColorChooser for select a color it show corresponding color hex value in one JtextField and color Name in another JTextField. but i can get hex value but i don't know how i can get color name. import javax