| | |
JAVA GUI Prob: Components only appear when frame edge clicked.
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
This is really frustrating.
Whenever I run this, a blank window frame appears
The components only appear when I click the edge of the frame.
Please check if I did something wrong:
Thank you.
Whenever I run this, a blank window frame appears
The components only appear when I click the edge of the frame.
Please check if I did something wrong:
Java Syntax (Toggle Plain Text)
import javax.swing.*; import java.awt.*; /** * */ public class FFGen{ public void First(){ /** * @param args */ JLabel pleaseChooseFFType; String[] FlipflopTypes = {"JK", "RS", "D", "T"};; JList FlipflopList; JLabel pleaseChooseFFNum; ButtonGroup FlipflopNumberGroup; JRadioButtonMenuItem oneFlipflop; JRadioButtonMenuItem twoFlipflop; JLabel pleaseCheck; JCheckBox oneInput; JCheckBox oneOutput; JButton next; JFrame first; JPanel firstConLeft; JPanel firstConRight; FlipflopList = new JList(FlipflopTypes); FlipflopList.setVisibleRowCount(1); JScrollPane scroller = new JScrollPane(FlipflopList); pleaseChooseFFType = new JLabel("Type of Flipflop:"); oneFlipflop = new JRadioButtonMenuItem ("1"); twoFlipflop = new JRadioButtonMenuItem ("2"); pleaseChooseFFNum = new JLabel("Number of Flipflops:"); FlipflopNumberGroup = new ButtonGroup(); FlipflopNumberGroup.add(oneFlipflop); FlipflopNumberGroup.add(twoFlipflop); pleaseCheck = new JLabel("There is an:"); oneInput = new JCheckBox ("Input"); oneOutput = new JCheckBox ("Output"); next = new JButton ("Next"); first = new JFrame(); first.setSize(250,235); first.setVisible(true); firstConLeft = new JPanel(); firstConRight = new JPanel(); firstConRight.setLayout(new GridLayout(9,1,0,0)); firstConRight.add(pleaseChooseFFType); firstConRight.add(scroller); firstConRight.add(pleaseChooseFFNum); firstConRight.add(oneFlipflop); firstConRight.add(twoFlipflop); firstConRight.add(pleaseCheck); firstConRight.add(oneInput); firstConRight.add(oneOutput); firstConRight.add(next); JPanel Empty = new JPanel(); Empty.setLayout(new GridLayout(1,2)); Empty.add(firstConLeft); Empty.add(firstConRight); first.add(Empty); } public static void main(String[] args) { // TODO Auto-generated method stub FFGen gui = new FFGen(); gui.First(); } }
Thank you.
•
•
Join Date: Jan 2008
Posts: 3,833
Reputation:
Solved Threads: 503
It shows up correctly for me without having to click anything. Often, if you need to click, move, resize, or maximize/minimize something for it to show up, you can solve it by using the validate () from the Container class.
http://java.sun.com/javase/6/docs/ap...html#validate()
But again, I did not have to do this. I was able to see your GUI without doing anything.
http://java.sun.com/javase/6/docs/ap...html#validate()
But again, I did not have to do this. I was able to see your GUI without doing anything.
•
•
•
•
It shows up correctly for me without having to click anything. Often, if you need to click, move, resize, or maximize/minimize something for it to show up, you can solve it by using the validate () from the Container class.
http://java.sun.com/javase/6/docs/ap...html#validate()
But again, I did not have to do this. I was able to see your GUI without doing anything.
Thanks.. I'll try that now.
•
•
Join Date: Nov 2008
Posts: 332
Reputation:
Solved Threads: 54
Based on the swing Sun example:
Write constructor for FFGen:
Under Windows XP I have no problem. Same as VernonDozier.
What is your Operating System?
java Syntax (Toggle Plain Text)
public static void main(String[] args) { //Schedule a job for the event-dispatching thread: //creating and showing this application's GUI. javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { //FFGen gui = new FFGen(); new FFGen(); } }); }
java Syntax (Toggle Plain Text)
public FFGen() { First(); }
What is your Operating System?
•
•
•
•
based on the swing sun example:
write constructor for ffgen:java Syntax (Toggle Plain Text)
public static void main(string[] args) { //schedule a job for the event-dispatching thread: //creating and showing this application's gui. Javax.swing.swingutilities.invokelater(new runnable() { public void run() { //ffgen gui = new ffgen(); new ffgen(); } }); }
under windows xp i have no problem. Same as vernondozier.java Syntax (Toggle Plain Text)
public ffgen() { first(); }
What is your operating system?
I really can't understand why that happens.i've done other gui interfaces before and they run just fine.
But i just can't figure this one out.
I asked a friend of mine to run it in his computer, and he gets the same result as mine.
•
•
Join Date: Jan 2008
Posts: 3,833
Reputation:
Solved Threads: 503
Did adding validate () not do anything?
Try moving lines 57 and 58 from where they are to the BOTTOM of the function. Then add:
at the very bottom of the function. See if that makes a difference. I'm not sure it will, but it's worth a shot.
Try moving lines 57 and 58 from where they are to the BOTTOM of the function. Then add:
Java Syntax (Toggle Plain Text)
first.validate ();
at the very bottom of the function. See if that makes a difference. I'm not sure it will, but it's worth a shot.
•
•
•
•
Did adding validate () not do anything?
Try moving lines 57 and 58 from where they are to the BOTTOM of the function. Then add:
Java Syntax (Toggle Plain Text)
first.validate ();
at the very bottom of the function. See if that makes a difference. I'm not sure it will, but it's worth a shot.
0__0 Thanks. It worked!
Thank you.. >(~__~)<
![]() |
Similar Threads
- Help - Basic Java GUI problem (Java)
- Java GUI Creation (Java)
- How to? Java GUI interacting with another Java class (Java)
- Java GUI Run Error (Java)
- Display an image using java GUI (Java)
- Help with placing images in Java GUI (Java)
- Java / GUI Developer Needed (UK) (Software Development Job Offers)
- java gui libraries (Java)
- two Java GUI problems - please help (Java)
Other Threads in the Java Forum
- Previous Thread: AODV routing algorithm
- Next Thread: insert coding in java
| Thread Tools | Search this Thread |
Tag cloud for gui, java
.net addressbook ajax apple applet array asp automation beginner binary block browser busy_handler(null) c++ card character class classes client code collision compile compiler component convert database design development draw eclipse embedded error event examples firefox forms fractal game givemetehcodez google grails gui html image input integer java javadesktopapplications javafx javascript jetbrains jmf jni jsp julia jvm lego linux loop looping main method methods microsoft myaggfun mysql netbeans newbie numbers osx php problem programming project projectideas pyglet python rsa se search security server set socket software sort sortedmaps string sun swing test thread threads time tree virtualization web websphere windows wxpython







