jframe

why can't I draw any stuffs on Frame in java?

回眸只為那壹抹淺笑 提交于 2019-12-02 13:10:40
Coding is here. I can't create any rectangle or circle inside frame. the object of this project is to create converting celcius 2 Farenheit & Farenheit 2 Celcius. so what I want is, please teach me to how to draw rectangle or oval in side the frame. import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Frame; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; import

Nothing happens when running GUI

这一生的挚爱 提交于 2019-12-02 13:04:42
I'm doing a project for my class and I'm working on the GUI right now. I don't have much because, well, it's not showing up and it's infuriating. Here's my code. public class BookQuizGUI extends JFrame implements ActionListener { private Container c; private JPanel pnlButtons; private JButton addQs; private JButton takeQuiz; private JButton quit; private Container c2; private JPanel pnlButtons2; private JComboBox qType; private JComboBox ans; private JTextField q; private JTextField cA; private JTextField cB; private JTextField cC; private JTextField cD; private JButton add; private JButton

setModal issue with 2 Jdialogs within a Jframe

我怕爱的太早我们不能终老 提交于 2019-12-02 12:59:30
问题 I am facing issues when I set my first JDialog modal and the second one non-modal. This is the functionality I am trying to implement: On click of "Test the dialog!" button, a JDialog with name Custom Dialog Main will open. If click "yes" option in Custom Dialog Main , another JDialog named Custom Dialog Search will open. If click "yes" option in Custom Dialog Search , then Custom Dialog Main should come front. And I should be able to select any JDialog . For example if I select Custom Dialog

Integrating Swing in a simple text adventure game

孤街浪徒 提交于 2019-12-02 12:51:51
I am fairly new to some intermediate concepts in Java. Recently I made a text adventure game called DazzleQuest that runs entirely in the developer console/terminal. It involves my friends as characters so I wanted to show it to them and gain experience with Java by transferring the functionality of the command line and output from the console to a simple Swing interface comprised of a JTextArea to show the game's output and a JTextField , with ActionListener , to handle commands from the user. My main DazzleQuest class contains methods called run() and handleCommand() , which I figure I need

How to have a JFrame Maximise icon

旧街凉风 提交于 2019-12-02 12:26:19
How do i create a JFrame window in eclipse on a Mac that has an icon that makes the window full screen like the double arrow icon on most windows at the top right?? MadProgrammer Take a look at Fullscreen feature for Java Apps on OSX Lion And Java Runtime System Properties , which may be of interested or How can I do full screen in Java on OSX if those were the wrong feature you wanted UPDATE Lucky for you JFrame extends Window via Frame ... public class TestMacFullScreen { public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override public void run() { JFrame

JFrame does not add component when JButton is pressed

故事扮演 提交于 2019-12-02 12:15:07
My code is basically about having a frame and it has a button. You press the button you can draw rectangles, getting coordinates from the mouse press and the mouse release. Now, if you remove the button the code works perfectly, here is the code. //testing file package ActionTest; import java.awt.*; import javax.swing.*; public class MouseTest { public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { JFrame frame = new MouseFrame(); frame.setTitle("MouseTest"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); frame

Simple JFrame program but can't see JTextfield

≡放荡痞女 提交于 2019-12-02 11:50:26
I'm trying to learn Swing on my own. I'm playing with a toy program that asks the user to input their name. I put a JLabel and JTextfield into a JPanel where the user can input their name and submit. However my JTextfield is squished up and invisible and I can't get it to show (I've tried "setSize" to no avail). This is my code: import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; public class NamePrompt extends JFrame{ private static final long serialVersionUID = 1L; String name; public NamePrompt(){ setLayout(new BorderLayout());

Why is my JFrame empty?

不打扰是莪最后的温柔 提交于 2019-12-02 11:48:36
I can't seem to figure out why my JFrame is empty. Where am I going wrong? import javax.swing.*; import java.awt.FlowLayout; public class GUIExample extends JFrame { JCheckBox box1 = new JCheckBox("Satellite Radio"); JCheckBox box2 = new JCheckBox("Air Conditioning"); JCheckBox box3 = new JCheckBox("Manual Tranmission"); JCheckBox box4 = new JCheckBox("Leather Seats"); JRadioButton radio1 = new JRadioButton("Car"); JRadioButton radio2 = new JRadioButton("Pickup Truck"); JRadioButton radio3 = new JRadioButton("Minivan"); JTextField text = new JTextField(); ButtonGroup group = new ButtonGroup();

The method … is undefined for type JFrame

放肆的年华 提交于 2019-12-02 11:36:40
I'm trying to make a gui with two menu lists, with 3 items in each. What my problem is, is that when I click on an item, I get an error "The method displayList(int, AirplaneList) is undefined for the type JFrame" Code for AirplaneController.java: import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JOptionPane; import java.util.StringTokenizer; public class AirplaneController implements ActionListener{ public static StringTokenizer myTokens; //Declares a string tokenizer. public static String[] animals; public static int i;/

Simple KeyListener not working

白昼怎懂夜的黑 提交于 2019-12-02 11:35:06
I'm working on a really simple project in Java to try to understand how to use KeyListener. I've created a Main class and a KeyListener, MouseListener class. I want to get something to happen when I press a keyboard key. So far the only thing that is working is "Hello" when I click. Here is my code: import javax.swing.JFrame; import javax.swing.JPanel; public class KeyPractice{ public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); panel.addKeyListener(new KeyEar()); panel.addMouseListener(new KeyEar()); frame.add(panel); frame.setVisible(true);