Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My code builds but wont display the GUI when I run it. Main Project TipCalculator Tab of coding: /* * To change this license header,

My code builds but wont display the GUI when I run it.

image text in transcribed

Main Project "TipCalculator" Tab of coding:

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package tip.calculator;

/** * * @author Jacob */ public class TipCalculator {

/** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here } }

NewJFrame Tab of coding:

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */

/** * * @author Jacob */ public class NewJFrame extends javax.swing.JFrame {

/** * Creates new form NewJFrame */ public NewJFrame() { initComponents(); }

/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // private void initComponents() {

jScrollPane1 = new javax.swing.JScrollPane(); jTextPane1 = new javax.swing.JTextPane(); jPopupMenu1 = new javax.swing.JPopupMenu(); jFrame1 = new javax.swing.JFrame(); jFrame2 = new javax.swing.JFrame(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); CalculateTip = new javax.swing.JButton(); SubtotalTF = new javax.swing.JTextField(); TIPTF = new javax.swing.JTextField(); Exit = new javax.swing.JButton(); jInternalFrame1 = new javax.swing.JInternalFrame(); jLabel3 = new javax.swing.JLabel();

jScrollPane1.setViewportView(jTextPane1);

javax.swing.GroupLayout jFrame1Layout = new javax.swing.GroupLayout(jFrame1.getContentPane()); jFrame1.getContentPane().setLayout(jFrame1Layout); jFrame1Layout.setHorizontalGroup( jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 400, Short.MAX_VALUE) ); jFrame1Layout.setVerticalGroup( jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 300, Short.MAX_VALUE) );

javax.swing.GroupLayout jFrame2Layout = new javax.swing.GroupLayout(jFrame2.getContentPane()); jFrame2.getContentPane().setLayout(jFrame2Layout); jFrame2Layout.setHorizontalGroup( jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 400, Short.MAX_VALUE) ); jFrame2Layout.setVerticalGroup( jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 300, Short.MAX_VALUE) );

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

jLabel1.setText("Enter the restaurant bill:"); getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(47, 166, -1, -1));

jLabel2.setText("Tip your server:"); getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(47, 214, -1, -1));

CalculateTip.setText("Calculate Tip"); CalculateTip.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { CalculateTipActionPerformed(evt); } }); getContentPane().add(CalculateTip, new org.netbeans.lib.awtextra.AbsoluteConstraints(276, 246, -1, -1));

SubtotalTF.setEditable(false); SubtotalTF.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SubtotalTFActionPerformed(evt); } }); getContentPane().add(SubtotalTF, new org.netbeans.lib.awtextra.AbsoluteConstraints(216, 163, 153, -1));

TIPTF.setEditable(false); TIPTF.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { TIPTFActionPerformed(evt); } }); getContentPane().add(TIPTF, new org.netbeans.lib.awtextra.AbsoluteConstraints(216, 208, 153, -1));

Exit.setText("Exit"); Exit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ExitActionPerformed(evt); } }); getContentPane().add(Exit, new org.netbeans.lib.awtextra.AbsoluteConstraints(219, 246, -1, -1));

jInternalFrame1.setVisible(true);

jLabel3.setFont(new java.awt.Font("Harlow Solid Italic", 0, 24)); // NOI18N jLabel3.setText("Tip Calculator By Jacob Stedman");

javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane()); jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout); jInternalFrame1Layout.setHorizontalGroup( jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jInternalFrame1Layout.createSequentialGroup() .addContainerGap(127, Short.MAX_VALUE) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 369, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(55, 55, 55)) ); jInternalFrame1Layout.setVerticalGroup( jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jInternalFrame1Layout.createSequentialGroup() .addGap(0, 24, Short.MAX_VALUE) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)) );

getContentPane().add(jInternalFrame1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

pack(); }//

private void SubtotalTFActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }

private void ExitActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: System.exit(0); }

private void CalculateTipActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }

private void TIPTFActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: double a=Double.parseDouble(SubtotalTF.getText()); double tip=0.15*a; TIPTF.setText(String.valueOf(tip)); }

/** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ // /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //

/* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new NewJFrame().setVisible(true); } }); }

// Variables declaration - do not modify private javax.swing.JButton CalculateTip; private javax.swing.JButton Exit; private javax.swing.JTextField SubtotalTF; private javax.swing.JTextField TIPTF; private javax.swing.JFrame jFrame1; private javax.swing.JFrame jFrame2; private javax.swing.JInternalFrame jInternalFrame1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JPopupMenu jPopupMenu1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextPane jTextPane1; // End of variables declaration }

.default config> kdefault cfi> > X> . (. Start Page x TpCalculator.java x|ESNewJFrame.java x Hstory !! To change this license header, choose License Headers in Project Properties To change this templace file, choose ToolsI Templates and open the template in the editor ackage tip.calculator; 10 eauthor Jacob 12 public class TipCalculator 13 14 15 16 17| public static void main (String[] args) { 18 19 ublic class Tiaiu param param args argumentS TOD0 code application logic here

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

Evaluate three pros and three cons of e-prescribing

Answered: 1 week ago

Question

Know how to use reservations systems to inventory demand.

Answered: 1 week ago