TableView setEditable is not working

Hello, the method setEditable(boolean value) in TabeView is not working.
I read the documentation and I'm supposed to use de enter key, but it does not work. I also read in this forum, and I found that a bug was reported, but that forum thread was issued almost a year ago. So I was wondering if it is my javafx version that is giving me the problem.
Thanks in advance.

Hello James, thanks for your answer.
I have used that same code, and it does not work for me. I even tried invoking setEditable on the TableColumns references.
And also I have updated JDK to the last version. 1.7.0_21.
Look:
* To change this template, choose Tools | Templates
* and open the template in the editor.
package tableviewsample;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.stage.Stage;
* @author Eugenio
public class TableViewSample extends Application {
    private TableView table = new TableView();
    @Override
    public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        stage.setTitle("Table View Sample");
        stage.setWidth(400);
        stage.setHeight(500);
        final Label label = new Label("Address Book");
        label.setFont(new Font("Arial", 20));
        TableColumn firstNameCol = new TableColumn("First Name");
        TableColumn lastNameCol = new TableColumn("Last Name");
        TableColumn emailCol = new TableColumn("Email");
        emailCol.setMinWidth(200);
        firstNameCol.setEditable(true);
        lastNameCol.setEditable(true);
        emailCol.setEditable(true);
        table.setEditable(true);
        table.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
        final ObservableList<Person> data = FXCollections.observableArrayList(
                new Person("Jacob", "Smith", "[email protected]"),
                new Person("Isabella", "Johnson", "[email protected]"),
                new Person("Ethan", "Williams", "[email protected]"),
                new Person("Emma", "Jones", "[email protected]"),
                new Person("Michael", "Brown", "[email protected]"));
        firstNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("firstName"));
        lastNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("lastName"));
        emailCol.setCellValueFactory(new PropertyValueFactory<Person, String>("email"));
        table.setItems(data);
        final TextField addFirstName = new TextField();
        addFirstName.setPromptText("First Name");
        addFirstName.setMaxWidth(firstNameCol.getPrefWidth());
        final TextField addLastName = new TextField();
        addLastName.setMaxWidth(lastNameCol.getPrefWidth());
        addLastName.setPromptText("Last Name");
        final TextField addEmail = new TextField();
        addEmail.setMaxWidth(emailCol.getPrefWidth());
        addEmail.setPromptText("Email");
        final Button addButton = new Button("Add");
        addButton.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent e) {
                data.add(new Person(
                        addFirstName.getText(),
                        addLastName.getText(),
                        addEmail.getText()));
                addFirstName.clear();
                addLastName.clear();
                addEmail.clear();
        final HBox hb = new HBox();
        hb.getChildren().addAll(addFirstName, addLastName, addEmail, addButton);
        hb.setSpacing(3);
        final VBox vbox = new VBox();
        vbox.setSpacing(5);
        vbox.setPadding(new Insets(10, 0, 0, 10));
        vbox.getChildren().addAll(label, table, hb);
        ((Group) scene.getRoot()).getChildren().addAll(vbox);
        stage.setScene(scene);
        stage.show();
     * The main() method is ignored in correctly deployed JavaFX application.
     * main() serves only as fallback in case the application can not be
     * launched through deployment artifacts, e.g., in IDEs with limited FX
     * support. NetBeans ignores main().
     * @param args the command line arguments
    public static void main(String[] args) {
        launch(args);
}

Similar Messages

  • Javafx tableview onscroll event not working

    tableview onscroll event is not working and how to add scrollbal event on tableview.could u help me

    As jsmith notes, the best place to report bugs is directly into the Jira tracker at http://javafx-jira.kenai.com. If you put it in the 'runtime' area against the 'controls' component, it'll end up on my plate.
    Thanks!
    Jonathan

  • TableView.edit() is not working in JavaFX 2.1

    Hi All,
    Yesterday i have updated my javafx installation from JavaFX 2.0.2 to JavaFX 2.1 b07
    After that I am facing issues with TableView.edit() method. It stops working and not making the cell as editable.
    In the below example , select the first cell, and on click of 'tab' , the next cell is changed to editing state..and goes on for all the cells. If it reaches the end column, the first cell of the next row is selected.
    You can find the sscce example below. The same code is working well in 2.0.2 build.
    import javafx.application.Application;
    import javafx.beans.property.SimpleStringProperty;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.event.EventHandler;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.control.TableCell;
    import javafx.scene.control.TableColumn;
    import javafx.scene.control.TableView;
    import javafx.scene.control.TextField;
    import javafx.scene.control.cell.PropertyValueFactory;
    import javafx.scene.input.KeyCode;
    import javafx.scene.input.KeyEvent;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.StackPane;
    import javafx.stage.Stage;
    import javafx.util.Callback;
    import com.sun.javafx.scene.control.skin.TableRowSkin;
    public class StartEditDemo extends Application {
        public static void main(String[] args) {
            Application.launch(args);
        public void start(Stage primaryStage) {
            primaryStage.setTitle("Start Edit Test");
            StackPane root = new StackPane();
            Scene scene = new Scene(root, 600, 150);
            primaryStage.setScene(scene);
            primaryStage.show();
            configureTable(root);
         private void configureTable(StackPane root) {
              final ObservableList<MyDomain> data = FXCollections.observableArrayList(
                         new MyDomain("Apple","This is a fruit","Red"),
                         new MyDomain("PineApple","This is also a fruit","Yellow"),
                         new MyDomain("Potato","This is a vegetable","Brown")
              TableView<MyDomain> table = new TableView<MyDomain>();
              TableColumn<MyDomain,String> titleColumn = new TableColumn<MyDomain,String>("Name");
              titleColumn.setPrefWidth(150);
              titleColumn.setCellValueFactory(new PropertyValueFactory<MyDomain,String>("name"));
              titleColumn.setCellFactory(getEditableCallBack(1));
              TableColumn<MyDomain,String> descCol = new TableColumn<MyDomain,String>("Description");
              descCol.setPrefWidth(150);
              descCol.setCellValueFactory(new PropertyValueFactory<MyDomain,String>("description"));
              descCol.setCellFactory(getEditableCallBack(2));
              TableColumn<MyDomain,String> colorCol = new TableColumn<MyDomain,String>("Color");
              colorCol.setPrefWidth(150);
              colorCol.setCellValueFactory(new PropertyValueFactory<MyDomain,String>("color"));
              colorCol.setCellFactory(getEditableCallBack(0));
              table.getColumns().addAll(titleColumn,descCol,colorCol);
              table.setItems(data);
              root.getChildren().add(table);
         private Callback<TableColumn<MyDomain, String>, TableCell<MyDomain, String>> getEditableCallBack(final int nextColumn) {
              /* Cell factory call back object */
              return new Callback<TableColumn<MyDomain, String>, TableCell<MyDomain, String>>() {
                   @Override
                   public TableCell<MyDomain, String> call(TableColumn<MyDomain, String> p) {
                        return new EditableCell<MyDomain>(nextColumn);
         public class EditableCell<T> extends TableCell<T, String> {
              private TextField textBox;
              private Label label;
              private int nextCol;
              public EditableCell(int nextcolumn) {
                   this.label = new Label();
                   this.nextCol = nextcolumn;
                   /* Enabling to get the edit cell on single mouse click over the cell. */
                   this.setOnMouseClicked(new EventHandler<MouseEvent>() {
                        @Override
                        public void handle(MouseEvent event) {
                             startEdit();
              @Override
              public void startEdit() {
                   super.startEdit();
                   if (isEmpty()) {
                        return;
                   if (textBox == null) {
                        createTextBox();
                   } else {
                        textBox.setText(getItem());
                   setGraphic(textBox);
                   textBox.requestFocus();
                   textBox.selectAll();
                   setEditable(true);
              @Override
              public void updateItem(String item, boolean empty) {
                   super.updateItem(item, empty);
                   if (!isEmpty()) {
                        if (textBox != null) {
                             textBox.setText(item);
                        label.setText(item);
                        setGraphic(label);
              private void createTextBox() {
                   textBox = new TextField(getItem());
                   /* On focus of the textbox, selecting the row.*/
                   textBox.focusedProperty().addListener(new ChangeListener<Boolean>() {
                        @Override
                        public void changed(ObservableValue<? extends Boolean> paramObservableValue,Boolean paramT1, Boolean paramT2) {
                             if(paramT2){
                                  EditableCell.this.getTableView().getSelectionModel().select(EditableCell.this.getIndex());
                   textBox.setOnKeyReleased(new EventHandler<KeyEvent>() {
                        @Override
                        public void handle(KeyEvent t) {
                             if (t.getCode() == KeyCode.ENTER) {
                                  callAction();
                             } else if (t.getCode() == KeyCode.ESCAPE) {
                                  cancelEdit();
                   textBox.setOnKeyPressed(new EventHandler<KeyEvent>() {
                        @Override
                        public void handle(KeyEvent t) {
                             if (t.getCode() == KeyCode.TAB){
                                  if(nextCol!=0){
                                       // Making the next as editable and focused.
                                       TableColumn nextColumn = getTableView().getColumns().get(nextCol);
                                       getTableView().edit(getTableRow().getIndex(), nextColumn);
                                       getTableView().getFocusModel().focus(getTableRow().getIndex(), nextColumn);
                                  }else{
                                       // Making the next row as editable.
                                       if(getTableRow().getIndex()<getTableView().getItems().size()){
                                            TableColumn nextColumn = getTableView().getColumns().get(0);
                                            getTableView().edit(getTableRow().getIndex()+1, nextColumn);
                                            getTableView().getFocusModel().focus(getTableRow().getIndex()+1, nextColumn);
              @Override
              public void cancelEdit() {
                   super.cancelEdit();
                   textBox = null;
                   setGraphic(label);
              @Override
              public void commitEdit(String t) {
                   super.commitEdit(t);
                   setItem(t);
                   textBox = null;
                   label.setText(t);
                   setGraphic(label);
              @SuppressWarnings("rawtypes")
              public ObservableList<Node> getAllCellsOfSameRow(TableCell cell) {
                   TableRowSkin rowSkin = (TableRowSkin) cell.getParent();
                   return rowSkin.getChildren();
              public void callAction() {
                   TableRowSkin<T> rowSkin = (TableRowSkin<T>) this.getParent();
                   ObservableList<Node> cells = rowSkin.getChildren();
                   for (Node node : cells) {
                        EditableCell<T> cell = (EditableCell<T>) node;
                        cell.commitEdit(cell.getTextBox().getText());
              public TextField getTextBox() {
                   return this.textBox;
              public Label getLabel() {
                   return this.label;
         public class MyDomain{
              private SimpleStringProperty name = new SimpleStringProperty();
              private SimpleStringProperty description = new SimpleStringProperty();
              private SimpleStringProperty color = new SimpleStringProperty();
              public MyDomain(String name, String desc, String color){
                   this.name.set(name);
                   this.description.set(desc);
                   this.color.set(color);
              public String getDescription() {
                 return description.get();
              public SimpleStringProperty descriptionProperty(){
                  return description;
             public String getName() {
                 return name.get();
             public SimpleStringProperty nameProperty(){
                  return name;
             public String getColor() {
                 return color.get();
             public SimpleStringProperty colorProperty(){
                  return color;
    }Regards,
    Sai Pradeep Dandem.

    As jsmith notes, the best place to report bugs is directly into the Jira tracker at http://javafx-jira.kenai.com. If you put it in the 'runtime' area against the 'controls' component, it'll end up on my plate.
    Thanks!
    Jonathan

  • SetEditable is not working with combobox

    Hi,
    I am working with table and using combo box in cell of table, in certain condition I have to make combo as editable and non editable.
    I have written class which extends DefaultCellEditor
    @Override
    public Component getTableCellEditorComponent(JTable table, Object value, boolean flag, int row, int column)
    comboBox.getModel()).setSelectedItem(value.toString());
    comboBox.setEditable(true);
    if i set comboBox.setEditable(true). cell become editable but i am not able to select item from combo..
    when i do set comboBox.setEditable(false) cell become non editable and i can select value from combo but not able to enter any value.
    i want both the operations. Editable cell in which user can enter any value and also can select value from combo.
    Any Idea???? please share with me, this is blocking issue for me. Thanks in advance.
    Prashant Gour
    Message was edited by:
    Prashant_SDN

    thanks
    that is working idea of key listener. now i am able to select item form combo and can enter value too. but now problem is that by default combo looks non editable and become editable after pressing key .
    so that is looked user friendly.
    have you any suggestions.

  • TableView updates not working when ValueFactory returns a new Binding

    Hi,
    When a cell value factory returns a newly created expression or Binding cell values will stop receiving updates at some point. It seems that the cell that requests the observable value from the value factory does not keep a strong reference to the returned value so the cell will only receive updates from the the Observable value as long as it has not been garbage collected. The code below reproduces this issue:
    import javafx.application.Application;
    import javafx.beans.property.DoubleProperty;
    import javafx.beans.property.ReadOnlyStringWrapper;
    import javafx.beans.property.SimpleDoubleProperty;
    import javafx.beans.value.ObservableValue;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.TableColumn;
    import javafx.scene.control.TableColumn.CellDataFeatures;
    import javafx.scene.control.TableView;
    import javafx.scene.layout.HBox;
    import javafx.scene.layout.HBoxBuilder;
    import javafx.scene.layout.StackPane;
    import javafx.scene.layout.VBox;
    import javafx.scene.layout.VBoxBuilder;
    import javafx.stage.Stage;
    import javafx.util.Callback;
    * Reproduce cell update bug. Compile and run the class. Press the update button a
    * couple of times and note how the values in the total column update. Press the
    * GC button a couple of times and then press the update button again. Note how
    * the values in the total column do not update anymore.
    * The Value Factory for the total column does not return a property that is
    * held by the Order object, it returns a Binding that is created on the fly.
    * The cell does not hold a strong reference to this object so it can be gc'd 
    public class CellUpdateTest2 extends Application {
         static class Order {
              String name;
              DoubleProperty price = new SimpleDoubleProperty();
              DoubleProperty qty = new SimpleDoubleProperty();
              Order(String n, double p) {
                   name = n;
                   price.set(p);
                   qty.set(1);
         final Order items[] = {
                   new Order("Item 0", 4.0),
                   new Order("Item 1", 5.0),
                   new Order("Item 2", 6.0),
                   new Order("Item 3", 7.0),
                   new Order("Item 4", 8.0),
                   new Order("Item 5", 9.0),
                   new Order("Item 6", 10.0),
                   new Order("Item 7", 11.0)
         @Override
         public void start(final Stage primaryStage) throws Exception {
              final Button updateButton = new Button("Update Values");
              updateButton.setOnAction(new EventHandler<ActionEvent>() {
                   @Override
                   public void handle(final ActionEvent actionEvent) {
                        for (Order i: items) {
                             i.qty.set(i.qty.get() + 1);
              final Button gcButton = new Button("System.gc()");
              gcButton.setOnAction(new EventHandler<ActionEvent>() {
                   @Override
                   public void handle(final ActionEvent actionEvent) {
                        System.gc();
              final TableView<Order> tv = new TableView<Order>();
              final TableColumn<Order, String> nameCol = new TableColumn<Order, String>("Item");
              final TableColumn<Order, Number> priceCol = new TableColumn<Order, Number>("Price");
              final TableColumn<Order, Number> qtyCol = new TableColumn<Order, Number>("Quantity");
              final TableColumn<Order, Number> totalCol = new TableColumn<Order, Number>("Total");
              nameCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Order, String>, ObservableValue<String>>() {
                   @Override
                   public ObservableValue<String> call(final CellDataFeatures<Order, String> d) {
                        return new ReadOnlyStringWrapper(d.getValue().name);
              priceCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Order, Number>, ObservableValue<Number>>() {
                   @Override
                   public ObservableValue<Number> call(final CellDataFeatures<Order, Number> cellData) {
                        return cellData.getValue().price;
              qtyCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Order, Number>, ObservableValue<Number>>() {
                   @Override
                   public ObservableValue<Number> call(final CellDataFeatures<Order, Number> cellData) {
                        return cellData.getValue().qty;
              totalCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Order, Number>, ObservableValue<Number>>() {
                   @Override
                   public ObservableValue<Number> call(final CellDataFeatures<Order, Number> cellData) {
                        return cellData.getValue().price.multiply(cellData.getValue().qty);
              tv.getColumns().addAll(nameCol, priceCol, qtyCol, totalCol);
              tv.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
              tv.getItems().addAll(items);
              final HBox hb = HBoxBuilder.create().children(updateButton, gcButton).build();
              final VBox vb = VBoxBuilder.create().children(tv, hb).build();
              primaryStage.setScene(new Scene(vb));
              primaryStage.setHeight(200.0);
              primaryStage.show();
         public static void main(final String args[]) {
              launch(args);
    } Is this expected behaviour?
    If so - what would the correct way to approach this?
    If not - is there an easy workaround?

    this seems to have worked....
         static class Order {
              String name;
              DoubleProperty price = new SimpleDoubleProperty();
              DoubleProperty qty = new SimpleDoubleProperty();
                    DoubleProperty total = new SimpleDoubleProperty();
              Order(String n, double p) {
                   name = n;
                   price.set(p);
                   qty.set(1);
                    public void updateTotal() {
                        total.set(price.get() * qty.get());
         }with
              qtyCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Order, Number>, ObservableValue<Number>>() {
                   @Override
                   public ObservableValue<Number> call(final CellDataFeatures<Order, Number> cellData) {
                                    System.out.println("in qty column");
                                    cellData.getValue().updateTotal();
                        return cellData.getValue().qty;
              });and finally
              totalCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Order, Number>, ObservableValue<Number>>() {
                   @Override
                   public ObservableValue<Number> call(final CellDataFeatures<Order, Number> cellData) {
                                    System.out.println("in total column");
                        return cellData.getValue().total;
              });I cannot explain why what you did did not work. I have a mistrust towards binding and I avoid it when ever possible.
    thanks
    jose

  • MenuManager in TableViewer does not work on mobile device (tablet with Win 8)

    Hi
    Welcome everybody This is my first post on this forum. I really hope you can help me out with this. It is kind of strange.... Ok, so I am developing RCP/SWT application, and it has to work on mobile device with windows 8 as well (10' tablet with windows Cool. So far so good - everything work pretty nice, except one thing that is really annoying. So I have this table, and user has possibility to use right click menu (context menu) on each row. Problem is that it does not work at all on mobile device. Right click on tablet is actually defined by pressing finger for longer period of time - then after 1 or 2 second menu should appear. Problem is that it does not at all. Funny thing is that when I connect a mouse using USB port to tablet I am able to open this menu Smile - it works completely fine. Menu works also with finger action when I press on empty (e.g. table without any data) I noticed that this issue is related with constructor style option SWT.FULL_FULL_SELECTION that is used for creating table. When I remove it from the constructor, right click works fine but there is not any data (no record is selected), so I can not perform any context menu action. Menu is dynamic, so depending on what data is loaded, the contain of menu changes. Main problem is that method menuAboutToShow is not called at all!. The code looks like that:
    Table table = new Table(parent, SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    table.setLinesVisible(true);
    table.setLayout(myTableLayout);
    createColumns(table, layout);
    table.setHeaderVisible(true);
    tableViewer = new TableViewer(table);
    tableViewer.setContentProvider(myContentProvider);
    tableViewer.setLabelProvider(myLabelProvider);
    MenuManager contextMenu = new MenuManager();
    contextMenu.setRemoveAllWhenShown(true);
    contextMenu.addMenuListener(new IMenuListener() {
    public void menuAboutToShow(IMenuManager mgr) {
    contextMenu.add(new MyAction(action)); // THIS PLACE IS NEVER CALLED WITH RIGHT FINGER CLICK!
    // dynamic filling context menu engine
    Menu menu = contextMenu.createContextMenu(tableViewer.getControl());
    tableViewer.getControl().setMenu(menu);
    getSite().registerContextMenu(contextMenu, null);
    Additional info: this tap-hold functionally is standard equivalent for right click on tablet device with Windows. I did not do any additional implementation for that. I think it should just work. I have several tables in my application and in all of those this problem appears. Any idea what may be wrong ?
    cheers,
    Pawel

    I have just installed SWT Example on my tablet (from here: https://www.eclipse.org/swt/examples.php#standaloneOutsideEclipse) and this same problem appears on the table example. I think it is general problem/bug. Should I report this as a swt eclipse bug ?

  • MenuManager in TableViewer does not work on mobile device

    Hi
    Welcome everybody This is my first post on this forum. I really hope you can help me out with this. It is kind of strange.... Ok, so I am developing RCP application, and it has to work on mobile device with windows 8 as well (10' tablet with windows . So far so good - everything work pretty nice, except one thing that is really annoying. So I have this table, and user has possibility to use right click menu (context menu) on each row. Problem is that it does not work at all on mobile device. Right click on tablet is actually defined by pressing finger for longer period of time - then after 1 or 2 second menu should appear. Problem is that it does not at all. Funny thing is that when I connect a mouse using USB port to tablet I am able to open this menu - it works completely fine. Menu works also with finger action when I press on empty (e.g. table without any data) I noticed that this issue is related with constructor style option SWT.FULL_FULL_SELECTION that is used for creating table. When I remove it from the constructor, right click works fine but there is not any data (no record is selected), so I can not perform any context menu action. Menu is dynamic, so depending on what data is loaded, the contain of menu changes. Main problem is that method menuAboutToShow is not called at all!. The code looks like that:
    Table table = new Table(parent, SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    table.setLinesVisible(true);
    table.setLayout(myTableLayout);
    createColumns(table, layout);
    table.setHeaderVisible(true);
    tableViewer = new TableViewer(table);
    tableViewer.setContentProvider(myContentProvider);
    tableViewer.setLabelProvider(myLabelProvider);
    MenuManager contextMenu = new MenuManager();
    contextMenu.setRemoveAllWhenShown(true);
    contextMenu.addMenuListener(new IMenuListener() {
    public void menuAboutToShow(IMenuManager mgr) {
    contextMenu.add(new MyAction(action)); // THIS PLACE IS NEVER CALLED WITH RIGHT FINGER CLICK!
    // dynamic filling context menu engine
    Menu menu = contextMenu.createContextMenu(tableViewer.getControl());
    tableViewer.getControl().setMenu(menu);
    getSite().registerContextMenu(contextMenu, null);
    Any idea what may be wrong ?
    cheers,
    Pawel

    Hi
    The "tap-and-hold" is not my functionality. It default SWT Table behaviour on tablet. In windows it self it works like that - to use "right click" you have to do "tap-and-hold". It is just the way it works on tablet I do not have any other application to test it, but I have several tables/tableViever in my application for presenting different results/data, and in all of those this problem appears

  • TableView : sort = "SERVER" ...does not work for "TIME"

    Hi,
    TableView sort = "Server" works automatically for "Date" Fields and "Text" Fields.
    But it does not work for "Time" field with data element "CDUZEIT". It shows the below error message:
    Note
    The following error text was processed in the system IFD : Invalid sort field type in "SORT ... AS TEXT".
    The error occurred on the application server ifdmain_IFD_01 and in the work process 0 .
    The termination type was: RABAX_STATE
    The ABAP call stack was:
    Form: IF_HTMLB_ELEMENT_DELEGATED~DO_AT_END of program CL_HTMLB_TABLEVIEW============CP
    Form: DELEGATED_END of program CL_HTMLB_ELEMENT==============CP
    Form: IF_BSP_ELEMENT~DO_AT_END of program CL_HTMLB_TABLEVIEW============CP
    Form: ONLAYOUT of program CLO27OLHO7EA9KVWPONPDC2NLTDFHCP
    Form: %_ONLAYOUT of program CL_O27OLHO7EA9KVWPONPDC2NLTDFHCP
    Form: DO_REQUEST of program CL_BSP_PAGE===================CP
    Form: CALL_VIEW of program CL_BSP_PAGE_BASE==============CP
    Form: CALL_VIEW of program CL_BSP_CONTROLLER=============CP
    Form: DO_REQUEST of program ZCL_ZPR_C_ACTION_LOG==========CP
    Form: DO_REQUEST of program CL_BSP_CTRL_ADAPTER===========CP
    Thanks and Regards,
    Bindiya

    Welcome to SDN.
    This problem and solution to it is exaplined in the following oss note number.
    <a href="https://service.sap.com/~form/handler?_APP=01100107900000000342&_EVENT=REDIR&_NNUM=893210&_NLANG=E">893210</a>
    Regards
    Raja

  • Web Cam applet is not working in great consistency

    Hi... My video capturing applet is not working very well.
    The image stream is displayed on the web page in JPEG format with 0.5 quality. However, it crashes after a while and the it does not release the vfw resource.
    I have to restart my machine in order to execute it again.
    Can anyone please help?
    Thanks.
    Carter

    Ok. Thanks.
    Sender Applet
    import javax.swing.*;
    import java.io.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    /*<applet code="myGUIApplet.class" width="300" height="300"></applet>*/
    public class myGUIApplet extends JApplet implements ActionListener
         private JPanel bottom=new JPanel();
         private JPanel centVisual=new JPanel();
         private JPanel connectionAddress=new JPanel();
         private JButton capture=new JButton("Start Capturing");
         private JButton stops=new JButton("Stop");
         private JMenuBar menubar=new JMenuBar();
         private JMenu file=new JMenu("file");     
         private JMenuItem fileItem1=new JMenuItem("Exit");
         private JLabel serverip=new JLabel("Server IP");
         private JTextField setIP=new JTextField();
         public static JTextField ServerInfo=new JTextField();
         private MyTransmitter mytrans;
         private String ip;
         public static final String DEFAULT_MULTICAST_IP="226.10.10.20";
         public static final String DEFAULT_PORT="80";
         public void init()
              //setSize(400,400);               
              setLayout(new BorderLayout());
              menubar.add(file);
              file.add(fileItem1);
              bottom.setLayout(new BorderLayout());
              bottom.setBackground(Color.black);
              bottom.add("West",capture);
              bottom.add("East",stops);
              connectionAddress.setLayout(new BorderLayout());
              connectionAddress.add("North",serverip);
              connectionAddress.add("South",setIP);
              ServerInfo.setEditable(false);
              connectionAddress.add("Center",ServerInfo);
              setIP.addActionListener(this);
              setIP.setText("");
              capture.setBackground(Color.lightGray);
              capture.addActionListener(this);
              stops.addActionListener(this);
              fileItem1.addActionListener(this);
              add("South",bottom);
              add("North",menubar);     
              add("Center",connectionAddress);          
         public void actionPerformed(ActionEvent ae){
              Object source=ae.getSource();
              if(source==capture){
              if(setIP.getText().equals(""))
                        ip=DEFAULT_MULTICAST_IP;
              else{
                   ip=setIP.getText();
                   if(mytrans!=null){
                        mytrans.stopTransmitter();
                        mytrans=null;                         
                   System.out.println(" - Connecting to "+ip+" port: "+DEFAULT_PORT);
                   ServerInfo.setText(" - Connecting to "+ip+" port: "+DEFAULT_PORT);
                   mytrans=new MyTransmitter(ip,DEFAULT_PORT,ServerInfo);
                   mytrans.start();               
              if(source==stops){
                   if(mytrans!=null)
                        mytrans.stopTransmitter();
                   System.exit(0);
              if(source==fileItem1){
                   if(mytrans!=null)
                        mytrans.stopTransmitter();     
                   System.exit(0);
         public void destroy(){
              if(mytrans!=null){
                   mytrans.stopTransmitter();
    import java.awt.*;
    import javax.swing.*;
    import java.io.*;
    import java.util.*;
    import java.net.InetAddress;
    import javax.media.*;
    import javax.media.protocol.*;
    import javax.media.protocol.DataSource;
    import javax.media.format.*;
    import javax.media.control.TrackControl;
    import javax.media.control.QualityControl;
    import javax.media.rtp.*;
    import javax.media.rtp.rtcp.*;
    import javax.media.rtp.*;
    import java.io.InputStream;
    import javax.media.rtp.RTPManager;
    public class MyTransmitter extends Thread
         private MediaLocator videoLocator;
         private String ipAddress;
         private int basePort;
         private Integer stateLock=new Integer(0);
         private boolean failure;
         private Processor processor;
         private DataSource videoDataInput,videoDataOutput;
         private RTPManager rtpMgrs[];
         private VideoFormat JPEG_VIDEO=new VideoFormat(VideoFormat.JPEG_RTP);
         private SendStream sendStream;
         private SourceDescription descriptionList[];
         private JTextField infoField;
         public MyTransmitter(String ips,String ports,JTextField ServerInfo){
              infoField=ServerInfo;
              ipAddress=ips;
              Integer bPort=Integer.valueOf(ports);
              if(bPort!=null)
                   basePort=bPort.intValue();
         public void run()
              initializeVideo();
              if(videoLocator!=null){
                   createMyProcessor();
                   createMyManager();
              // May be should put inside the if..else statements
              //createMyTransmitter();
         // Initailize the video
         public void initializeVideo()
              // Stre the devices in a vector
              VideoFormat format=new VideoFormat(VideoFormat.RGB);
              Vector deviceList=CaptureDeviceManager.getDeviceList(format);
              CaptureDeviceInfo deviceInfo=null;
              // If there is more than one device detected
              if(deviceList.size()>0){
                   // Set the first device to device Info
                   // GEt the media locator of the devie
                   deviceInfo=(CaptureDeviceInfo)deviceList.elementAt(0);
                   videoLocator=deviceInfo.getLocator();
              }else{
                   System.out.println(" --X No device found...");
                   infoField.setText(" --X No device found...");
         public void createMyProcessor()
              boolean result=false;
              DataSource ds=null;
              // Check if the media locator is null
              if(videoLocator==null){
                   System.out.println(" --X No video locator..");
                   infoField.setText(" --X No video locator...");
              System.out.println(" - Trying to create a Processor..");
              infoField.setText(" - Trying to create a Processor..");
              // Attempt to create DataSource from media locator
              try{
                   ds=Manager.createDataSource(videoLocator);
              }catch(Exception ex){
                   System.out.println(" --X Unable to create dataSource : "+ex.getMessage());
              System.out.println(" - Video data source is created..");
              infoField.setText(" - Video data source is created..");
              // Try to create Processor from DataSource
              try{
                   processor=Manager.createProcessor(ds);
              }catch(NoProcessorException npe){
                   System.out.println(" --X Unable to create Processor: "+npe.getMessage());
                   infoField.setText(" --X Unable to create Processor: "+npe.getMessage());
              catch(IOException ioe){
                   System.out.println(" --X IOException creating Processor..");
                   infoField.setText(" --X IOException creating Processor..");
              // Wait for the processor to be configured
              result=waitForState(processor,Processor.Configured);
              if(result==false){
                   System.out.println(" --X Could not configure processor..");
                   infoField.setText(" --X Could not configure processor..");
              // Set the track controls for processor
              TrackControl []tracks=processor.getTrackControls();
              if(tracks==null || tracks.length<1){
                   System.err.println(" --X No track is found..");
                   infoField.setText(" --X No track is found..");
              // Set the content description of processor to RAW_RTP format
              // This will limit the supported formats to reported from
              // Track.getSupportedFormats() to valid RTP format
              ContentDescriptor cdes=new ContentDescriptor(ContentDescriptor.RAW_RTP);
              processor.setContentDescriptor(cdes);
              Format []supported;
              Format chosen=null;
              boolean atLeastOneTrack=false;
              for(int i=0;i<tracks.length;i++){
                   Format format=tracks.getFormat();
                   if(tracks[i].isEnabled()){
                        supported=tracks[i].getSupportedFormats();
                        // WE've set the output content to RAW_RTP.
                        // So, all the supporte formats should work with RAW_RTP.
                        // We will pick the first one.
                        if(supported.length>0){
                             if(supported[0] instanceof VideoFormat){                              
                                  chosen=checkVideoSize(tracks[i].getFormat(),supported[0]);
                             }else
                                  chosen=supported[0];
                             tracks[i].setFormat(chosen);
                             System.out.println(" Track "+i+" is transmitted in "+chosen+" format.. ");
                             infoField.setText(" Track "+i+" is transmitted in "+chosen+" format.. ");
                             atLeastOneTrack=true;
                        }else{
                             // If no format is suitable, track is disabled
                             tracks[i].setEnabled(false);
                   }else
                        tracks[i].setEnabled(false);          
              if(!atLeastOneTrack)
                   System.out.println("atLeastOneTrack: "+atLeastOneTrack);
                   System.out.println(" --X Could Not find track to RTP format..");
                   infoField.setText("atLeastOneTrack: "+atLeastOneTrack);
                   infoField.setText(" --X Could Not find track to RTP format..");
              result=waitForState(processor,Controller.Realized);
              if(result==false){
                   System.out.println(" --X Could NOT realize processor...");
                   infoField.setText(" --X Could NOT realize processor...");
              // Set the JPEG Quality to value 0.5
              setJPEGQuality(processor,0.5f);
              // Set the output Data Source
              videoDataOutput=processor.getDataOutput();
              //Start the processor
              processor.start();          
         public void setJPEGQuality(Processor p,float values)
              Control []cs=p.getControls();
              QualityControl qc=null;
              VideoFormat JPEGFmt=new VideoFormat(VideoFormat.JPEG);
              // Loop through the ocntrols to find the Quality control for the JPEG encoder
              for(int i=0;i<cs.length;i++){
                   if(cs[i] instanceof QualityControl && cs[i] instanceof Owned){
                        Object owner=((Owned)cs[i]).getOwner();
                        // Check if the owner is the Codec
                        // Check the format of output as well
                        if(owner instanceof Codec){
                             Format fmts[]=((Codec)owner).getSupportedOutputFormats(null);
                             // Loop through the supported format and set the quality to 0.5
                             for(int j=0;j<fmts.length;j++){
                                  qc=(QualityControl)cs[i];
                                  qc.setQuality(values);
                                  System.out.println(" - Quality is set to "+values+" on "+qc);
                                  infoField.setText(" - Quality is set to "+values+" on "+qc);
                                  break;
                   if(qc!=null)
                        break;
         public Format checkVideoSize(Format originalFormat,Format supported)
              int width,height;
              Dimension size=((VideoFormat)originalFormat).getSize();     
              Format jpegFormat=new Format(VideoFormat.JPEG_RTP);
              Format h263fmt=new Format(VideoFormat.H263_RTP);
              if(supported.matches(jpegFormat)){
                   width=(size.width%8 == 0 ? size.width:(int)(size.width%8)*8);
                   height=(size.height%8 == 0 ? size.height:(int)(size.height%8)*8);
              }else if(supported.matches(h263fmt)){
                   if(size.width<128){
                        width=128;
                        height=96;
                   }else if(size.width<176){
                        width=176;
                        height=144;
                   }else{
                        width=352;
                        height=288;
              }else{
                   // Unknown format, just return it.
                   return supported;
              return (new VideoFormat(null,new Dimension(width,height),Format.NOT_SPECIFIED,null,Format.NOT_SPECIFIED)).intersects(supported);
         public boolean waitForState(Processor p,Integer status)
              p.addControllerListener(new StateListener());
              failure=false;
              if(status==Processor.Configured){
                   p.configure();               
              }else if(status==Processor.Realized){
                   p.realize();
              //Wait until an event that confirms the success of the method, or failure of an event
              while(p.getState()<status && !failure){
                   synchronized(getStateLock()){
                        try{
                             // Wait
                             getStateLock().wait();
                        }catch(InterruptedException ie){
                             return false;
              if(failure)
                   return false;
              else
                   return true;
         public Integer getStateLock(){
              return stateLock;
         public void setFailure(){
              failure=true;
         public void createMyManager()
              SessionAddress destAddress;
              InetAddress ipAddr;
              int port;
              SourceDescription srcDesList[];
              PushBufferDataSource pbds=(PushBufferDataSource)videoDataOutput;
              PushBufferStream pbss[]=pbds.getStreams();          
              rtpMgrs=new RTPManager[pbss.length];          
              for(int a=0;a<pbss.length;a++){
              try{
                   // RTP Managers or RTP Manager?????
                   rtpMgrs[a]=RTPManager.newInstance();
                   port=basePort;
                   ipAddr=InetAddress.getByName(ipAddress);
                   SessionAddress localAddr=new SessionAddress(InetAddress.getLocalHost(),port+20);
                   destAddress=new SessionAddress(ipAddr,port,1);
                   Integer myipprefix=Integer.valueOf(ipAddress.substring(0,3));
                   if((myipprefix.intValue()>223) && (myipprefix.intValue()<240)){
                        rtpMgrs[a].initialize(destAddress);
                   }else{
                        rtpMgrs[a].initialize(localAddr);
                   rtpMgrs[a].addTarget(destAddress);
                   System.out.println(" Created RTP session: "+ipAddress+" "+port+" to "+destAddress);
                   infoField.setText(" Created RTP session: "+ipAddress+" "+port+" to "+destAddress);
                   if(videoDataOutput!=null){
                        sendStream=rtpMgrs[a].createSendStream(videoDataOutput,0);
                        sendStream.start();
                        System.out.println(" RTP stream is started..");
                        infoField.setText(" RTP stream is started..");
              }catch(UnsupportedFormatException ex){
                   System.out.println(" --X Unsupported Format : "+ex);
                   infoField.setText(" --X Unsupported Format : "+ex);
              catch(IOException ioe){
                   System.out.println(" --X IOException : "+ioe.getMessage());
                   infoField.setText(" --X IOException : "+ioe.getMessage());
              catch(Exception ex){
                   System.out.println(" --X Unable to create RTP Manager...");
                   System.out.println(ex.getMessage());
                   infoField.setText(" --X Unable to create RTP Manager..."+ex.getMessage());
         /*public void createMyTransmitter()
         try{
              if(videoDataOutput!=null){
                   sendStream=rtpMgrs[i].createSendStream(videoDataOutput,0);
                   sendStream.start();
         }catch(UnsupportedFormatException ex){
                   System.out.println(" --X Unsupported Format : "+ex);
                   infoField.setText(" --X Unsupported Format : "+ex);
         catch(IOException ioe){
                   System.out.println(" --X IOException : "+ioe.getMessage());
                   infoField.setText(" --X IOException : "+ioe.getMessage());
         public void stopTransmitter(){
              if(processor!=null){
                   processor.stop();
                   processor.close();
                   processor=null;
                   // Loop through RTP Managers and close all managers..
                   // Dispose them for garbage collection
                   for(int i=0;i<rtpMgrs.length;i++){
                        rtpmgrs[i].removeSendStream(this);
                        rtpMgrs[i].removeTargets("Session ended..");
                        rtpMgrs[i].dispose();
                   //rtpMgrs.removeTargets("Session ended..");
                   //rtpMgrs.dispose();
         * StateListener class to handle Controller events
         class StateListener implements ControllerListener{
              public void controllerUpdate(ControllerEvent ce){
                   if(ce instanceof ControllerClosedEvent){
                        processor.close();
                   /* Handle all controller events and notify all
                   waiting thread in waitForState method */
                   if(ce instanceof ControllerEvent){
                        synchronized(getStateLock()){
                             getStateLock().notifyAll();
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    Client Applet
    import javax.media.*;
    import javax.media.protocol.*;
    import javax.media.protocol.DataSource;
    import javax.media.control.BufferControl;
    import javax.media.control.*;
    import javax.media.format.*;
    import javax.media.rtp.*;
    import javax.media.rtp.rtcp.*;
    import javax.media.rtp.event.*;
    import com.sun.media.rtp.RTPSessionMgr;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import java.io.*;
    import java.net.*;
    import java.net.URL;
    import java.net.Socket;
    /*<applet code="clientPlayerApplet.class" width="400" height="300">
         <param name=ServerIPS value="192.168.0.9">
         <param name=ServerPort value="80">
         <param name=TimeToLive value="1">
         <param name=archive value="clientPlayerApplet.jar">
    </applet> */
    public class clientPlayerApplet extends JApplet implements ControllerListener, ReceiveStreamListener,SessionListener
         String sessions[]=null;
         RTPManager rtpmgrs[]=null;     
         boolean dataReceived=false;
         Object myDataSync=new Object();
         private Player player;
         //private String serveripadd="226.10.10.20";
         //private int serverPort=2020;
         //private int timeToLive=1;
         private JPanel panel;
         private Vector currentParticipant;
         public void init()
              panel=new JPanel();
              setLayout(new BorderLayout());
              add("Center",panel);
              //String[] urls;
              /*urls[0]=getParameter("ServerIPS");
              urls[1]="/";
              urls[2]=getParameter("ServerPort");*/
              String []urls={new String(getParameter("ServerIPS")+"/"+getParameter("ServerPort")+"/"+getParameter("TimeToLive"))};
              sessions=urls;          
              initializePlayer();
         public void initializePlayer(){
              try{
                   InetAddress ipAddr;
                   SessionAddress localAddr=new SessionAddress();
                   SessionAddress destAddr;
                   rtpmgrs=new RTPManager[sessions.length];
                   currentParticipant=new Vector();
                   //rtpmgrs=new RTPManager();
                   SessionLabel session=null;
                   //Open RTP session
                   for(int i=0;i<sessions.length;i++){
                        try{
                             session=new SessionLabel(sessions[i]);
                             //session=new SessionLabel(sessions);
                        }catch(IllegalArgumentException iae){
                             System.out.println(" --X Unable to parse the sesion address given");     
                        System.out.println(" - Open RTP session for "+session.port);
                        rtpmgrs[i]=(RTPManager) RTPManager.newInstance();               
                        rtpmgrs[i].addSessionListener(this);
                        rtpmgrs[i].addReceiveStreamListener(this);
                        ipAddr=InetAddress.getByName(session.addr);
                        if(ipAddr.isMulticastAddress()){
                             localAddr=new SessionAddress(ipAddr,session.port,session.ttl);
                             destAddr=new SessionAddress(ipAddr,session.port,session.ttl);
                        }else{
                             localAddr=new SessionAddress(InetAddress.getLocalHost(),session.port);     
                             destAddr=new SessionAddress(ipAddr,session.port);
                        rtpmgrs[i].initialize(localAddr);
                        BufferControl bc=(BufferControl)rtpmgrs[i].getControl("javax.media.control.BufferControl");
                        if(bc!=null)
                             bc.setBufferLength(600);
                        rtpmgrs[i].addTarget(destAddr);
              }catch(Exception ex){
                   System.out.println(" --X Cannot create RTP Session "+ex.getMessage());
              long currentTime=System.currentTimeMillis();
              long waitingDuration=10000;
              try{
                   synchronized(myDataSync){
                        while(!dataReceived && (System.currentTimeMillis() - currentTime < waitingDuration)){
                             if(!dataReceived){
                                  myDataSync.wait(1000);
              }catch(Exception ex){
                   System.out.println(" --X myDataSync interrupted...");
              if(!dataReceived){
                   System.out.println(" No RTP Stream Data is received.." );               
         public void destroy()
              for(int i=0;i<currentParticipant.size();i++){
                   //if(player!=null)
                        ((MyPlayList)currentParticipant.elementAt(i)).close();
              // Loop through the RTP Managers
              // -> Remove the stream listener
              // -> Remove the target address
              // -> Dispose the RTP Manager for garbage collection
              currentParticipant.removeAllElements();
              for(int i=0;i<rtpmgrs.length;i++){
                   if(rtpmgrs[i]!=null){
                        rtpmgrs[i].removeReceiveStreamListener(this);
                        rtpmgrs[i].removeTargets(" Closing session..");
                        rtpmgrs[i].dispose();
                        rtpmgrs[i]=null;
         MyPlayList find(Player pl){
              for(int i=0;i<currentParticipant.size();i++){
                   MyPlayList mpl=(MyPlayList)currentParticipant.elementAt(i);
                   if(mpl.clientPlay==pl)
                        return mpl;
              return null;
         MyPlayList find(ReceiveStream rs){
              for(int i=0;i<currentParticipant.size();i++){
                   MyPlayList mpl=(MyPlayList)currentParticipant.elementAt(i);
                   if(mpl.stream==rs)
                        return mpl;
              return null;
         *     ReceiveStream Listener function                    *
         public synchronized void update(ReceiveStreamEvent rse)
              RTPManager mgr=(RTPManager)rse.getSource();
              ReceiveStream stream=rse.getReceiveStream();
              Participant participant=rse.getParticipant();
              if(rse instanceof RemotePayloadChangeEvent){
                   System.out.println(" -- Received Payload Change Event..");
                   System.out.println(" Sorry, no payload change is allowed.");               
              }else if(rse instanceof NewReceiveStreamEvent){
                   try{
                        // Once the new stream is detected, create the datasource
                        stream=((NewReceiveStreamEvent)rse).getReceiveStream();
                        DataSource outputDS=stream.getDataSource();
                        // Get RTP Controller to find the format
                        RTPControl rtpctl=(RTPControl)outputDS.getControl("javax.media.rtp.RTPControl");
                        if(rtpctl!=null){
                             System.out.println(" -> Received new rtP stream: "+rtpctl.getFormat());
                        }else
                             System.out.println(" -> Received new RTP stream");
                        if(participant!=null){
                             System.out.println(" -> New stream received from: "+participant.getCNAME());
                        }else{
                             System.out.println(" -> New stream detected... ");
                        player=Manager.createPlayer(outputDS);
                        if(player==null)
                             return;
                        System.out.println(" - Player is created...");
                        player.addControllerListener(this);
                        player.realize();
                        // Helper class to identify the player and stream
                        MyPlayList mpl=new MyPlayList(player,stream);
                        // Add the helper class object to Vector
                        currentParticipant.addElement(mpl);
                        // Notify initializePlayer() that a new stream has arrived
                        synchronized(myDataSync){
                             dataReceived=true;
                             myDataSync.notifyAll();
                   }catch(Exception ex){
                        System.out.println(" --X NewReceiveStream Exception: "+ex.getMessage());
                        return;
              }else if(rse instanceof ByeEvent){
                   System.out.println(" - BYE packet received from "+participant.getCNAME());
                   MyPlayList mpls=find(stream);
                   if(player!=mpls){
                        mpls.close();
                        currentParticipant.removeElement(mpls);
                   if(mgr!=null){
                        mgr.removeReceiveStreamListener(this);
                        mgr.removeTargets(" Closing session..");
                        mgr.dispose();
                        mgr=null;
              }else if(rse instanceof StreamMappedEvent){
                   if(stream!=null && stream.getDataSource()!=null){
                        DataSource myds=stream.getDataSource();
                        RTPControl rtpctrl=(RTPControl)myds.getControl("javax.media.rtp.RTPControl");
                        System.out.println(" -> The previously unidentified stream ");
                        if(rtpctrl!=null)
                             System.out.println(" "+rtpctrl.getFormat());
                        System.out.println(" has been identified as sent by :"+participant.getCNAME());
         *           Session Listener
         public void update(SessionEvent sesevt)
              if(sesevt instanceof NewParticipantEvent){
                   Participant part=((NewParticipantEvent)sesevt).getParticipant();
                   System.out.println(" -> A new partcipant has joined :"+part.getCNAME());
         *     ControllerListener for Players          
         public synchronized void controllerUpdate(ControllerEvent ce)
              Player p=(Player)ce.getSource();
              if(p==null)
                   return;
              if(ce instanceof RealizeCompleteEvent){
                   MyPlayList mpls=find(p);
                   if(mpls!=null){
                        p.start();
                        if(p.getVisualComponent()!=null){
                             panel.add(player.getVisualComponent());
                             panel.validate();
              if(ce instanceof ControllerErrorEvent){
                   p.removeControllerListener(this);
                   MyPlayList mpls=find(p);
                   if(mpls!=null){
                        // Close the player
                        // Remove the player helper class object from the list
                        p.close();
                        currentParticipant.removeElement(mpls);
                   System.out.println("Receiver internal error: "+ce);
         class SessionLabel{
              public String addr=null;
              public int port;
              public int ttl;
              SessionLabel(String session) throws IllegalArgumentException
                   int off;
                   String portStr=null;
                   String ttlStr=null;
                   if(session!=null && session.length() >0){
                        while(session.length()>1 && session.charAt(0)=='/')
                             session=session.substring(1);
                        off=session.indexOf('/');
                        if(off==-1){
                             if(!session.equals(""))
                                  addr=session;
                        }else{
                             addr=session.substring(0,off);
                             session=session.substring(off+1);
                             off=session.indexOf('/');
                             if(off==-1){
                                  if(!session.equals(""))
                                       portStr=session;
                             }else{
                                  portStr=session.substring(0,off);
                                  session=session.substring(off+1);
                                  off=session.indexOf('/');
                                  if(off==-1){
                                       if(!session.equals(""))
                                            ttlStr=session;
                                  }else{
                                       ttlStr=session.substring(0,off);
                   if(addr==null)
                        throw new IllegalArgumentException();
                   if(portStr!=null)
                        try{
                             Integer ints=Integer.valueOf(portStr);
                             if(ints!=null)
                                  port=ints.intValue();
                        }catch(Throwable t){
                             System.out.println(" --X PortStr Error..");
                             throw new IllegalArgumentException();
                   }else
                        throw new IllegalArgumentException();
                   if(ttlStr!=null){
                   try{
                        Integer intsttl=Integer.valueOf(ttlStr);
                        if(intsttl!=null)
                             ttl=intsttl.intValue();
                   }catch(Throwable t){
                             System.out.println(" --X PortStr Error..");
                             throw new IllegalArgumentException();
         class MyPlayList{
              Player clientPlay;
              ReceiveStream stream;
              MyPlayList(Player p,ReceiveStream rs){
                   clientPlay=p;
                   stream=rs;
              public void close()
                   clientPlay.close();

  • Last_page button is not working in table control-urgent

    hi  all,
    iam displaying the data in table control.in my pf-status i have first_page,next_page,prev_page and last_page.out of 4 buttons 3 buttons are working finr except last_page. any body can send me the code for this program.iam sending my program below.
    REPORT ZMAHI_TABLE_CONTROL .
    TABLES : VBAK,VBAP.
    DATA : BEGIN OF ITAB OCCURS 0,
             VBELN TYPE VBAK-VBELN,
             ERDAT TYPE VBAK-ERDAT,
             ERNAM TYPE VBAK-ERNAM,
             ERZET TYPE VBAK-ERZET,
             REASON(40) TYPE C,
           END OF ITAB.
    DATA :   FILL TYPE I VALUE 1.
    DATA : N TYPE I .
    DATA      : BEGIN OF XVALUES OCCURS 50,
                  BUTXT LIKE  T001-BUTXT,
                END OF XVALUES.
    DATA      : BEGIN OF XFIELDS OCCURS 50.
            INCLUDE STRUCTURE HELP_VALUE.
    DATA      : END OF XFIELDS.
    DATA      : BEGIN OF SEL_VAL OCCURS 50.
            INCLUDE STRUCTURE HELP_VTAB.
    DATA      : END OF SEL_VAL.
    TABLE CONTROL DECLARATIONS------
    CONTROLS : CONTROL_DATA TYPE TABLEVIEW USING  SCREEN '100'.
    DATA : OK_CODE TYPE SY-UCOMM,
    LIN TYPE I,
    LIN1 TYPE I,
    LIN2 TYPE I,
    LIN3 TYPE I.
    DATA: LINES TYPE I,
          LIMIT TYPE I VALUE 1.
    DATA :   LINE_COUNT       TYPE  I,
             LINEI            TYPE  I,
             LINEJ            TYPE  I,
             LINE1            TYPE  I,
             LINE2            TYPE  I,
             LN1              TYPE  I.
    SELECTION-SCREEN : BEGIN OF BLOCK B1.
    SELECT-OPTIONS   : P_VBELN FOR VBAK-VBELN.
    SELECTION-SCREEN : END OF BLOCK B1.
    START-OF-SELECTION.
      SELECT VBELN
             ERDAT
             ERNAM
             ERZET
        FROM VBAK
        INTO TABLE ITAB
      WHERE VBELN IN P_VBELN.
      CALL SCREEN 100.
    *&      Module  F4_HELP  INPUT
    MODULE F4_HELP INPUT.
      FREE  :  XFIELDS,SEL_VAL,XVALUES.
      MOVE : 'ZMAHI'     TO XFIELDS-TABNAME,
             'REASON'    TO XFIELDS-FIELDNAME,
             'X'        TO XFIELDS-SELECTFLAG.
      APPEND XFIELDS.
      XVALUES = 'Non Trade F&F'.
      APPEND XVALUES .
      XVALUES = 'Non Trade Retention'.
      APPEND XVALUES .
      XVALUES = 'Oldbills Accnt cntmnt'.
      APPEND XVALUES .
      XVALUES = 'Non Trade Not claimed'.
      APPEND XVALUES .
      XVALUES = 'Non Trade Dispute'.
      APPEND XVALUES .
      XVALUES = 'Non Trade Payment Block'.
      APPEND XVALUES .
      XVALUES = 'N/T Subsntly Cleared'.
      APPEND XVALUES .
      XVALUES = 'N/T Unstld Advances'.
      APPEND XVALUES .
      XVALUES = 'N/T OThers'.
      APPEND XVALUES .
      XVALUES = 'Trade Non Receipt OF BOE'.
      APPEND XVALUES .
      XVALUES = 'Trade OEM Adjustments'.
      APPEND XVALUES .
      XVALUES = 'Trade Reject Of Material'.
      APPEND XVALUES .
      XVALUES = 'Trade NOt Claimed'.
      APPEND XVALUES .
      XVALUES = 'Trade Dispute'.
      APPEND XVALUES .
      XVALUES = 'Trade Payment BLock'.
      APPEND XVALUES .
      XVALUES = 'Trade Subsntly Cleared'.
      APPEND XVALUES .
      XVALUES = 'Trade Non Submission of bills'.
      APPEND XVALUES .
      XVALUES = 'Trade others'.
      APPEND XVALUES .
      CALL FUNCTION 'HELP_VALUES_GET_WITH_TABLE_EXT'
           EXPORTING
                CUCOL         = 0
                CUROW         = 0
                DISPLAY       = ' '
                FIELDNAME     = 'REASON'
                TABNAME       = 'ZIFIOD011'
           IMPORTING
                SELECT_VALUE  = ITAB-REASON
           TABLES
                FIELDS        = XFIELDS
                SELECT_VALUES = SEL_VAL
                VALUETAB      = XVALUES.
    ENDMODULE.                 " F4_HELP  INPUT
    *&      Module  STATUS_0100  OUTPUT
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS '0100'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'CANCEL' OR 'EXIT' OR 'BACK'.
          LEAVE TO SCREEN 0.
       WHEN 'NEXT_LINE'.
         CONTROL_DATA-top_line = CONTROL_DATA-top_line + 1.
         limit = fill - lines + 1.
         IF CONTROL_DATA-top_line > limit.
           CONTROL_DATA-top_line = limit.
         ENDIF.
       WHEN 'PREV_LINE'.
         CONTROL_DATA-top_line = CONTROL_DATA-top_line - 1.
         IF CONTROL_DATA-top_line < 0.
           CONTROL_DATA-top_line = 0.
         ENDIF.
        WHEN 'NEXT_PAGE'.
          CONTROL_DATA-TOP_LINE = CONTROL_DATA-TOP_LINE + LINES.
          LIMIT = LIMIT + 1.
          CONTROL_DATA-TOP_LINE = LIMIT.
        WHEN 'PREV_PAGE'.
          CONTROL_DATA-TOP_LINE = CONTROL_DATA-TOP_LINE - LINES.
          LIMIT = LIMIT - 1.
          CONTROL_DATA-TOP_LINE = LIMIT.
       WHEN 'LAST_PAGE'.
         CONTROL_DATA-TOP_LINE =  FILL - LINES + 1.
        WHEN 'FIRST_PAGE'.
          CONTROL_DATA-TOP_LINE = 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  SCROLL_BAR  INPUT
    MODULE SCROLL_BAR INPUT.
      DESCRIBE  TABLE  ITAB  LINES  CONTROL_DATA-LINES.
    ENDMODULE.                 " SCROLL_BAR  INPUT
    thanks,
    maheedhar.T

    Hi Ravi,
    The code which u sent to me is not working for next page and previous page.
    can u plz resend me the code.
    iam sending my code below.
    REPORT ZMAHI_TABLE_CONTROL .
    TABLES : VBAK,VBAP.
    DATA : BEGIN OF ITAB OCCURS 0,
             VBELN TYPE VBAK-VBELN,
             ERDAT TYPE VBAK-ERDAT,
             ERNAM TYPE VBAK-ERNAM,
             ERZET TYPE VBAK-ERZET,
             REASON(40) TYPE C,
           END OF ITAB.
    DATA :   FILL TYPE I VALUE 1.
    DATA : N TYPE I .
    DATA      : BEGIN OF XVALUES OCCURS 50,
                  BUTXT LIKE  T001-BUTXT,
                END OF XVALUES.
    DATA      : BEGIN OF XFIELDS OCCURS 50.
            INCLUDE STRUCTURE HELP_VALUE.
    DATA      : END OF XFIELDS.
    DATA      : BEGIN OF SEL_VAL OCCURS 50.
            INCLUDE STRUCTURE HELP_VTAB.
    DATA      : END OF SEL_VAL.
    TABLE CONTROL DECLARATIONS------
    CONTROLS : CONTROL_DATA TYPE TABLEVIEW USING  SCREEN '100'.
    DATA : OK_CODE TYPE SY-UCOMM,
    LIN TYPE I,
    LIN1 TYPE I,
    LIN2 TYPE I,
    LIN3 TYPE I.
    DATA: LINES TYPE I,
          LIMIT TYPE I VALUE 1.
    DATA :   LINE_COUNT       TYPE  I,
             LINEI            TYPE  I,
             LINEJ            TYPE  I,
             LINE1            TYPE  I,
             LINE2            TYPE  I,
             LN1              TYPE  I.
    SELECTION-SCREEN : BEGIN OF BLOCK B1.
    SELECT-OPTIONS   : P_VBELN FOR VBAK-VBELN.
    SELECTION-SCREEN : END OF BLOCK B1.
    START-OF-SELECTION.
      SELECT VBELN
             ERDAT
             ERNAM
             ERZET
        FROM VBAK
        INTO TABLE ITAB
      WHERE VBELN IN P_VBELN.
      CALL SCREEN 100.
    *&      Module  F4_HELP  INPUT
    MODULE F4_HELP INPUT.
      FREE  :  XFIELDS,SEL_VAL,XVALUES.
      MOVE : 'ZMAHI'     TO XFIELDS-TABNAME,
             'REASON'    TO XFIELDS-FIELDNAME,
             'X'        TO XFIELDS-SELECTFLAG.
      APPEND XFIELDS.
      XVALUES = 'Non Trade F&F'.
      APPEND XVALUES .
      XVALUES = 'Non Trade Retention'.
      APPEND XVALUES .
      XVALUES = 'Oldbills Accnt cntmnt'.
      APPEND XVALUES .
      XVALUES = 'Non Trade Not claimed'.
      APPEND XVALUES .
      XVALUES = 'Non Trade Dispute'.
      APPEND XVALUES .
      XVALUES = 'Non Trade Payment Block'.
      APPEND XVALUES .
      XVALUES = 'N/T Subsntly Cleared'.
      APPEND XVALUES .
      XVALUES = 'N/T Unstld Advances'.
      APPEND XVALUES .
      XVALUES = 'N/T OThers'.
      APPEND XVALUES .
      XVALUES = 'Trade Non Receipt OF BOE'.
      APPEND XVALUES .
      XVALUES = 'Trade OEM Adjustments'.
      APPEND XVALUES .
      XVALUES = 'Trade Reject Of Material'.
      APPEND XVALUES .
      XVALUES = 'Trade NOt Claimed'.
      APPEND XVALUES .
      XVALUES = 'Trade Dispute'.
      APPEND XVALUES .
      XVALUES = 'Trade Payment BLock'.
      APPEND XVALUES .
      XVALUES = 'Trade Subsntly Cleared'.
      APPEND XVALUES .
      XVALUES = 'Trade Non Submission of bills'.
      APPEND XVALUES .
      XVALUES = 'Trade others'.
      APPEND XVALUES .
      CALL FUNCTION 'HELP_VALUES_GET_WITH_TABLE_EXT'
           EXPORTING
                CUCOL         = 0
                CUROW         = 0
                DISPLAY       = ' '
                FIELDNAME     = 'REASON'
                TABNAME       = 'ZIFIOD011'
           IMPORTING
                SELECT_VALUE  = ITAB-REASON
           TABLES
                FIELDS        = XFIELDS
                SELECT_VALUES = SEL_VAL
                VALUETAB      = XVALUES.
    ENDMODULE.                 " F4_HELP  INPUT
    *&      Module  STATUS_0100  OUTPUT
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS '0100'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'CANCEL' OR 'EXIT' OR 'BACK'.
          LEAVE TO SCREEN 0.
       WHEN 'NEXT_LINE'.
         CONTROL_DATA-top_line = CONTROL_DATA-top_line + 1.
         limit = fill - lines + 1.
         IF CONTROL_DATA-top_line > limit.
           CONTROL_DATA-top_line = limit.
         ENDIF.
       WHEN 'PREV_LINE'.
         CONTROL_DATA-top_line = CONTROL_DATA-top_line - 1.
         IF CONTROL_DATA-top_line < 0.
           CONTROL_DATA-top_line = 0.
         ENDIF.
       WHEN 'NEXT_PAGE'.
         CONTROL_DATA-TOP_LINE = CONTROL_DATA-TOP_LINE + LINES.
         LIMIT = LIMIT + 1.
         CONTROL_DATA-TOP_LINE = LIMIT.
       WHEN 'PREV_PAGE'.
         CONTROL_DATA-TOP_LINE = CONTROL_DATA-TOP_LINE - LINES.
         LIMIT = LIMIT - 1.
         CONTROL_DATA-TOP_LINE = LIMIT.
       WHEN 'LAST_PAGE'.
         DESCRIBE TABLE ITAB LINES LIMIT.
         CONTROL_DATA-TOP_LINE =  LIMIT.
       WHEN 'FIRST_PAGE'.
         CONTROL_DATA-TOP_LINE = 0.
    WHEN 'P--'.
    CLEAR ok_code.
    PERFORM paging USING 'P--'.
    WHEN 'P-'.
    CLEAR ok_code.
    PERFORM paging USING 'P-'.
    WHEN 'P+'.
    CLEAR ok_code.
    PERFORM paging USING 'P+'.
    WHEN 'P++'.
    CLEAR ok_code.
    PERFORM paging USING 'P++'.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  SCROLL_BAR  INPUT
    MODULE SCROLL_BAR INPUT.
      DESCRIBE  TABLE  ITAB  LINES  CONTROL_DATA-LINES.
    ENDMODULE.                 " SCROLL_BAR  INPUT
    *&      Form  paging
          text
         -->P_0356   text
    *FORM paging USING    VALUE(P_0356).
    FORM paging USING code.
    DATA: i TYPE i,
    j TYPE i.
    CASE code.
    WHEN 'P--'.
    CONTROL_DATA-top_line = 1.
    WHEN 'P-'.
    CONTROL_DATA-top_line = CONTROL_DATA-top_line - line_count.
    IF CONTROL_DATA-top_line LE 0.
    CONTROL_DATA-top_line = 1.
    ENDIF.
    WHEN 'P+'.
    i = CONTROL_DATA-top_line + line_count.
    j = CONTROL_DATA-lines - line_count + 1.
    IF j LE 0. j = 1. ENDIF.
    IF i LE j.
    CONTROL_DATA-top_line = i.
    ELSE.
    CONTROL_DATA-top_line = j.
    ENDIF.
    WHEN 'P++'.
    CONTROL_DATA-top_line = CONTROL_DATA-lines - line_count + 1.
    IF CONTROL_DATA-top_line LE 0.
    CONTROL_DATA-top_line = 1.
    ENDIF.
    ENDCASE.
    ENDFORM. " PAGING
    *ENDFORM.                    " paging
    thanks,
    maheedhar.t

  • MultiLineCellRenderer (TableCellRenderer) not working in 1.4

    I have the following custom TableCellRenderer I use to display a multi-line cell in a JTable. The row height is suppose to adjust itself automatically so that all the text is visible. This worked perfectly fine in 1.3. In 1.3, the JTextArea was given a preferred size after setting the text, so when calling the getPreferredSize() method, I would get the dimensions of the text area needed to display the entire text. In 1.4, however, I seem to get the default preferred size (100x34) even after setting the text, so my row height is never set properly. Does anybody have any work around for this?
    public class MultiLineCellRenderer extends JTextArea
      implements TableCellRenderer {
      JTable mTable;
        public MultiLineCellRenderer(JTable table) {
          super();
          mTable = table;
          setLineWrap(true);
          setWrapStyleWord(true);
          setOpaque(true);
          setEditable(false);
        public Component getTableCellRendererComponent(JTable jTable,
            Object obj, boolean isSelected, boolean hasFocus, int row,
            int column) {
          // set the text
          setText((obj == null)?"":obj.toString());
          // get the current row height
          int height = mTable.getRowHeight(row);
          System.out.println("Get Preferred Size: " + getPreferredSize());
          System.out.println("Get Size: " + getSize());
          // if the current height is insufficient, resize the row height
          if (height < this.getPreferredSize().getHeight()) {
            mTable.setRowHeight(row, (int)(getPreferredSize().getHeight()));
          return this;
    }

    Hi,
    I am also using almost the similar code and using JDK1.3, but I am using my table in a scroll pane. Problem is that when I am using the scroll bar, sometimes the text in cells get wrapped and sometimes not.
    Some changes in my code from your code are :
    1. I am not extending my renderer from JTextArea, instead using a member variable of JTextArea in my renderer class and returning that after setting the text and row height from getTableCellRendererComponent() method.
    2. I am not keeping table as a member variable in the class. I am setting row height of the table instance that comes in the getTableCellRendererComponent() method.
    Can anyone tell me why it does not work while scrolling?
    My code is something like below:
    public class MultiLineCellRenderer implements TableCellRenderer {
       JTextArea myLabel;
         public MultiLineCellRenderer(JTable table) {
            myLabel = new JTextArea(); 
            myLabel.setLineWrap(true);
           myLabel.setWrapStyleWord(true);
           myLabel.setOpaque(true);
           myLabel.setEditable(false);
    public Component
    getTableCellRendererComponent(JTable jTable,
    Object obj, boolean isSelected, boolean
    boolean hasFocus, int row,
             int column) {
           // set the text
           myLable.setText((obj == null)?"":obj.toString());
           // get the current row height
           int height = jTable.getRowHeight(row);
    // if the current height is different, resize the row height
    if (height != myLabel.getPreferredSize().getHeight()) {
    jTable.setRowHeight(row, (int)(getPreferredSize().getHeight()));
           return myLabel;

  • If not working correctly

    Hi I am new to Java programming and I have written a program to compute parking fees and my if statements seem to not be working right because they calculate the wrong amounts. It should calculate this way: $2.20 minimum for the first hour. $1.60 for every hour after that with a $7.00 maximum. I tried using ceil() but couldn't get that to work at all. I have attached my whole program in case that helps. But my if statements seem to be the only thing not working. Thank you in advance for any help.
    import java.awt.*;          //Container, Flowlayout
    import java.awt.event.*;     //ActionEvent, ActionListener
    import javax.swing.*;          //JApplet, JLabel, JTextfield
    public class ParkingFeeCalculator extends JApplet implements ActionListener
    //declare labels
    JLabel hoursLabel, chargeLabel, totalchargesLabel;
    //declare text fields
    JTextField hoursField, chargeField, totalchargesField;
    double charge;
    double numberhours;
    double sumOfCharges;
    //setup GUI componenets
    public void init()
    //obtain content pane and change its layout to FlowLayout
    Container container = getContentPane();
    container.setLayout( new FlowLayout() );
    //create label and text field for Hours
    hoursLabel = new JLabel(" Hours");
    container.add(hoursLabel);
    hoursField = new JTextField (10);
    hoursField.setEditable( true );
    container.add( hoursField );
    //create label and text field for Charge
    chargeLabel = new JLabel(" Charge");
    container.add(chargeLabel);
    chargeField = new JTextField (10);
    chargeField.setEditable( false );
    container.add( chargeField );
    //create label and text field for Total Charges
    totalchargesLabel = new JLabel("Total Charges");
    container.add(totalchargesLabel);
    totalchargesField = new JTextField (10);
    totalchargesField.setEditable( false );
    container.add( totalchargesField);
    //register this applet as hoursField's ActionListener
    hoursField.addActionListener(this);
    }     //end init
    //process entry of hours
    public void actionPerformed( ActionEvent actionEvent)
    //call method calculateCharge
    double numberhours = calculateCharge();
    //obtain user's input convert double
    numberhours = Double.parseDouble (hoursField.getText());
    //enter number of hours
    if (numberhours <= 1)
    charge = 2.20;
    else if (numberhours >= 4)
    charge = 7.00;
    else
    charge = ((numberhours-1) * 1.60) + 2.20;
    }     //end method actionPerformed
    //enter number of hours, calculate charge, total charges, and display results
    public double calculateCharge()
    sumOfCharges = sumOfCharges + charge;
    //display results in text fields
    chargeField.setText("$" + Double.toString(charge));
    totalchargesField.setText("$" + Double.toString(sumOfCharges));
    return sumOfCharges;
    }     //end method calculateCharge
    }     //end class ParkingFeeCalculator

    int h = 0; // here should be your hours
    int i = h == 0 ? 0 : h = (h * 160 + 60) > 700 ? h : 700;
    float fine = h/700;what i do is i give fine of 0 for 0 hours
    and if there are more than 0 hours (1 or more) then fine is 1.60 times hours + 0.60 aditionally for first hour (2.20 - 1.60 = 0.60)
    and what i used there that for of if (tertial or what it's called)
    condition ? returned_value_if_true : returned_vale_if_false

  • Scrollbar not working in a JScrollPane

    In the JDialog there is a JScrollPane. JTextPane is in a the scroll pane. For some reason the scrollbars are not working.
    Any suggestions on this why the scrollbars not working?
    Thanks.

    using the setText() method the text is set to the text pane from some other package. the Dialog displays the text too with the vertical scroll bar that doesn't work.
    public MyDialog(JFrame frame) {
    super(frame);
    initialize();
    private void initialize() {
    this.setResizable(true);
    this.setName("");
    this.setUndecorated(false);
    this.setContentPane(getScrl());
    this.setSize(400, 300);
    this.centerDialog();
    private javax.swing.JScrollPane getScrl() {
    if (scrl == null) {
    scrl = new javax.swing.JScrollPane();
    scrl.setViewportView(getTxt());
    return scrl;
    private javax.swing.JTextPane getTxt() {
    if (txt == null) {
    txt = new javax.swing.JTextPane();
    txt.setBackground(java.awt.SystemColor.info);
    txt.setEditable(false);
    return txt;
    public void setText(String text) {
    if (txt.getEditorKit() == null) {
    txtToolTip.setEditorKit(new StyledEditorKit());
    txt.setContentType("text/html");
    txt.setOpaque(true);
    txt.setText(text);

  • Can not fine symbol... class SwingWorker is not working...

    Hi ,
    my code is like this. I am using netbeans ide 5.5.
    package concurrency;
    import java.util.List;
    import java.util.Random;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.GridBagLayout;
    import java.awt.GridBagConstraints;
    import java.awt.Insets;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    import javax.swing.SwingUtilities;
    import javax.swing.border.Border;
    import javax.swing.BorderFactory;
    import javax.swing.*;
    public class Flipper extends JFrame
    implements ActionListener {
    private final GridBagConstraints constraints;
    private final JTextField headsText, totalText, devText;
    private final Border border =
    BorderFactory.createLoweredBevelBorder();
    private final JButton startButton, stopButton;
    private FlipTask flipTask;
    private JTextField makeText() {
    JTextField t = new JTextField(20);
    t.setEditable(false);
    t.setHorizontalAlignment(JTextField.RIGHT);
    t.setBorder(border);
    getContentPane().add(t, constraints);
    return t;
    private JButton makeButton(String caption) {
    JButton b = new JButton(caption);
    b.setActionCommand(caption);
    b.addActionListener(this);
    getContentPane().add(b, constraints);
    return b;
    public Flipper() {
    super("Flipper");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Make text boxes
    getContentPane().setLayout(new GridBagLayout());
    constraints = new GridBagConstraints();
    constraints.insets = new Insets(3, 10, 3, 10);
    headsText = makeText();
    totalText = makeText();
    devText = makeText();
    //Make buttons
    startButton = makeButton("Start");
    stopButton = makeButton("Stop");
    stopButton.setEnabled(false);
    //Display the window.
    pack();
    setVisible(true);
    private static class FlipPair {
    private final long heads, total;
    FlipPair(long heads, long total) {
    this.heads = heads;
    this.total = total;
    private class FlipTask extends SwingWorker<Void, FlipPair> {
    @Override
    protected Void doInBackground() {
    long heads = 0;
    long total = 0;
    Random random = new Random();
    while (!isCancelled()) {
    total++;
    if (random.nextBoolean()) {
    heads++;
    publish(new FlipPair(heads, total));
    return null;
    @Override
    protected void process(List<FlipPair> pairs) {
    FlipPair pair = pairs.get(pairs.size() - 1);
    headsText.setText(String.format("%d", pair.heads));
    totalText.setText(String.format("%d", pair.total));
    devText.setText(String.format("%.10g",
    ((double) pair.heads)/((double) pair.total) - 0.5));
    public void actionPerformed(ActionEvent e) {
    if ("Start" == e.getActionCommand()) {
    startButton.setEnabled(false);
    stopButton.setEnabled(true);
    (flipTask = new FlipTask()).execute();
    } else if ("Stop" == e.getActionCommand()) {
    startButton.setEnabled(true);
    stopButton.setEnabled(false);
    flipTask.cancel(true);
    flipTask = null;
    public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    new Flipper();
    Though this code is taken from java.sun.com.
    but this code is not working.. It shows :
    Compiling 1 source file to F:\ ...\FlipperProject\build\classes
    F:\....\FlipperProject\src\concurrency\Flipper.java:73: cannot find symbol
    symbol : class SwingWorker
    location: class concurrency.Flipper
    private class FlipTask extends SwingWorker<Void, FlipPair> {
    F:\.......\FlipperProject\src\concurrency\Flipper.java:79: cannot find symbol
    symbol : method isCancelled()
    location: class concurrency.Flipper.FlipTask
    while (!isCancelled()) {
    F:\.....\FlipperProject\src\concurrency\Flipper.java:84: cannot find symbol
    symbol : method publish(concurrency.Flipper.FlipPair)
    location: class concurrency.Flipper.FlipTask
    publish(new FlipPair(heads, total));
    F:\.......\FlipperProject\src\concurrency\Flipper.java:74: method does not override a method from its superclass
    @Override
    F:\.......\FlipperProject\src\concurrency\Flipper.java:89: method does not override a method from its superclass
    @Override
    F:\......1\FlipperProject\src\concurrency\Flipper.java:105: cannot find symbol
    symbol : method execute()
    location: class concurrency.Flipper.FlipTask
    (flipTask = new FlipTask()).execute();
    F:\............\FlipperProject\src\concurrency\Flipper.java:109: cannot find symbol
    symbol : method cancel(boolean)
    location: class concurrency.Flipper.FlipTask
    flipTask.cancel(true);
    7 errors
    BUILD FAILED (total time: 4 seconds)
    please help...

    try right-clicking on the source and select fix imports.

  • Chechbox header : deselect all not working

    folks,
    I have a jtable generated from my database. IT has 3 columns . The 3rd column has checkboxes in it. I am implementing a "CHECK ALL"
    checkbox on the header for selection and deselection of checkboxes. the below code works for selection of all boxes.. IT DOES NOT
    WORK WHEN IT IS DESELECTED ? i want to make it work for deselection also
    I call the custom table renderer from main program as follows :
    tc = table.getColumnModel().getColumn(3);
    tc.setHeaderRenderer(new CustomTableCellRenderer1(new MyItemListener(),Name));
    this is item listner in main program for checkbox "check all" present in the table header :
    class MyItemListener implements ItemListener
    public void itemStateChanged(ItemEvent e) {
    Object source = e.getSource();
    if (source instanceof AbstractButton == false) return;
    boolean checked=e.getStateChange() == ItemEvent.SELECTED;
    for(int x = 0, y = table.getRowCount(); x < y; x++)
    table.setValueAt(new Boolean(checked),x,3);
    if (e.getStateChange() == ItemEvent.DESELECTED) // dosent work
    System.out.println("deselect all"); // may b code for deselection
    this is CustomTableCellRenderer1 class below:
    package moxaclient;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.awt.event.*;
    class CustomTableCellRenderer1 extends JCheckBox
    implements TableCellRenderer, MouseListener {
    private static final long serialVersionUID = 1L;
    protected CustomTableCellRenderer1 rendererComponent;
    protected int column;
    String Name;
    private JTable table1;
    Object abc=null;
    protected boolean mousePressed = false;
    public CustomTableCellRenderer1(ItemListener itemListener,String name) {
    rendererComponent = this;
    rendererComponent.addItemListener(itemListener);
    this.Name=name;
    public Component getTableCellRendererComponent(
    JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
    if (table != null) {
    JTableHeader header = table.getTableHeader();
    this.table1=table;
    if (header != null) {
    rendererComponent.setForeground(header.getForegrou nd());
    rendererComponent.setBackground(header.getBackgrou nd());
    rendererComponent.setFont(header.getFont());
    header.addMouseListener(rendererComponent);
    setColumn(column);
    rendererComponent.setText("Check All");
    setBorder(UIManager.getBorder("TableHeader.cellBor der"));
    return rendererComponent;
    protected void setColumn(int column) {
    this.column = column;
    public int getColumn() {
    return column;
    protected void handleClickEvent(MouseEvent e) {
    if (mousePressed) {
    mousePressed=false;
    JTableHeader header = (JTableHeader)(e.getSource());
    JTable tableView = header.getTable();
    TableColumnModel columnModel = tableView.getColumnModel();
    int viewColumn = columnModel.getColumnIndexAtX(e.getX());
    int column = tableView.convertColumnIndexToModel(viewColumn);
    if (viewColumn == this.column && e.getClickCount() == 1 && column != -1) {
    doClick();
    int row=table1.getRowCount();
    if(row!=0)
    for(int i=0;i<=row-1;i++)
    String Sensor =(String) table1.getValueAt(i, column-3); // // when checkbox selectedthis code gets all value present in table and stores in string abc
    Double Value =(Double) table1.getValueAt(i, column-2);
    String Date =(String) table1.getValueAt(i, column-1);
    abc += Sensor+"\t"+Value+"\t"+Name+"\t"+Date+"\t";
    public void mouseClicked(MouseEvent e) {
    handleClickEvent(e);
    ((JTableHeader)e.getSource()).repaint();
    public void mousePressed(MouseEvent e) {
    mousePressed = true;
    public void mouseReleased(MouseEvent e) {
    public void mouseEntered(MouseEvent e) {
    public void mouseExited(MouseEvent e) {
    plzz help.

    please add tags around the code in your posts.
    Dinud123 wrote:
    IT DOES NOT
    WORK WHEN IT IS DESELECTED ? i want to make it work for deselection alsoI don't know any user interface where I would toggle "select all" and "deselect all" via the same control. That may be for a reason.
    So my suggestion is: provide a second button for "deselect all".
    bye
    TPD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • Show Size of FOLDER in Finder List

    Leopard OS X 10.5.4, nor previous editions, doesn't show folder size in Finder list. Only method to get size is right click and then "get Info". Is there any way to show sizes of folders as a list? Note, individual file sizes are listed, but not fold

  • Does JCE 1.2.2 make use of a certificate with an expiration date?

    Does JCE 1.2.2 make use of a certificate with an expiration date? If so, what's the date?

  • IPod song list

    In iTunes 7.0.1, is there a way to see the songs on my iPod when it is connected? I want to delete some music to make room for other stuff, but I can't figure out how to do it.

  • Unused reports in OBIEE

    Hi, Is there any option in OBI to check what all the reports accessed by the users and the reports that were not accesses. I am basically interested in seeing the list of users who have accessed the reports and if so,what reports they have accessed.A

  • InDesign CC - Fusion de données : aperçu dynamique d'une couleur

    Bonjour à tous, Je travaille sur la création d'une charte graphique et plus précisément sur la définition des couleurs. Afin de permettre une modification facile de ces couleurs, j'ai utilisé la fusion des données. Ce que j'ai fait : Un document inDe