I created a [PRODUCT FORM] with no errors after compilation yet it is not visible. Can anyone help?
[Commented area of showProduct is where i tried to create the form] - import javax.swing.*;
-
import java.awt.*;
-
import java.awt.event.*;
-
import javax.swing.JFrame;
-
-
public class Bookshop extends JFrame implements ActionListener
-
{
-
//JFrame product = new JFrame();
-
JTextField productIdText;
-
JTextField productNameText;
-
JTextField productCostText;
-
JTextField productyearOfPublicationText;
-
JTextField productpublishingHouseText;
-
-
JButton submit;
-
Product [] productList = new Product [100];
-
int numberOfProduct = 0;
-
-
-
public void showProduct(int productId,String productName,double cost,int yearOfPublication,String publishingHouse)
-
{
-
//
-
//
-
// //JFrame product = new JFrame("PRODUCT");
-
// setSize(400,400);
-
// setLayout(null);
-
//
-
// productIdText = new JTextField(5);
-
// productIdText.setSize(80,30);
-
// productIdText.setLocation(100,0);
-
//
-
// add(productIdText);
-
//
-
// productNameText = new JTextField(5);
-
// productNameText.setSize(80,30);
-
// productNameText.setLocation(101,30);
-
// add(productNameText);
-
//
-
// productCostText = new JTextField(5);
-
// productCostText.setSize(80,30);
-
// productCostText.setLocation(131,31);
-
// add(productCostText);
-
//
-
// productyearOfPublicationText = new JTextField(5);
-
// productyearOfPublicationText.setSize(80,30);
-
// productyearOfPublicationText.setLocation(161,61);
-
// add(productyearOfPublicationText);
-
//
-
// productpublishingHouseText = new JTextField(5);
-
// productpublishingHouseText.setSize(80,30);
-
// productpublishingHouseText.setLocation(191,91);
-
// add(productpublishingHouseText);
-
//
-
// submit = new JButton("click");
-
// submit.addActionListener(this);
-
// add(submit);
-
// //getContentPane().add(product);
-
//
-
// setVisible(true);
-
// }
-
-
public void actionPerformed(ActionEvent e)
-
{
-
if(e.getSource() == submit)
-
{
-
int id = Integer.parseInt(productIdText.getText());
-
String name = productNameText.getText();
-
double cost = Double.parseDouble(productCostText.getText());
-
int yearOfPublication = Integer.parseInt(productyearOfPublicationText.getText());
-
String publishingHouse = productpublishingHouseText.getText();
-
//System.out.println();
-
//System.out.println();
-
-
-
productList[numberOfProduct] = new Product(id,name,cost,yearOfPublication,publishingHouse);
-
numberOfProduct++;
-
}
-
-
}
-
-
public static void main(String []args)
-
{
-
new Bookshop();
-
}
-
-
class Product
-
{
-
private int productId;
-
private String productName;
-
private double cost;
-
private int yearOfPublication;
-
private String publishingHouse;
-
-
-
public Product(int productId,String productName,double cost,int yearOfPublication,String publishingHouse)
-
{
-
this.productId = productId;
-
this.productName = productName;
-
this.cost = cost;
-
this.yearOfPublication = yearOfPublication;
-
this.publishingHouse = publishingHouse;
-
-
-
}
-
-
public void setSize(int x,int y)
-
{
-
}
-
-
public void setproductIdText(int productIdText)
-
{
-
}
-
-
public void setproductNameText(String productNameText)
-
{
-
}
-
-
public void setId(int productId)
-
{
-
}
-
-
public int getproductId()
-
{
-
return productId;
-
}
-
public void setproductName(String productName)
-
{
-
this.productName = productName;
-
}
-
-
public String getproductName()
-
{
-
return productName;
-
}
-
-
public void setcost(double cost)
-
{
-
this.cost = cost;
-
}
-
-
public double getcost()
-
{
-
return cost;
-
}
-
-
public void setyearOfPublication(int yearOfPublication)
-
{
-
this.yearOfPublication = yearOfPublication;
-
}
-
-
public int getyearOfPublication()
-
{
-
return yearOfPublication;
-
}
-
-
public void setpublishingHouse(String publishingHouse)
-
{
-
this.publishingHouse = publishingHouse;
-
}
-
-
public String getpublishingHouse()
-
{
-
return publishingHouse;
-
}
-
}
-
-
class Book extends Product
-
{
-
private String author;
-
private int isbn;
-
private int numberOfPages;
-
-
-
public Book(String author, int isbn, int numberOfPages, int productId, String productName, double cost,
-
int yearOfPublication, String publishingHouse)
-
{
-
super(productId,productName,cost,yearOfPublication,publishingHouse);
-
this.author = author;
-
this.isbn = isbn;
-
this.numberOfPages = numberOfPages;
-
}
-
}
-
-
class Software extends Product
-
{
-
private int ram;
-
private int processor;
-
-
-
-
public Software(int ram,int processor,int productId, String productName, double cost,
-
int yearOfPublication, String publishingHouse)
-
{
-
super(productId,productName,cost,yearOfPublication,publishingHouse);
-
this.ram = ram;
-
this.processor = processor;
-
}
-
-
}
-
}
-
-
I attached a picture copy of the form section. Thanks
Hi,
Form is now Visible, Please make sure your components inside the JFrame are aligned. Its not aligned properly. Please find the below Code -
-
import javax.swing.*;
-
import java.awt.*;
-
import java.awt.event.*;
-
import javax.swing.JFrame;
-
-
public class Bookshop extends JFrame implements ActionListener {
-
// JFrame product = new JFrame();
-
JTextField productIdText;
-
JTextField productNameText;
-
JTextField productCostText;
-
JTextField productyearOfPublicationText;
-
JTextField productpublishingHouseText;
-
-
JButton submit;
-
Product[] productList = new Product[100];
-
int numberOfProduct = 0;
-
-
public Bookshop() {
-
-
-
//JFrame product = new JFrame("PRODUCT");
-
setSize(400,400);
-
setLayout(null);
-
-
productIdText = new JTextField(5);
-
productIdText.setSize(80,30);
-
productIdText.setLocation(100,0);
-
-
add(productIdText);
-
-
productNameText = new JTextField(5);
-
productNameText.setSize(80,30);
-
productNameText.setLocation(101,30);
-
add(productNameText);
-
-
productCostText = new JTextField(5);
-
productCostText.setSize(80,30);
-
productCostText.setLocation(131,31);
-
add(productCostText);
-
-
productyearOfPublicationText = new JTextField(5);
-
productyearOfPublicationText.setSize(80,30);
-
productyearOfPublicationText.setLocation(161,61);
-
add(productyearOfPublicationText);
-
-
productpublishingHouseText = new JTextField(5);
-
productpublishingHouseText.setSize(80,30);
-
productpublishingHouseText.setLocation(191,91);
-
add(productpublishingHouseText);
-
-
submit = new JButton("click");
-
submit.addActionListener(this);
-
add(submit);
-
//getContentPane().add(product);
-
-
setVisible(true);
-
}
-
-
public void actionPerformed(ActionEvent e) {
-
if (e.getSource() == submit) {
-
int id = Integer.parseInt(productIdText.getText());
-
String name = productNameText.getText();
-
double cost = Double.parseDouble(productCostText.getText());
-
int yearOfPublication = Integer
-
.parseInt(productyearOfPublicationText.getText());
-
String publishingHouse = productpublishingHouseText.getText();
-
// System.out.println();
-
// System.out.println();
-
-
productList[numberOfProduct] = new Product(id, name, cost,
-
yearOfPublication, publishingHouse);
-
numberOfProduct++;
-
}
-
-
}
-
-
public static void main(String[] args) {
-
new Bookshop();
-
}
-
-
class Product {
-
private int productId;
-
private String productName;
-
private double cost;
-
private int yearOfPublication;
-
private String publishingHouse;
-
-
public Product(int productId, String productName, double cost,
-
int yearOfPublication, String publishingHouse) {
-
this.productId = productId;
-
this.productName = productName;
-
this.cost = cost;
-
this.yearOfPublication = yearOfPublication;
-
this.publishingHouse = publishingHouse;
-
-
}
-
-
public void setSize(int x, int y) {
-
}
-
-
public void setproductIdText(int productIdText) {
-
}
-
-
public void setproductNameText(String productNameText) {
-
}
-
-
public void setId(int productId) {
-
}
-
-
public int getproductId() {
-
return productId;
-
}
-
-
public void setproductName(String productName) {
-
this.productName = productName;
-
}
-
-
public String getproductName() {
-
return productName;
-
}
-
-
public void setcost(double cost) {
-
this.cost = cost;
-
}
-
-
public double getcost() {
-
return cost;
-
}
-
-
public void setyearOfPublication(int yearOfPublication) {
-
this.yearOfPublication = yearOfPublication;
-
}
-
-
public int getyearOfPublication() {
-
return yearOfPublication;
-
}
-
-
public void setpublishingHouse(String publishingHouse) {
-
this.publishingHouse = publishingHouse;
-
}
-
-
public String getpublishingHouse() {
-
return publishingHouse;
-
}
-
}
-
-
class Book extends Product {
-
private String author;
-
private int isbn;
-
private int numberOfPages;
-
-
public Book(String author, int isbn, int numberOfPages, int productId,
-
String productName, double cost, int yearOfPublication,
-
String publishingHouse) {
-
super(productId, productName, cost, yearOfPublication,
-
publishingHouse);
-
this.author = author;
-
this.isbn = isbn;
-
this.numberOfPages = numberOfPages;
-
}
-
}
-
-
class Software extends Product {
-
private int ram;
-
private int processor;
-
-
public Software(int ram, int processor, int productId,
-
String productName, double cost, int yearOfPublication,
-
String publishingHouse) {
-
super(productId, productName, cost, yearOfPublication,
-
publishingHouse);
-
this.ram = ram;
-
this.processor = processor;
-
}
-
-
}
-
}
-
-
Thanks
Raju
1 1373
Hi,
Form is now Visible, Please make sure your components inside the JFrame are aligned. Its not aligned properly. Please find the below Code -
-
import javax.swing.*;
-
import java.awt.*;
-
import java.awt.event.*;
-
import javax.swing.JFrame;
-
-
public class Bookshop extends JFrame implements ActionListener {
-
// JFrame product = new JFrame();
-
JTextField productIdText;
-
JTextField productNameText;
-
JTextField productCostText;
-
JTextField productyearOfPublicationText;
-
JTextField productpublishingHouseText;
-
-
JButton submit;
-
Product[] productList = new Product[100];
-
int numberOfProduct = 0;
-
-
public Bookshop() {
-
-
-
//JFrame product = new JFrame("PRODUCT");
-
setSize(400,400);
-
setLayout(null);
-
-
productIdText = new JTextField(5);
-
productIdText.setSize(80,30);
-
productIdText.setLocation(100,0);
-
-
add(productIdText);
-
-
productNameText = new JTextField(5);
-
productNameText.setSize(80,30);
-
productNameText.setLocation(101,30);
-
add(productNameText);
-
-
productCostText = new JTextField(5);
-
productCostText.setSize(80,30);
-
productCostText.setLocation(131,31);
-
add(productCostText);
-
-
productyearOfPublicationText = new JTextField(5);
-
productyearOfPublicationText.setSize(80,30);
-
productyearOfPublicationText.setLocation(161,61);
-
add(productyearOfPublicationText);
-
-
productpublishingHouseText = new JTextField(5);
-
productpublishingHouseText.setSize(80,30);
-
productpublishingHouseText.setLocation(191,91);
-
add(productpublishingHouseText);
-
-
submit = new JButton("click");
-
submit.addActionListener(this);
-
add(submit);
-
//getContentPane().add(product);
-
-
setVisible(true);
-
}
-
-
public void actionPerformed(ActionEvent e) {
-
if (e.getSource() == submit) {
-
int id = Integer.parseInt(productIdText.getText());
-
String name = productNameText.getText();
-
double cost = Double.parseDouble(productCostText.getText());
-
int yearOfPublication = Integer
-
.parseInt(productyearOfPublicationText.getText());
-
String publishingHouse = productpublishingHouseText.getText();
-
// System.out.println();
-
// System.out.println();
-
-
productList[numberOfProduct] = new Product(id, name, cost,
-
yearOfPublication, publishingHouse);
-
numberOfProduct++;
-
}
-
-
}
-
-
public static void main(String[] args) {
-
new Bookshop();
-
}
-
-
class Product {
-
private int productId;
-
private String productName;
-
private double cost;
-
private int yearOfPublication;
-
private String publishingHouse;
-
-
public Product(int productId, String productName, double cost,
-
int yearOfPublication, String publishingHouse) {
-
this.productId = productId;
-
this.productName = productName;
-
this.cost = cost;
-
this.yearOfPublication = yearOfPublication;
-
this.publishingHouse = publishingHouse;
-
-
}
-
-
public void setSize(int x, int y) {
-
}
-
-
public void setproductIdText(int productIdText) {
-
}
-
-
public void setproductNameText(String productNameText) {
-
}
-
-
public void setId(int productId) {
-
}
-
-
public int getproductId() {
-
return productId;
-
}
-
-
public void setproductName(String productName) {
-
this.productName = productName;
-
}
-
-
public String getproductName() {
-
return productName;
-
}
-
-
public void setcost(double cost) {
-
this.cost = cost;
-
}
-
-
public double getcost() {
-
return cost;
-
}
-
-
public void setyearOfPublication(int yearOfPublication) {
-
this.yearOfPublication = yearOfPublication;
-
}
-
-
public int getyearOfPublication() {
-
return yearOfPublication;
-
}
-
-
public void setpublishingHouse(String publishingHouse) {
-
this.publishingHouse = publishingHouse;
-
}
-
-
public String getpublishingHouse() {
-
return publishingHouse;
-
}
-
}
-
-
class Book extends Product {
-
private String author;
-
private int isbn;
-
private int numberOfPages;
-
-
public Book(String author, int isbn, int numberOfPages, int productId,
-
String productName, double cost, int yearOfPublication,
-
String publishingHouse) {
-
super(productId, productName, cost, yearOfPublication,
-
publishingHouse);
-
this.author = author;
-
this.isbn = isbn;
-
this.numberOfPages = numberOfPages;
-
}
-
}
-
-
class Software extends Product {
-
private int ram;
-
private int processor;
-
-
public Software(int ram, int processor, int productId,
-
String productName, double cost, int yearOfPublication,
-
String publishingHouse) {
-
super(productId, productName, cost, yearOfPublication,
-
publishingHouse);
-
this.ram = ram;
-
this.processor = processor;
-
}
-
-
}
-
}
-
-
Thanks
Raju
Sign in to post your reply or Sign up for a free account.
Similar topics
by: genetic.error |
last post by:
I'm moving from Vb6 to VB.Net. I have a feeling this has come up
before...
The VS.Net MSDN file seems to state that the following should work:
Form1.Show
Form1.Visible = True
Form1.Hide...
|
by: vooose |
last post by:
How would you determine if a window(Form) is visible. By visible I mean
that you can currently see it, as apposed to Form.Visible. (which
returns True when the window sits behind other windows)
...
|
by: abdul bari |
last post by:
Hi
I have a standard html form which is generated by an XSL sheet. The
form data is submitted to the server and is passed on to file.aspx for
processing. However file.aspx is refreshed every 5...
|
by: Shippy |
last post by:
Please help, this is doing my head in!!!! I am sure it is something
really simple and ovbious that I am missing but for the life of me I
cant find where!!!
I have this function...
<script>...
|
by: |
last post by:
How can i make my form invisible
public class Form1 : System.Windows.Forms.Form
static void Main()
{
|
by: ConfusedMay |
last post by:
I have a form that content all sales. Right now the default view is single form. the problem is that I can't view the form as a datasheet view when I run the form, even I already specified on the...
|
by: clloyd |
last post by:
I have a form that opens with an embedded subform visible for data entry of new data only. The form is based of a select query so I can show data from multiple tables for verification but the sub...
|
by: Daniel B |
last post by:
I would like to create a form, with a subform that shows data from several tables. Then I would like to be able to somehow click on one line of data, and it will take you to another form showing only...
|
by: lenniekuah |
last post by:
Hi Good Guys,
I have an interesting problem and I need your help.
Please Help me.
Requested were made by Businese Analyst to set the few Main FORMs VISIBLE PROPERTY TO FALSE when the POPUP FORM...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |