NOR
how to do gui
2 Answer(s)      a year and 7 months ago
Posted in : Java Beginners

import java.util.Scanner; import javax.swing.JFrame; import javax.swing.JOptionPane;

public class ShippingCost {

public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    JFrame frame = new JFrame();


    String itemName = "";
    double weight = 0.0;
    double firstKg = 10.0;
    double nextKg = 5.0;
    double num1 = 0.0;

    //itemName = JOptionPane.showInputDialog(frame, "Enter item name:");
    //weight = Double.parseDouble(JOptionPane.showInputDialog(frame, "Enter item weight:"));

    System.out.println("Please insert item name : ");
    itemName = sc.next();
    System.out.println("Please insert weight : ");
    weight = sc.nextDouble();

    if(weight <= 1.0){
        System.out.println("Your shipping cost is RM" + firstKg );
    }else {
        weight = weight - 1;
        num1 = weight * nextKg;
        num1 = firstKg + num1;
        System.out.println("Your shipping cost is RM" + num1);

    }
}

}

how to do gui for this coding..tq

View Answers

October 20, 2011 at 11:25 AM


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

public class ShippingCost {

public static void main(String[] args){

JFrame f=new JFrame();
JLabel lab1=new JLabel("Enter Item Name: ");
JLabel lab2=new JLabel("Enter Weight: ");
final JTextField text1=new JTextField(20);
final JTextField text2=new JTextField(20);
JPanel p=new JPanel(new GridLayout(3,2));
JButton b=new JButton("Find");

p.add(lab1);
p.add(text1);
p.add(lab2);
p.add(text2);
p.add(b);
b.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
String itemName = text1.getText();
    double weight = Double.parseDouble(text2.getText());
    double firstKg = 10.0;
    double nextKg = 5.0;
    double num1 = 0.0;

    if(weight <= 1.0){
        System.out.println("Your shipping cost is RM" + firstKg );
    }else {
        weight = weight - 1;
        num1 = weight * nextKg;
        num1 = firstKg + num1;
        System.out.println("Your shipping cost is RM" + num1);
    }
    }
});
    f.add(p);
    f.setVisible(true);
    f.setSize(300,100);
    }
}

October 20, 2011 at 11:46 AM


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

public class ShippingCost {

public static void main(String[] args){

JFrame f=new JFrame();
JLabel lab1=new JLabel("Enter Item Name: ");
JLabel lab2=new JLabel("Enter Weight: ");
final JTextField text1=new JTextField(20);
final JTextField text2=new JTextField(20);
JPanel p=new JPanel(new GridLayout(3,2));
JButton b=new JButton("Find");

p.add(lab1);
p.add(text1);
p.add(lab2);
p.add(text2);
p.add(b);
b.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
String itemName = text1.getText();
    double weight = Double.parseDouble(text2.getText());
    double firstKg = 10.0;
    double nextKg = 5.0;
    double num1 = 0.0;

    if(weight <= 1.0){
        JOptionPane.showMessageDialog(null,"Your shipping cost is RM" + firstKg );
    }else {
        weight = weight - 1;
        num1 = weight * nextKg;
        num1 = firstKg + num1;
        JOptionPane.showMessageDialog(null,"Your shipping cost is RM" + num1);
    }
    }
});
    f.add(p);
    f.setVisible(true);
    f.setSize(300,100);
    }
}









