Solved

How do I output GUI?

Posted on 2004-10-31
177 Views
Last Modified: 2010-03-31
I'm wondering how do I get the output to show on the screen?  I run this in JBuilder and nothing happens.  Please help!  Thanks!


import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.*;

public class Program4  {
  public static void main(String[] args) {

    JLabel JLString1, JLString2, JLResults;
    JTextField JTFString1, JTFString2, JTFResults;
    JButton JBCompare, JBClear;
    JPanel Panel;
    String output = "";

    JLString1 = new JLabel("First String: ");
    JLString2 = new JLabel("Second String: ");
    JLResults = new JLabel("Results: ");
    JBCompare = new JButton("Compare Strings");
    JBClear = new JButton("Clear");
    JTFString1 = new JTextField(20);
    JTFString2 = new JTextField(20);
    JTFResults = new JTextField(30);
    Panel = new JPanel();

    JTFResults.setEditable(false);
    JTFString1.requestFocus();

    Panel.add(JLString1);
    Panel.add(JTFString1);
    Panel.add(JLString2);
    Panel.add(JTFString2);
    Panel.add(JBCompare);
    Panel.add(JBClear);
    Panel.add(JLResults);
    Panel.add(JTFResults);

    String String1 = JTFString1.getText();
    String String2 = JTFString2.getText();

  }
}
0
Question by:Job4Suprmn
    5 Comments
     
    LVL 6

    Expert Comment

    by:expertmb
    put the panel in jduailo or jframe then call setVisible(true)
    0
     
    LVL 6

    Expert Comment

    by:expertmb
    jduailo should be jdialog.
    0
     
    LVL 6

    Accepted Solution

    by:
       JFrame frame = new JFrame();
        frame.getContentPane().add(Panel);
        frame.setSize(400,400);
        frame.setVisible(true);
    0
     

    Author Comment

    by:Job4Suprmn
    That worked, thanks!  Here are your points.
    0
     
    LVL 6

    Expert Comment

    by:expertmb
    :)
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Learn The Basics of Ethical Hacking & Pen Testing

    Computer and network security is one of the fastest growing and most essential industries in technology, meaning companies will pay big bucks for ethical hackers. This is the perfect course to leap into this lucrative career, learning how to use ethical hacking to reveal ...

    Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
    Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
    Video by: Michael
    Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    934 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now