public class SingleList extends JPanel implements ListSelectionListener { private JList list; private DefaultListModel listModel; private static final String saveString = "Save"; private static final String delString = "Delete"; private JButton deleteButton; private JTextField ename;
public SingleList() { super(new BorderLayout()); listModel = new DefaultListModel(); listModel.addElement("Amardeep"); listModel.addElement("Vinod"); listModel.addElement("Suman");
//Create the list and put it in a scroll pane. list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0); list.addListSelectionListener(this); list.setVisibleRowCount(5); JScrollPane listScrollPane = new JScrollPane(list);
JButton saveButton = new JButton(saveString); SaveListener save = new SaveListener(saveButton); saveButton.setActionCommand(saveString); saveButton.addActionListener(save); saveButton.setEnabled(false);
deleteButton = new JButton(delString); deleteButton.setActionCommand(delString); deleteButton.addActionListener(new DeleteListener());
ename = new JTextField(10); ename.addActionListener(save); ename.getDocument().addDocumentListener(save); String name = listModel.getElementAt(list.getSelectedIndex()).toString();
//Create a panel that uses BoxLayout. JPanel pane = new JPanel(); pane.setLayout(new BoxLayout(pane, BoxLayout.LINE_AXIS)); pane.add(deleteButton); pane.add(Box.createHorizontalStrut(5)); pane.add(new JSeparator(SwingConstants.VERTICAL)); pane.add(Box.createHorizontalStrut(5)); pane.add(ename); pane.add(saveButton); pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); add(listScrollPane, BorderLayout.CENTER); add(pane, BorderLayout.PAGE_END); }
class DeleteListener implements ActionListener { public void actionPerformed(ActionEvent e) {
int index = list.getSelectedIndex(); listModel.remove(index);
int size = listModel.getSize();
if (size == 0) { //Nobody's left, disable firing. deleteButton.setEnabled(false);
} else { //Select an index. if (index == listModel.getSize()) { //removed item in last position index--; }
//This listener is shared by the text field and the save button. class SaveListener implements ActionListener, DocumentListener { private boolean alreadyEnabled = false; private JButton button;
public SaveListener(JButton button) { this.button = button; }
September 3, 2008 at 12:06 PM
//Required by ActionListener. public void actionPerformed(ActionEvent e) { String name = ename.getText();
//User didn't type in a unique name... if (name.equals("") || alreadyInList(name)) { Toolkit.getDefaultToolkit().beep(); ename.requestFocusInWindow(); ename.selectAll(); return; }
int index = list.getSelectedIndex(); if (index == -1) { index = 0; } else { index++; }
//Reset the text field. ename.requestFocusInWindow(); ename.setText("");
//Select the new item and make it visible. list.setSelectedIndex(index); list.ensureIndexIsVisible(index); } protected boolean alreadyInList(String name) { return listModel.contains(name); }
//Required by DocumentListener. public void insertUpdate(DocumentEvent e) { enableButton(); }
//Required by DocumentListener. public void removeUpdate(DocumentEvent e) { handleEmptyTextField(e); }
//Required by DocumentListener. public void changedUpdate(DocumentEvent e) { if (!handleEmptyTextField(e)) { enableButton(); } }
private void enableButton() { if (!alreadyEnabled) { button.setEnabled(true); } }
private static void createAndShowGUI() { //Create and set up the window. JFrame frame = new JFrame("Single list example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane. JComponent newContentPane = new SingleList(); newContentPane.setOpaque(true); //content panes must be opaque frame.setContentPane(newContentPane); frame.setSize(300,200); frame.setVisible(true); }
public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } } -------------------------------------------
Scrolling List Box. - Java Beginners ScrollingListBox. How can is make a listbox scrollable by using... ListSelectionListener {
private JList list;
private DefaultListModel listModel...");
//Create the list and put it in a scroll pane.
list = new
List Box - JSP-Servlet list box.on selecting one value in listbox,i will retrieve values from database and store into another listbox in same page using javascript :location.my problem is in first listbox,value which i selected to get values is not displaying
Javascript List Box - JSP-Servlet
itself.my problem is in listbox the semester which i selected is not showing in listbox as selected.when i select,the page refreshes but i get the result what i expected.i need to show in listbox as semester is selected but it doesnt
jsp list box - Java Beginners
jsp list box I have two list boxs. the values for the first listbox is retrieved from the mysql database. I want to fill the second listbox selected item from the database.
Please help me in this regard.
Your help
PHP list box mysql
PHP Listbox that displays the data from mysql table.
User can select any value from the PHP listbox.
Example of PHP MYSQL ListBox
Code
<?php
if(isset($_GET['roll']))
{
$username="root";
$password="";
$database
PHP List Box Post
The PHP Post Listbox is used in the form. It contains multiple value
User can select one or more values from the PHP listBox
This PHP Post ListBox is the alternate of Combo box
PHP Post ListBox Example
<?php
PHP list box
The PHP Listbox is used in the form.
It takes input values from the user.
The PHP Listbox contains multiple values at a time.
PHP ListBox Example
<?php
if(isset($_GET['hobbie']))
 
store values of drop down list box in database
store values of drop down listbox in database how to store values of drop down listbox in oracle database in jsp?I have information inserting form where i have date of birth as drop down listbox
scroll bars to list box - JSP-Servlet
scroll bars to list box Can I add scroll bars to a listbox in struts? Hi friend,
Scroll the listbox in struts
Two attribute set "multiple" "size".
Select Tag Example
Select Tag
scrolling image scrolling image How create a scrolling image in java
image scrolling
image scrolling A brief description of scrolling image
dynamic drop down list box - Java Beginners
dynamic drop down list box hi all ,
I want to dynamically populate a drop down box from an sql query in a servlet program, using only html...
Dynamic Combobox List
list boxs list boxs i have two list boxes first listbox values from database and i want to assign selected options to the second listbox using jsp is it possible to do this in jsp
combo box
combo box Hi,
[_|] dropdown box...] | |
| LEFT LIST | | RIGHT LIST... a screen like this using jsp-servlet(or DAO,DTO),in that drop down box i should get
retrive the data from access database to drop down list box in jsp
retrive the data from access database to drop down listbox in jsp hai,
im new to jsp now im using the jsp along with access database.in table i load all the data's i need to retrive the data from database to dropdown listbox
remove item from list box using java script - Java Beginners
remove item from listbox using java script remove item from listbox using java script Hi friend,
Code to remove listbox item using java script :
Add or Remove Options in Javascript
function addItem
Scrolling UIWebView JavaScript Scrolling UIWebView JavaScript Hi, i am looking for an example code to make a scrolling function for UIWebView in JavaScript.
Thanks
Disable UITableView Scrolling
Disable UITableView Scrolling How to disable the UITableView Scrolling either programmatically or in XIB
scrolling problem - Framework scrolling problem I have eco framework application in that i created one grid on contentpane and add image on grid . i also add window pane on contentpane also.
while scrolling only image is moving but window is not moving
scrolling text in applet scrolling text in applet applet to display the scrolling text. The text should move from right to left. When it
reaches to start of the applet border, it should stop moving and restart from the left. When the applet
interrelated two selection box
interrelated two selection box hi i need two selection box .in 1 box all designation like manager, ceo etc , onclick on manager i should get list of managers names in second selection box.. like wise so on. from database
dropdown list in jsf
dropdown list in jsf I want to add a listbox to display the country name from the lists on all countries.When I select for e.g India then in the second listbox it will display the states related to India only and the flow
problem Scrolling jTable in scrollpane
problem Scrolling jTable in scrollpane hi i get into a problem of scrolling jtable in scrollpane.Only horizontal scroll is working, vertical scroll is not working...here is m code:
try
{
PreparedStatement pst
problem Scrolling jTable in scrollpane
problem Scrolling jTable in scrollpane hi i get into a problem of scrolling jtable in scrollpane.Only horizontal scroll is working, vertical scroll is not working...here is m code:
try
{
PreparedStatement pst
scrolling a drawing..... - Swing AWT scrolling a drawing..... I am using a canvas along with other components like JTable over a frame
the drawing which i am going to show over canvas is dynamic and hence there is no fixed size, that's why i need to make
enable text box and label on selection
enable text box and label on selection hello,
Please tell me how to enable label and text box on selection of drop down listbox.
in drop down listbox all values come from database.
please reply
populating the combo box - Struts
the combo box with a table in MS SQL Server 2005 Management Studio Express.
Belo...) {
ArrayList list = new ArrayList();
try {
connectToDb();
// String sec = null... {
closeConnection();
}
return list;
}
public ArrayList getCompanyBySector
problem scrolling jtable
problem scrolling jtable hi,
i've to query the table thousand of times...m table display is not getting stable/proper,especially after getting the empty table...
for removing the table i'm doing this::
numrows
Show the Value of Scroll Bar in Java Swing
the value of
scrolling position in the text box. The
scroll bar has multiples... of these components then you get the value of scrolling
positions.
This program shows a scrollbar...: horizontal and vertical. The text field holds the value of scrolling position
Helps with combo box and frame
Helps with combo box and frame Hi
i have a combobox and when i click... on the second window and click confirm i would have the information on the combo box.
i... = new JFrame("Add-Remove item to list");
String items
drop down box - JSP-Servlet
drop down box when i enter some letter in the input box,the corresponding words of that particular letter must be displayed below as a list from the data base in the same input box as drop down.
Thanks&Regards,
VijayaBabu.M
Dojo Combo Box
or listbox and a single-line textbox, allowing
the user either to type a value...Dojo Combo Box
In this section, you will learn what is combo box and
how to create
List
List i do have one list object, i want to compare this list from database table and if match found i want to update the list
List
List getting values from a form and make a list of them and store them into database
problem in scrolling SVG drawing in canvas - MobileApplications
problem in scrolling SVG drawing in canvas hi all,
i'm...- usually map's size is bigger than mobile screen , so i need to make scrolling over the drawing , scrolling works well in wireless toolkit emulator , but when i