Related Pages:
how to do gui
is RM" + num1); } } } how to do gui for this coding..tq   import...how to do gui  import java.util.Scanner; import javax.swing.JFrame; import javax.swing.JOptionPane; public class ShippingCost { public static void
GUI
GUI  How to GUI in Net-beans ... ??   Please visit the following link: http://www.roseindia.net/java/java-tips/background/30java_tools/netbeans.shtml
GUI problem
GUI problem  How do I make a Jbutton which is shaped like a circle. This button needs to be clicked in order to change color.   import java.awt.*; import java.awt.geom.*; import javax.swing.*; public class
Gui Interface - Java Beginners
Gui Interface  hi I have two seperate interfaces in the same projects . my question is how can I access this interface using a jbutton (i.e... I have to do to make this work? Thanks again  JFrame frame2 = new
GUI Alternatives
the GUI interface processing from the logic. This is easy to do by putting... how to connect the GUI to a Java application. Seems..., it isn't difficult to build a Graphical User Interface (GUI) in Java, but it is hard
Rationale for GUI tutorial decisions
Table of Contents Rationale for GUI tutorial decisions Java offers many... learn GUI programming? All "normal" programs are GUI based, so this question... that some Java textbooks are written without any GUI coverage, and others cover
Java GUI - Applet
JFrame and make GUI structure by draging buttons and labels, now i want to insert image on left corner JLable. how thats possible?  Hi friend, Code...); } }); } // Variables declaration - do not modify private
GUI framework
GUI framework  what do u mean by GUI framework
GUI - Java Beginners
GUI  How do i make these buttons work? Update, Delete, Save, Submit, Clear,Turn off,Canel, Log off,Close, Add new, First, previous, Next, Last,Print. Send me the code please.  Hi Friend, Please visit the following
java gui database - Java Beginners
the data on command line but I do not know how to display the same using java gui. Could anybody help me. Thanks. Shah...java gui database  I have eight files. Each file has exactly same
GUI component
GUI component  How can a GUI component handle its own events
how to do this?
how to do this?   Given any integer 2D array, design then implement a Java program that will add to each element in the array the corresponding column number and the corresponding row number. Then, it prints the array before
Serializing GUI Components Across Network - tutorial
careful that we do not read from the GUI components or write to them from any... to show you how to do an asynchronous serialization of components via another...Serializing GUI Components Across Network 2001-03-14 The Java Specialists
how to refresh my GUI page
how to refresh my GUI page  how to refresh a GUI in java
java gui
java gui   friends... good day.. i have doubt in java gui. ? i created 1 java gui application. That has two text fields jtext1,jtext2. case: user... must go to the next text field(jtext2). How can i arrange this. which code can i
how to do an measure converter in netbeans - Java Beginners
how to do an measure converter in netbeans   hi im not sure... information on joptionpane visit to : http://www.roseindia.net/java/java-tips/GUI.../GUI/containers/20dialogs/10joptionpane-2.shtml http://www.roseindia.net
turn the GUI(java class) into XML - XML
requirement.I don't know how can I do that please give me solution.It is urgent...turn the GUI(java class) into XML   Hi im trying to turn the GUI(java class) into XML ,means in my gui one combobox is there if i select one
Programming - Transform Name - GUI 0
Java: Programming - Transform Name - GUI 0 Write a GUI program... the maximum score on this problem, however if you do extra work, it can cancel... Maus, Michael Write answer below here and on back. Show how the window appears
Java GUI problem with linklists and administration - Java Beginners
of a person. If possible, please show me a sample code on how to do it, the data can...Java GUI problem with linklists and administration  Hi, I'm having trouble making a GUI interface in java, where a list of names are displayed using
Catching Exceptions in GUI Code - Java Tutorials
.style1 { text-align: center; } Catching uncaught exception in GUI In this section, we will discuss how to catch uncaught exceptions in GUI. Lets see... javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; public class Gui
Convert the code to GUI
How to Convert the code to GUI   How to convert a code into GUI
HOW TO CONVERT THIS CODE INTO GUI
HOW TO CONVERT THIS CODE INTO GUI   System.out.println("\n\t UGANDA CHRISTIAN UNIVERSITY\n"); System.out.println("\n\tFACULTY OF SCIENCE AND TECHNOLOGY\n"); System.out.println("\n BACHELOR OF SCIENCE IN COMPUTER
Convert the code to GUI
How to create GUI application in Java   How to create GUI application in Java
Netbeans GUI Ribbon
Netbeans GUI Ribbon  how to create ribbon task in java GUI using netbeans
Java GUI - Java Beginners
Java GUI  HOW TO ADD ICONS IN JAVA GUI PROGRAMMES
Convert the code to GUI
Convert the code   How to convert a code to GUI look alike
how to connect mysql from gui?
how to connect mysql from gui?  i am unable to connet to mysql server from my projet that is gui for mysql...can anyone help me in this...its urgent? i have to connet to mysql from gui..   Hi Friend, Try the following
GUI Interface .Reply me with in hour..Its Urgent - Java Beginners
have to create GUI Interace ..How should i create the Interface. In Existing project - contains , encryption & Decryption..what i have to do is...To create...GUI Interface .Reply me with in hour..Its Urgent  Hi ... Now i am
how to do this - JavaMail
how to do this  i have created three HTMl documents. i want to display three HTML documents combinely with in a single frame. can i save 3 HTMl combinely as single JSP.If combine how ? Plese send examples not only with HTML's
Regarding GUI Applications
Regarding GUI Applications  How to create a save and open jmenu item in java desktop application
Flex SDK GUI
Flex SDK GUI  Hi....... please give me ans of this question.. What classes do you typically extend in the Flex SDK for creating GUI controls and why? Thanks
GUI Tips
be separated from the GUI execution. Building the GUI Do not add... Java NotesGUI Tips [Beginning of list of GUI tips -- needs much more... to understand if it's in a separate class. main should do very little work
How to convert this Java code into GUI?
How to convert this Java code into GUI?   import java.util.Scanner; public class StudentMarks { double totalMarks; String grade; public void setTotalMarks(double totalMarks) { this.totalMarks = totalMarks
How do you define a constant?
How do you define a constant?  How do you define a constant in php
java gui-with jscroll pane
java gui-with jscroll pane  Dear friends.. I have a doubt in my gui application. I developed 1 application. In this application is 1 Jscrollpane... the window manually.....but i need this through my program...How can i show that text
java gui-with jscroll pane
java gui-with jscroll pane  Dear friends.. I have a doubt in my gui application. I developed 1 application. In this application is 1 Jscrollpane... the window manually.....but i need this through my program...How can i show that text
GUI problem - Java Beginners
GUI problem  how to write java program that use JTextField to input data and JTextField to display the output when user click Display Button??  Handle the actionPerformed event for JButton and try doing something like
How to Display Data in a tree structure on the GUI
How to Display Data in a tree structure on the GUI  how to display data in a tree structure on the GUI? I need this sort of UI to display data showing a set of rules showing various conditions and the actions related
how to save a gui form in core java
how to save a gui form in core java  please help me i am java beginner how to save a jframe containing jtable and panels in java thank you
GUI - Java Beginners
GUI testing  GUI testing in software testing  HiNow, use...; int num; do{ str_value = JOptionPane.showInputDialog(null, "...;GUI Example");pack();show();}public void actionPerformed(ActionEvent event
GUI 2 - Java Beginners
GUI 2  How can I modify this code? Please give me a GUI Example.Thanks!!  This can be done using KeyEvent in the following way... written...;GUI Example");pack();show();}public void actionPerformed(ActionEvent event
Gui plz help
Gui plz help   Create a Java application that would allow a person... would do better next time if the ratio is smaller than 70%. this is what i got so... it do only 10 questions for button1 and not able to add them so i can get answers
How can I do it? .click();
How can I do it? .click();  I have a very unusual problem. I want to make a script like this: <script> x = document.getElementById... want that it make mouseup in this element. How can I do it, because if I write
How to send from netbeans gui registration form to MySQL query browser database?
How to send from netbeans gui registration form to MySQL query browser database?  Well i have a Registration form GUI in my netbeans. in my GUI... Browser database. what code will i do? this is my existing code from my
How to send from netbeans gui registration form to MySQL query browser database?
How to send from netbeans gui registration form to MySQL query browser database?  Well i have a Registration form GUI in my netbeans. in my GUI... Browser database. what code will i do? this is my existing code from my
Regarding GUI Applications
GUI Applications  How to create a save and open jmenu item in java desktop application.   Here is a simple JMenuItem example in java swing through which you can perform open and save operations on File. import
How do i do the coding for 'leaving a comment' in java
How do i do the coding for 'leaving a comment' in java  i am designing a webpage.In my webpage i want to add the option of adding a comment by the readers of the page.how do i do
Java Gui - Java Beginners
Java Gui  HOW TO ADD LINK LABELS IN JAVA PROGRAMMES
how do i solve this problem?
how do i solve this problem?  Define a class named Circle with the following properties: List item An integer data field named radius with protected access modifier, and a String data field named colour with private access
Java GUI - Java Beginners
Java GUI  How to use JTray in java programme?  Hi friend, JTrayIcon jtc= new JTrayIcon(image); // jPopupMenu is a javax.swing.JPopupMenu jtc.setRightClickTarget(jPopupMenu); jtc.show(); Thanks

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.