jframe

SwingWorker in another SwingWorker's done method

放肆的年华 提交于 2019-11-26 10:05:20
问题 First, I need to inform you that I am trying my hardest to learn how to code in Java. Its been a little bit difficult, but, I do believe I have it. I have submitted a couple question in the past in regards to SwingWorkers and the like. Each of which I thought I had it, but come to find out that I still had learning to do. Hopefully this time, is not one of those times. With that said, please let me know of anything you see that isn\'t to standard, or, could lead to problems in the future. Now

Java JFrame .setSize(x, y) not working?

假如想象 提交于 2019-11-26 10:04:55
问题 When I execute this bit of code, a tiny window pops up that, and the inside of it is about 116x63, and the entire size including the border of ~140x100. How do I set the inside to be what I need it to? public static void graphics() { JFrame frame = new JFrame(); String title = \"test window\"; frame.setTitle(title); frame.setSize(gridRow, gridCol); //101 x 101 frame.setResizable(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } 回答1: Create a custom

Proper way to use JLabels to update an image

喜欢而已 提交于 2019-11-26 10:03:39
问题 I am creating a GUI, and am fairly new to swing and awt. I am trying to create a gui that, upon launch, sets the background to an image, then uses a method to create a slideshow of sorts. I have attempted it, and I am not attached to the code so I am able to take both revisions and/or whole new concepts. EDIT(9/15/13): I am having trouble with the slideshow, I cant seem to get it to work. Here is my current code. public class MainFrame extends JFrame{ JLabel backgroundL = null; private JLabel

FlowLayout on top of GridLayout not working

岁酱吖の 提交于 2019-11-26 10:02:23
问题 I\'m trying to create a hangman game and so far it\'s coming along GREAT, but the layout design just doesn\'t seem to fall into place! The alphabet is supposed to end up in a FlowLayout order on top of the Hangman picture with the buttons \"Restart\", \"Help\" \"Add New Word\" and \"Exit\" at the bottom! What am I doing wrong? import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; public class Hangman extends JFrame { int i = 0; static JPanel panel; static JPanel

How to add multiple components to a JFrame?

ε祈祈猫儿з 提交于 2019-11-26 10:01:44
问题 I have a JFrame . I also have a Box class which extends Component . This box class has a paint method which makes a filled rectangle. When I add multiple of these Box components to my JFrame, only the most recently added one is displayed when I call repaint on the JFrame. I took a look at the layout managers, but I am not sure that\'s what I want. All I want is to be able to make an animation of whole bunch of rectangles wherever I want on the screen. (I also tried creating a panel, adding

All JFrame freeze while do JavaMail

倖福魔咒の 提交于 2019-11-26 10:00:46
问题 I develop program of car management system. Then I want to send mail to owner of this company when car coming in and car out. My code can send mail successfully but I notice that while mail send, other JFrame window is freeze (I can\'t do anything on all JFrame window) until mail send is complete. Is this normally for Javamail or there is a way to make other JFrame still working? In my program, it take about 10 seconds to complete send one mail. 回答1: When you do heavy task you should run them

Only allowing numbers and a symbol (-) to be typed into a JTextField

守給你的承諾、 提交于 2019-11-26 09:58:05
问题 I\'m trying to create a math quiz and I only want the user to be able to enter numbers whether they\'re negative or positive. Is there any way to do so? I\'ve thought of using Regular Expressions but I\'ve heard that they are bad to use. I tried using a keylistener but then what if the user pastes? I\'ve tried parsing the string to get an integer but then the negative symbol will not work. Any ideas? package com.quiz.ui; import java.awt.BorderLayout; import java.awt.event.KeyEvent; import

Why are my items not showing up in JFrame?

删除回忆录丶 提交于 2019-11-26 09:56:03
问题 I\'m fairly new to JFrame and I want to know why my items are not showing up on the window. I know i dont have a ActionHandler but I just want my textfield\'s to show up on my window. Here\'s my code: import java.awt.Font; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPasswordField; import javax.swing.JTextField; public class FirstGUI extends JFrame{ public void GUI(){ setTitle(\"Welcome\"); setResizable(false); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

how to set JFrame background transparent but JPanel or JLabel Background opaque?

孤人 提交于 2019-11-26 09:44:44
问题 As per assignment, we have to create a image viewer just like Picasas one. picture in the middle, translucent black background and changing images with left/right buttons. i can display an image set it to undercoated, set it to translucent frame but along with frame the the picture becomes translucent. what am i doing wrong. Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); JFrame f1 = new JFrame(\"ShowImage\"); f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f1.setSize(dim); f1

Java - How to create a custom dialog box?

别等时光非礼了梦想. 提交于 2019-11-26 09:36:10
问题 I have a button on a JFrame that when clicked I want a dialog box to popup with multiple text areas for user input. I have been looking all around to try to figure out how to do this but I keep on getting more confused. Can anyone help? 回答1: If you don't need much in the way of custom behavior, JOptionPane is a good time saver. It takes care of the placement and localization of OK / Cancel options, and is a quick-and-dirty way to show a custom dialog without needing to define your own classes