jframe

Nothing happens when running GUI

笑着哭i 提交于 2019-12-03 00:04:55
问题 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;

My jframe doesn't shows [closed]

允我心安 提交于 2019-12-02 23:53:02
问题 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 . I'm beginner woth java programming I tried to make my jframe shows but it didn't jframe.setVisible(true); it doesn't works 回答1: I think you didn't declare correctly your JFrame. Here is an example creating a

What is the difference between a JFrame and a JDialog?

◇◆丶佛笑我妖孽 提交于 2019-12-02 23:41:10
What is the difference between a JFrame and a JDialog ? Why can't we use setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE); for a JDialog? JFrame is a normal window with its normal buttons (optionally) and decorations. JDialog on the other side does not have a maximize and minimize buttons and usually are created with JOptionPane static methods, and are better fit to make them modal (they block other components until they are closed). But both inherit from Window, so they share much functionality. camickr Why we can't use setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); for JDialog ? Sure you

Error with timer and JFrame

被刻印的时光 ゝ 提交于 2019-12-02 23:23:04
问题 I'm making a game with a timer and a JFrame (and many other things but only these 2 are causing problems), and after running the segments below, I got a weird error. At least for me who has never used these classes prior to this. Start executing this private static GameView window; private static Timer time; public static void main(String args[]) { window = new GameView(800,600); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setVisible(true); time = new Timer(); time.schedule(

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

走远了吗. 提交于 2019-12-02 23:17:15
问题 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

set JFrame Orientation from right to left!

浪尽此生 提交于 2019-12-02 22:58:33
To align my JFrame from righ-to-left, I use: setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); but this works only if I use the following style (decoration) of the JFrame: public class RightToLeft { public static void main(String []args){ javax.swing.SwingUtilities.invokeLater(new Runnable(){ public void run() { try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("العنوان بالعربي"); frame.setComponentOrientation(ComponentOrientation

Java GUI: about getContentPane( ) method and content

与世无争的帅哥 提交于 2019-12-02 22:57:56
In this piece of code: JLabel emptyLabel = new JLabel(""); emptyLabel.setPreferredSize(new Dimension(175, 100)); frame.getContentPane().add(emptyLabel, BorderLayout.CENTER); I can see it makes a new label and adds it to the JFrame object frame . But I want to understand what does getContentPane() do, and why do I need it? I read this API but I still didn't understand. Caffe Latte Every JPanel is a container, so either add it to a panel then add it to the container or directly use add(component) or use the getContentPane().add method. Both add the component to the container in Java 7 ( I don't

Drawing on a buffered image

廉价感情. 提交于 2019-12-02 22:42:35
问题 I am trying to draw on a buffered image. I am able to get the picture on the frame but it doesnt seem to draw on the image. If I use BufferedImage bufferedImage = new BufferedImage(1280, 800,BufferedImage.TYPE_INT_RGB); then it seems to draw the string but I would like to ideally draw on the image as I need to plot some coordinates on the image for a project. Any guidance would be highly appreciated. Excuse the bad indentation import java.awt.Dimension; import java.awt.Graphics; import java

how to set the position of glasspane in JFrame?

我只是一个虾纸丫 提交于 2019-12-02 21:52:40
问题 I'm trying to create a menu slider from the left side of the frame. It need to be floating above the content, where i can access it always with a mouse listener(open the menu when the mouse is close to the left edge). Well, I set my GlassPane (My JPanel ) as setOpaue(false) and it was floating above the content. but the glasspane always positioned on the center, and I need to have a possibility to move it,slide it, but with no luck. the setBounds and setLocation does not worked for me. Can

Java Painting not working

巧了我就是萌 提交于 2019-12-02 21:41:53
问题 So I have this code: package tictactoe; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JFrame; import javax.swing.JPanel; public class TicTacToe extends JFrame { public static void main(String[] args) { JFrame masterFrame = new JFrame("TicTacToe"); JPanel drawingPanel = new JPanel(); GameBoard theGame = new GameBoard(); masterFrame.add(drawingPanel); masterFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); masterFrame.setSize(504, 504); masterFrame.setResizable