The choice of JDK is stored for each BlueJ version. If you have different versions of BlueJ installed, you can use one version of BlueJ with JDK 1.4.2 and another BlueJ version with JDK 1.5. Changing the Java version for BlueJ will make this change for all BlueJ installations of the same version for the same user. Running BlueJ Examples Note: in this example, the name of the zip file to download, unzip, and run is Intro.zip. You will get a series of lines beginning with Creating. And Expanding. Telling you what the unzip program did. You should now see the folder Intro in the Examples folder. Using BlueJ to Run the Examples.
Hi Guys,
- Open up the People Project in BlueJ. Find the folder where BlueJ is installed and open the examples folder inside. On Windows, look in C: Program Files (x86) BlueJ or C: Program Files BlueJ. If you cannot find it, download a copy of examples and unzip it. Open the people folder and click on the BlueJ package.
- Below method shows how to get index of a specified character or string from the given string. By using indexOf() method you get get the position of the sepcified string or char from the given string.
I was trying to build a library catalogue with GUI (Graphic User Interface) which consists of two text boxes and four buttons.
I have actually created the layout, but I dont know how to add actions to the buttons.
Could anyone help me please.
the Question is:
for the search button which is searching for list of book that contain within their description whatever is in the description text field and/ or is currently on loan to the borrower matching the number in the borrow text field.
What I have done is as follow:
import java.util.ArrayList;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class LibraryCatalog extends JFrame
{
private ArrayList<Item> items;
JPanel contentPane;
BorderLayout borderLayout1 = new BorderLayout ();
JPanel centrePanel = new JPanel ();
JTextField titleTextField = new JTextField ();
JTextField IDTextField = new JTextField ();
JPanel southPanel = new JPanel ();
JButton addButton = new JButton ();
JPanel northPanel = new JPanel ();
JLabel northLabel = new JLabel ();
JButton searchButton = new JButton ();
JButton borrowingButton = new JButton ();
JButton returnButton = new JButton ();
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class LibraryCatalog extends JFrame
{
private ArrayList<Item> items;
JPanel contentPane;
BorderLayout borderLayout1 = new BorderLayout ();
JPanel centrePanel = new JPanel ();
JTextField titleTextField = new JTextField ();
JTextField IDTextField = new JTextField ();
JPanel southPanel = new JPanel ();
JButton addButton = new JButton ();
JPanel northPanel = new JPanel ();
JLabel northLabel = new JLabel ();
JButton searchButton = new JButton ();
JButton borrowingButton = new JButton ();
JButton returnButton = new JButton ();
Necchi silvia maximatic 586 manual dexterity. //Construct the frame
public LibraryCatalog()
{
items = new ArrayList<Item>();
makeFrame ();
setVisible (true);
public LibraryCatalog()
{
items = new ArrayList<Item>();
makeFrame ();
setVisible (true);
}
//Component initialization
private void makeFrame ()
{
contentPane = (JPanel) this.getContentPane ();
contentPane.setLayout (borderLayout1);
this.setSize (new Dimension(420, 160));
this.setTitle ('Library Catalog');
titleTextField.setText (');
titleTextField.setColumns (20);
IDTextField.setText (');
IDTextField.setColumns (16);
addButton.setText ('Add a Book');
addButton.addActionListener (new java.awt.event.ActionListener ()
{
public void actionPerformed (ActionEvent e)
{
addButton_actionPerformed (e);
}
});
northLabel.setText (');
searchButton.setText ('Search');
searchButton.addActionListener (new java.awt.event.ActionListener ()
{
public void actionPerformed(ActionEvent e)
{
searchButton_actionPerformed(e);
}
});
private void makeFrame ()
{
contentPane = (JPanel) this.getContentPane ();
contentPane.setLayout (borderLayout1);
this.setSize (new Dimension(420, 160));
this.setTitle ('Library Catalog');
titleTextField.setText (');
titleTextField.setColumns (20);
IDTextField.setText (');
IDTextField.setColumns (16);
addButton.setText ('Add a Book');
addButton.addActionListener (new java.awt.event.ActionListener ()
{
public void actionPerformed (ActionEvent e)
{
addButton_actionPerformed (e);
}
});
northLabel.setText (');
searchButton.setText ('Search');
searchButton.addActionListener (new java.awt.event.ActionListener ()
{
public void actionPerformed(ActionEvent e)
{
searchButton_actionPerformed(e);
}
});
borrowingButton.setText ('Borrowing');
borrowingButton.addActionListener (new java.awt.event.ActionListener ()
{
public void actionPerformed(ActionEvent e)
{
borrowingButton_actionPerformed(e);
}
});
borrowingButton.addActionListener (new java.awt.event.ActionListener ()
{
public void actionPerformed(ActionEvent e)
{
borrowingButton_actionPerformed(e);
}
});
returnButton.setText ('Return a Book');
returnButton.addActionListener (new java.awt.event.ActionListener ()
{
public void actionPerformed(ActionEvent e)
{
returnButton_actionPerformed(e);
}
returnButton.addActionListener (new java.awt.event.ActionListener ()
{
public void actionPerformed(ActionEvent e)
{
returnButton_actionPerformed(e);
}
});
contentPane.add(centrePanel, BorderLayout.CENTER);
centrePanel.add(titleTextField, null);
centrePanel.add(IDTextField, null);
contentPane.add(southPanel, BorderLayout.SOUTH);
southPanel.add(addButton, null);
southPanel.add(searchButton, null);
southPanel.add(borrowingButton, null);
southPanel.add(returnButton, null);
contentPane.add(northPanel, BorderLayout.NORTH);
northPanel.add(northLabel, null);
}
contentPane.add(centrePanel, BorderLayout.CENTER);
centrePanel.add(titleTextField, null);
centrePanel.add(IDTextField, null);
contentPane.add(southPanel, BorderLayout.SOUTH);
southPanel.add(addButton, null);
southPanel.add(searchButton, null);
southPanel.add(borrowingButton, null);
southPanel.add(returnButton, null);
contentPane.add(northPanel, BorderLayout.NORTH);
northPanel.add(northLabel, null);
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e)
{
super.processWindowEvent(e);
if (e.getID() WindowEvent.WINDOW_CLOSING)
{
System.exit(0);
}
}
protected void processWindowEvent(WindowEvent e)
{
super.processWindowEvent(e);
if (e.getID() WindowEvent.WINDOW_CLOSING)
{
System.exit(0);
}
}
Bluej Programs
void addButton_actionPerformed(ActionEvent e)
{
String theTitle= this.titleTextField.getText();
int userID= Integer.parseInt(this.IDTextField.getText());
{
String theTitle= this.titleTextField.getText();
int userID= Integer.parseInt(this.IDTextField.getText());
this.addItem(new Item(theTitle,userID));//create a new object of the class Item
}
}
void searchButton_actionPerformed(ActionEvent e)
{
{
}
Descargar Diario de un putero de Torbe. Hola, soy Torbe, y soy la primera persona en Espa. Bienvenido a mi libro, dedicado a todas las putas, buenas y malas con las que estuve, que hicieron posible poder contarlo todo aqui, y ahora. Descargar diario de un vampiro.
void borrowingButton_actionPerformed(ActionEvent e)
{
}
void returnButton_actionPerformed(ActionEvent e)
{
}
public void addItem(Item theItem)
{
items.add(theItem);
}
{
items.add(theItem);
}
//Main method
public static void main(String[] args)
{
new LibraryCatalog();
}
}
public static void main(String[] args)
{
new LibraryCatalog();
}
}
Thanks for your help
- 5 Contributors
- forum5 Replies
- 1,046 Views
- 1 Year Discussion Span
- commentLatest Postby jwenting
You are complicating your life little. OK in general there are two main ways how to setup actionListener for buttons
1. general listener for all
1. general listener for all
Icse Bluej Programs
2. listener for each button
I use first option