How to trigger an ActionListener in different class on click of a tree node

Hi guyz,
There are three panels inside my main Frame
-->TopPanel,MiddlePanel and BottomPanel. I have a tree structure inside a panel. This panel along with couple more panels is in MiddlePanel. My main class is "mainClass.java". Inside that i have an actionListener for a specific button. I need to trigger that actionListener when i click one of the tree nodes in the panel i specified before. The problem is that my MiddlePanel is itself a different ".java" file which is being called in my "mainClass" when a specific button is clicked. There are different buttons in my "mainClass" file and for each one i am creating different MiddlePanels depending on the buttons clicked.
So, if i click the tree node, i need to remove the MiddlePanel and recreate the MiddlePanel(One that will be created when a different button in the mainClass file is clicked). i.e., i need to trigger the actionListener for that corresponding button. Is there a way to do it?

use this code to call different panel by selecting tree node.....ok
import javax.swing.*;
import javax.swing.tree.*;
import java.awt.*;
import java.sql.SQLException;
import javax.swing.event.*;
class MainTree extends JFrame
private static final long serialVersionUID = 1L;
     CardLayout cl = new CardLayout();
     JPanel panel = new JPanel(cl);
public MainTree() throws Exception
JPanel blankPanel = new JPanel();
blankPanel.setBorder(BorderFactory.createTitledBorder("Blank Panel"));
panel.add(blankPanel,"0");
panel.add(blankPanel,BorderLayout.CENTER);
     panel.setPreferredSize(new Dimension(800, 100));
     setSize(1000, 700);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
// getContentPane().setLayout(new GridLayout(1,2));
getContentPane().setLayout(new BorderLayout());
ConfigTree test = new ConfigTree();
DefaultMutableTreeNode mainTree = (DefaultMutableTreeNode)test.buildTree();
JTree tree = new JTree(mainTree);
tree.setCellRenderer(new DefaultTreeCellRenderer(){
private static final long serialVersionUID = 1L;
     public Component getTreeCellRendererComponent(JTree tree,Object value,
boolean sel,boolean expanded,boolean leaf,int row,boolean hasFocus){
JLabel lbl = (JLabel)super.getTreeCellRendererComponent(tree,value,sel,expanded,leaf,row,hasFocus);
NodeWithID node = (NodeWithID)((DefaultMutableTreeNode)value).getUserObject();
if(node.icon != null)lbl.setIcon(node.icon);
return lbl;
getContentPane().add(new JScrollPane(tree));
loadCardPanels((DefaultMutableTreeNode)((DefaultTreeModel)tree.getModel()).getRoot());
getContentPane().add(panel,BorderLayout.EAST);
     getContentPane().add(blankPanel,BorderLayout.WEST);
// getContentPane().add(panel);
tree.addTreeSelectionListener(new TreeSelectionListener(){
public void valueChanged(TreeSelectionEvent tse){
NodeWithID node =(NodeWithID)((DefaultMutableTreeNode)((TreePath)tse.getPath())
.getLastPathComponent()).getUserObject();
if(node.nodePanel != null)
String cardLayoutID = node.ID;
cl.show(panel,cardLayoutID);
cl.show(panel,"0");
public void loadCardPanels(DefaultMutableTreeNode dmtn)
for(int x = 0; x < dmtn.getChildCount(); x++)
if(((DefaultMutableTreeNode)dmtn.getChildAt(x)).isLeaf() == false)
loadCardPanels((DefaultMutableTreeNode)dmtn.getChildAt(x));
NodeWithID node = (NodeWithID)((DefaultMutableTreeNode)dmtn.getChildAt(x)).getUserObject();
if(node.nodePanel != null)
String cardLayoutID = node.ID;
panel.add(cardLayoutID,node.nodePanel);
public static void main(String[] args) throws Exception{new MainTree().setVisible(true);}
class ConfigTree
public Object buildTree() throws Exception
NodeWithID n0 = new NodeWithID("HelpDesk","");
NodeWithID n1 = new NodeWithID("Administrator",n0.nodeName);
NodeWithID n2 = new NodeWithID("Report Form",n1.nodeName,new Tree().getContentPane());
NodeWithID n3 = new NodeWithID("Create User",n2.nodeName,new JPanel());
NodeWithID n4 = new NodeWithID("Unlock User",n2.nodeName,new unlockui().getContentPane());
NodeWithID n5 = new NodeWithID("List User",n2.nodeName,new JPanel());
NodeWithID n6 = new NodeWithID("Assign Role",n2.nodeName,new AssignRole());
NodeWithID n9 = new NodeWithID("Operator",n1.nodeName,new JPanel());
NodeWithID n10 = new NodeWithID("Create Ticket",n9.nodeName,new JPanel());
NodeWithID n11 = new NodeWithID("My Ticket",n9.nodeName,new JPanel());
NodeWithID n12 = new NodeWithID("All Ticket",n9.nodeName,new JPanel());
NodeWithID n13 = new NodeWithID("Event Viewer",n1.nodeName,new JPanel());
DefaultMutableTreeNode top = new DefaultMutableTreeNode(n0);
DefaultMutableTreeNode branch1 = new DefaultMutableTreeNode(n1);
top.add(branch1);
DefaultMutableTreeNode node1_b1 = new DefaultMutableTreeNode(n2);
DefaultMutableTreeNode n1_node1_b1 = new DefaultMutableTreeNode(n3);
DefaultMutableTreeNode n2_node1_b1 = new DefaultMutableTreeNode(n4);
DefaultMutableTreeNode n3_node1_b1 = new DefaultMutableTreeNode(n5);
DefaultMutableTreeNode n4_node1_b1 = new DefaultMutableTreeNode(n6);
branch1.add(node1_b1);
branch1.add(n1_node1_b1);
branch1.add(n2_node1_b1);
branch1.add(n3_node1_b1);
branch1.add(n4_node1_b1);
DefaultMutableTreeNode node4_b1 = new DefaultMutableTreeNode(n9);
DefaultMutableTreeNode n1_node4_b1 = new DefaultMutableTreeNode(n10);
DefaultMutableTreeNode n2_node4_b1 = new DefaultMutableTreeNode(n11);
DefaultMutableTreeNode n3_node4_b1 = new DefaultMutableTreeNode(n12);
node4_b1.add(n1_node4_b1);
node4_b1.add(n2_node4_b1);
node4_b1.add(n3_node4_b1);
DefaultMutableTreeNode node5_b1 = new DefaultMutableTreeNode(n13);
branch1.add(node1_b1);
branch1.add(node4_b1);
branch1.add(node5_b1);
return top;
class NodeWithID
String nodeName;
String ID;
JPanel nodePanel;
ImageIcon icon;
public NodeWithID(String nn,String parentName)
nodeName = nn;
ID = parentName+" - "+nodeName;
public NodeWithID(String nn,String parentName,Container container)
this(nn,parentName);
nodePanel = (JPanel) container;
nodePanel.setBorder(BorderFactory.createTitledBorder(ID + " Panel"));
public NodeWithID(String nn,String parentName,JPanel p, ImageIcon i)
this(nn,parentName,p);
icon = i;
public String toString(){return nodeName;}
}

Similar Messages

  • How to display a search(query) on a report clicking on a tree node to open

    I need to know how can I do with that when I press on the link(on a tree node(leaf)), open on the other region in the same page a classic or interactive report with my results(passed by parameter, example: ID).
    One example are present on web site posted below:
    http://apex.oracle.com/pls/apex/f?p=36648:34:1599336964673301::NO:::
    I have tried this to composite my tree:
    select case when connect_by_isleaf = 1 then 0 when level = 1 then 1 else -1 end as status, level, "NAME" as title, null as icon, "ID" as value, null as tooltip, decode(level, 1, 'f?p=&APP_ID.:106:'||:APP_SESSION||'::::P106_MAQ_ID:'||ID, 2,'f?p=&APP_ID.:106:'||:APP_SESSION||'::::::::P106_MAQ_ID:'||(ID-1000), 3,'f?p=&APP_ID.:104:'||:APP_SESSION||'::::P106_MAQ_ID:'||(ID-10000), 4,'f?p=&APP_ID.:105:'||:APP_SESSION||'::::P106_MAQ_ID:'||(ID-100000)) as link from "#OWNER#"."V_TREE1" start with "PID" is null connect by prior "ID" = "PID" order siblings by "NAME"
    But the parameter passed dont do with the report change your view to the one row with ID passed. I need to obtain the same results showed on website posted above.
    I obtained success on action to redirect to other page with Form with Report to edit, but dont to show. And i want to show and the same page.
    below the code that i obtained to redirect:
    select case when connect_by_isleaf = 1 then 0 when level = 1 then 1 else -1 end as status, level, "NAME" as title, null as icon, "ID" as value, null as tooltip, decode(level, 1, 'f?p=&APP_ID.:102:'||:APP_SESSION||'::::P102_MAQ_ID:'||ID, 2,'f?p=&APP_ID.:103:'||:APP_SESSION||'::::P103_SRV_ID:'||(ID-1000), 3,'f?p=&APP_ID.:104:'||:APP_SESSION||'::::P104_INS_ID:'||(ID-10000), 4,'f?p=&APP_ID.:105:'||:APP_SESSION||'::::P105_SIS_ID:'||(ID-100000)) as link from "#OWNER#"."V_TREE1" start with "PID" is null connect by prior "ID" = "PID" order siblings by "NAME"
    Thank you so much for your help.

    Muhammad,
    you can add a user parameter (p_count), which get the default value value 1 for example. Then add a field (with some source of type character like desname) for your footer with a format trigger like
    if :p_count=1 then
         srw.set_field_char(0,'Office Copy');
    elsif :p_count=2 then
         srw.set_field_char(0,'Shop Copy');
    else
         srw.set_field_char(0,'Account Dept Copy');
    end;
    return true;
    Or you build 3 boilerplates with format triggers like
    if :p_count=1 then return true; else return false; end if; for "Office Copy" .....
    In the After Report Trigger start the Report with same paramters using a higher value for p_count as parameter. If p_count=3, do nothing in the trigger.
    Regards
    Rainer

  • How to trigger event when double click on a tree node

    I have this code which creates new tab in a remote Java Class.
    treeView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<String>>()
       @Override
       public void changed(ObservableValue<? extends TreeItem<String>> observable, TreeItem<String> oldValue, TreeItem<String> newValue)
       System.out.println("Selected Text : " + newValue.getValue());
       // Create New Tab
       Tab tabdata = new Tab();
       Label tabALabel = new Label("Test");
      tabdata.setGraphic(tabALabel);
       DataStage.addNewTab(tabdata);
    Can you tell me how I can modify the code to open new tab when I double click on a tree node. In my code the tab is opened when I click once. What event handler do I need?

    import java.util.Arrays;
    import javafx.application.Application;
    import javafx.event.EventHandler;
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.StackPane;
    import javafx.scene.control.TreeCell;
    import javafx.scene.control.TreeView;
    import javafx.scene.control.TreeItem;
    import javafx.scene.control.SelectionMode;
    import javafx.util.Callback;
    public class TreeTest extends Application {
      public static void main(String[] args) {
        launch(args);
      @Override
      public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("TreeView Test");
        primaryStage.setScene(createScene());
        primaryStage.show();
      private Scene createScene() {
        final StackPane stackPane = new StackPane();
        final TreeView<String> treeView = new TreeView<String>();
        treeView.setRoot(createModel());
        treeView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
        treeView.setCellFactory(new Callback<TreeView<String>, TreeCell<String>>() {
          @Override
          public TreeCell<String> call(TreeView<String> treeView) {
            return new ClickableTreeCell();
        stackPane.getChildren().add(treeView);
        return new Scene(stackPane);
      private TreeItem<String> createModel() {
        TreeItem<String> root = new TreeItem<String>("RootNode");
        TreeItem<String> packageA = new TreeItem<String>("package A");
        packageA.getChildren().addAll(
            Arrays.asList(new TreeItem<String>("A1"), new TreeItem<String>("A2"), new TreeItem<String>("A3"))
        TreeItem<String> packageB = new TreeItem<String>("package B");
        packageB.getChildren().addAll(
            Arrays.asList(new TreeItem<String>("B1"), new TreeItem<String>("B2"), new TreeItem<String>("B3"))
        root.getChildren().addAll(Arrays.asList(packageA, packageB));
        return root;
      private class ClickableTreeCell extends TreeCell<String> {
        ClickableTreeCell() {
          setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
              // Handle double-clicks on non-empty cells:
              if (event.getClickCount()==2 && ! isEmpty()) {
                System.out.println("Mouse double-clicked on: " + getItem());
        @Override
        protected void updateItem(String item, boolean empty) {
          super.updateItem(item, empty);
          if (empty) {
            setText(null);
          } else {
            setText(item);

  • How to access form objects from different class?

    Hello, I am new to java and i started with netbeans 6 beta,
    when i create java form application from template i get 2 classes one ends with APP and one with VIEW,
    i put for example jTextField1 with the form designer to the form and i can manipulate it's contents easily from within it's class (let's say it is MyAppView).
    Question>
    How can i access jTextField1 value from different class that i created in the same project?
    please help. and sorry for such newbie question.
    Thanks Mike

    hmm now it says
    non static variable jTree1 can not be referenced from static context
    My code in ClasWithFormObjects is
    public static void setTreeModel (DefaultMutableTreeNode treemodel){
    jTree1.setModel(new DefaultTreeModel(treemodel));
    and in Class2 it is
    ClasWithFormObjects.setTreeModel(model);

  • How to find the coordinates of a mouse click in a Tree node ?

    Hello
    I have a JTree that have few nodes. The nodes contain an icon and a label (using custom cell renderer) and I want to receive right clicks on the icon and show a popup menu.
    The problem is I can only get the right click on the whole tree node, not only the icon.
    I tried two approaches:
    1. register the mouse listener directly with the icon in the cell renderer. That doesnt work since the events received by the tree node do not propagate to its sub-components.
    2. Register the event with the JTree itself and then try to find which part of the tree node was clicked (see if it was within the coordinates of the icon).
    But I cant get the node's coordinates or width.
    I tried using SwingUtilities.convertPoint or SwingUtilities.ConvertMouseEvent but it just doesnt work with DefaultMutableTreeNode.
    Any ideas how to do it ?

    user11973359 wrote:
    1. register the mouse listener directly with the icon in the cell renderer. That doesnt work since the events received by the tree node do not propagate to its sub-components.No, it doesn't work because a renderer isn't added to any component hierarchy. It isn't in any way a 'sub-component'.
    Read about editor and renderer concepts in the Oracle tutorial on How to Use Tables.
    user11973359 wrote:
    2. Register the event with the JTree itself and then try to find which part of the tree node was clicked (see if it was within the coordinates of the icon).
    But I cant get the node's coordinates or width.<tt>getPathForLocation(...) </tt>in conjunction with<tt> getPathBounds(...)</tt>.
    db

  • How to trigger a workflow though a class event

    Hi,
    I have created a class and included interface IF_WORKFLOW in the interface. Also created a event 'START' with one parameter. I have created a workflow and assigned the class event 'START' as its triggerring event.
    I want to trigger my workflow from a custom program. But I am not able to trigger the workflow by passing the event container.
    How do I start trigger the class event with the req. container element?

    Hi
    You could check the class CL_HRECM00_WORKFLOW_EVENT, together with the corresponding workflows of package
    PAOC_ECM_ADM_PLANNING_OVERVIEW.
    Best Regards
    Raquel

  • Actionlistener in different class then the button

    hello,
    i am stuck on this piece of code and i think somebody here will be able to help me out :).
    i have these classes.
    ButtonPanel, Test.
    in the buttonpanel i have a few buttons, but the actionlistener is an innerClass in Test.
    when i want to add one of my actionlisteners in my ButtonPanel class the compiler cannot resolve symbol.
    this is a snippet of code:
    the buttons in buttonpanel class:
    btnStart = new JButton("Start");
    btnStart.addActionListener(new startActionListener());
    btnStop = new JButton("Stop");
    btnStop.addActionListener(new stopActionListener());
    btnTest = new JButton("Test");
    btnTest.addActionListener(new testActionListener());The actionlisteners in Test class:
    public class startActionListener implements ActionListener{
    public void actionPerformed(ActionEvent e){
    java.awt.Toolkit.getDefaultToolkit().beep();//werkt niet
    public class stopActionListener implements ActionListener{
    public void actionPerformed(ActionEvent e){
    java.awt.Toolkit.getDefaultToolkit().beep();//werkt niet
    public class testActionListener implements ActionListener{
    public void actionPerformed(ActionEvent e){
    java.awt.Toolkit.getDefaultToolkit().beep();//werkt niet
    }so basically its just how do use actionlisteners in the class that extends from the JFrame, in stead of in de ButtonPanel class where the buttons are?

    URgent help need.
    i need to link the page together : by clicking the button on the index page.
    it will show the revelant class file. I have try my ationPerformed method to the actionlistener, it cannot work.
    Thanks in advance.
    // class mtab
    // the tab menu where it display the gui
    import javax.swing.*;
    import java.awt.*;
    public class mtab {
    private static final int frame_height = 480;
    private static final int frame_width = 680;
    public static void main (String [] args){
    JFrame frame = new JFrame ("Mrt Timing System");
    frame.setDefaultCloseOperationJFrame.EXIT_ON_CLOSE);
    frame.setSize(frame_width,frame_height);
    JTabbedPane tp = new JTabbedPane ();
    tp.addTab("Mrt Timing System", new sample());
    frame.setResizable(false);
    frame.getContentPane().add(tp);
    frame.setSize(680,480);
    frame.show();
    // index page
    // class sample
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Image;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    import java.text.*;
    import javax.swing.border.*;
    class sample extends JPanel implements ActionListener
    //button
    private JButton TimingButton;
    private JButton ViewButton;
    private JButton FrequencyButton;
    private JButton calculateButton;
    private CardLayout mycard;
    private JPanel SelectXPanel;
    private JPanel SelectYPanel;
    private JPanel SelectZPanel;
    private JPanel bigFrame, mainPane;
    // constructor
    public sample() {
    super(new BorderLayout());
    //create the object
    //create button and set it
    TimingButton = new JButton("MRT Timing Calculator");
    TimingButton.addActionListener(this);
    ViewButton = new JButton("View First and Last Train");
    ViewButton.addActionListener(this);
    FrequencyButton = new JButton("Show the Train Frequency");
    FrequencyButton.addActionListener(this);
    // Layout
    //Lay out the button in a panel.
    JPanel buttonPane = new JPanel(new GridLayout(3,0));
    buttonPane.add(TimingButton);
    buttonPane.add(ViewButton);
    buttonPane.add(FrequencyButton);
    // Layout the button panel into another panel.
    JPanel buttonPane2 = new JPanel(new GridLayout(0,1));
    buttonPane2.add(buttonPane);
    tfrequency x = new tfrequency();
    fviewl2 y = new fviewl2 ();
    timing z = new timing ();
    JPanel SelectXPanel = new JPanel(new GridLayout(0,1));
    SelectXPanel.add(x);
    JPanel SelectYPanel = new JPanel(new GridLayout(0,1));
    SelectYPanel.add(y);
    JPanel SelectZPanel = new JPanel(new GridLayout(0,1));
    SelectZPanel.add(z);
    // Layout the button by putting in between the rigid area
    JPanel mainPane = new JPanel(new GridLayout(3,0));
    mainPane.add(Box.createRigidArea(new Dimension(0,1)));
    mainPane.add(buttonPane2);
    mainPane.add(Box.createRigidArea(new Dimension(0,1)));
    mainPane.setBorder(new TitledBorder("MRT Timing System"));
    // x = new tfrequency();
    // The overall panel -- divide the frame into two parts: west and east.
    JPanel bigFrame = new JPanel(new GridLayout(0,2));
    bigFrame.add(mainPane, BorderLayout.WEST);
    //bigFrame.add(x,BorderLayout.EAST); // this is where i want to link the page
    // this page being the index page. there being nothing to display.
    add(bigFrame);
    //Create the GUI and show it. For thread safety,
    public void actionPerformed (ActionEvent e){
    if (e.getSource() == TimingButton ){
    JPanel bigFrame = new JPanel(new GridLayout(0,2));
    bigFrame.add(mainPane, BorderLayout.WEST);
    bigFrame.add(SelectZPanel,BorderLayout.EAST);
    add(bigFrame);
    else if (e.getSource() == ViewButton ){
    JPanel bigFrame = new JPanel(new GridLayout(0,2));
    bigFrame.add(mainPane, BorderLayout.WEST);
    bigFrame.add(SelectYPanel,BorderLayout.EAST);
    add(bigFrame);
    else if (e.getSource() == FrequencyButton ){
    JPanel bigFrame2 = new JPanel(new GridLayout(0,2));
    bigFrame.add(mainPane, BorderLayout.WEST);
    bigFrame.add(SelectXPanel,BorderLayout.EAST);
    add(bigFrame);
    // Train Frequency Page
    // class fviewl2
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Image;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    import java.text.*;
    import javax.swing.border.*;
    class fviewl2 extends JPanel implements ActionListener
    //Labels to identify the fields
    private JLabel stationLabel;
    private JLabel firstLabel;
    private JLabel lastLabel;
    //Strings for the labels
    private static String station = "MRT Station:";
    private static String first = "First Train Time:";
    private static String last = "Last Train Time:";
    //Fields for data entry
    private JFormattedTextField stationField;
    private JFormattedTextField firstField;
    private JFormattedTextField lastField;
    //button
    private JButton homeButton;
    private JButton cancelButton;
    private JButton calculateButton;
    public fviewl2()
    super(new BorderLayout());
    //create the object
    //Create the Labels
    stationLabel = new JLabel(station);
    firstLabel = new JLabel (first);
    lastLabel = new JLabel (last) ;
    //Create the text fields .// MRT Station:
    stationField = new JFormattedTextField();
    stationField.setColumns(10);
    stationField.setBounds(300,300,5,5);
    //Create the text fields // First Train Time:
    firstField = new JFormattedTextField();
    firstField.setColumns(10);
    firstField.setBounds(300,300,5,5);
    //Create the text fields //Last Train Time:
    lastField = new JFormattedTextField();
    lastField.setColumns(10);
    lastField.setBounds(300,300,5,5);
    //Tell accessibility tools about label/textfield pairs, matching label for the field
    stationLabel.setLabelFor(stationField);
    firstLabel.setLabelFor(firstField);
    lastLabel.setLabelFor(lastField);
    //create button and set it
    homeButton = new JButton("Home");
    //homeButton.addActionListener(this);
    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(this);
    calculateButton = new JButton("Get Time");
    // Layout
    //MRT Station Label // insert into the panel
    JPanel StationPane = new JPanel(new GridLayout(0,1));
    StationPane.add(stationLabel);
    //MRT Station input field // insert into the panel
    JPanel StationInput = new JPanel(new GridLayout(0,1));
    StationInput.add(stationField);
    //Get Time Button // insert into the panel
    JPanel GetTime = new JPanel(new GridLayout(0,1));
    GetTime.add(calculateButton);
    //Lay out the labels in a panel.
    JPanel FlabelL = new JPanel(new GridLayout(0,1));
    FlabelL.add(firstLabel);
    FlabelL.add(lastLabel);
    // Layout the fields in a panel
    JPanel FFieldL = new JPanel(new GridLayout(0,1));
    FFieldL.add(firstField);
    FFieldL.add(lastField);
    //Lay out the button in a panel.
    JPanel buttonPane = new JPanel(new GridLayout(1,0));
    buttonPane.add(homeButton);
    buttonPane.add(cancelButton);
    // Layout all components in the main panel
    JPanel mainPane = new JPanel(new GridLayout(4,2));
    mainPane.add(StationPane);
    mainPane.add(StationInput);
    mainPane.add(Box.createRigidArea(new Dimension(0,1)));
    mainPane.add(GetTime);
    mainPane.add(FlabelL);
    mainPane.add(FFieldL);
    mainPane.add(Box.createRigidArea(new Dimension(0,1)));
    mainPane.add(buttonPane);
    mainPane.setBorder(new TitledBorder("View First and Last Train"));
    JPanel leftPane = new JPanel(new GridLayout(1,0));
    leftPane.add(Box.createRigidArea(new Dimension(0,1)));
    leftPane.add(mainPane);
    leftPane.add(Box.createRigidArea(new Dimension(0,1)));
    JPanel hahaFrame = new JPanel(new GridLayout(0,1));
    hahaFrame.add(Box.createRigidArea(new Dimension(0,1)));
    hahaFrame.setBorder(BorderFactory.createEmptyBorder(30, 10, 80, 150));
    hahaFrame.add(Box.createRigidArea(new Dimension(0,1)));
    JPanel bigFrame = new JPanel();
    bigFrame.add(hahaFrame, BorderLayout.NORTH);
    bigFrame.add(leftPane, BorderLayout.CENTER);
    add(bigFrame, BorderLayout.CENTER);
    //Create the GUI and show it. For thread safety,
    private void cancelButtonClicked()
    stationField.setText("");
    firstField.setText("");
    lastField.setText("");
    public void actionPerformed (ActionEvent e){
    if (e.getSource() == cancelButton){
    cancelButtonClicked();
    }

  • How to trigger a 'delete' across different related tables in ABAP?

    Hello All,
    I am creating database tables for storing different values of features coming under different countries. I have eight tables in my design and there are fields repeating in different tables, which i am connecting through foreign key relationship.
    After entering values to all my tables, if i need to delete a particular field value which is repeating in more than two tables, is it possible to trigger a delete event by which if am deleting the field value in a particular table, all the related field values also get deleted from the respective tables?
    For example, if i have a PRODUCT field in three tables, and if one of the PRODUCT is deleted from a particular table, can i trigger a delete event by which i can delete all the values related to that particular PRODUCT from all the related tables? The PRODUCT is a primary keyfield, and i have maintained proper foreign key relations also.
    I have tried deleting entries using the views and using the database table itself, but only that particular table value is being deleted.
    Is there any function module for triggering a delete?
    Can anyone help me with some solution?Sample code will be helpful.
    Thanks in Advance,
    Shino

    Hi,
    My friend it is not advisable to delete any field from a database  table bcoz it's creats incosistance data for all the other related tables, but there r few Function Modules that provide u this functionality.
    Such As:
    G_REPORT_DELETE_ADDFLD_ENTRY
    G_CATT_DELETE_TABLE_ENTRY
    RKE_DELETE_FIELDS_FROM_TABLE
    Regards

  • How to make versionable object of different class than Document?

    In the programmers reference is that every PublicObject can be versioned, but there are only samples for versioning documents. I would like to keep history on folder hierarchy changes, so I think I need a Folder that can be versioned.
    The question is how to do this?
    Should I override isVersionable method in subclass of Folder to return true?
    Please help

    Hi
    I am havin 10 text boxes in my application.
    But out of 10 , 3 will be always together(existence of one is not possible without the other two.)
    Now i want to create a vector of objects ( here object will consist of the value corresponding to these three boxes),there can be many elements in this vector.
    So i m thinking to make an inner class which have three String variables corresponding to these text boxes that exists together.
    What can b done ?

  • In java,how to trigger an event in one class from an event in another class

    i need sloution to thisbecause, when the swing components are colloborating each other,i need to control the components with respect to others events.

    eventListeners are the way to go.
    -Js

  • How to add style(color) info for the color used in ALV tree nodes

    I have an object for CL_GUI_ALV_TREE and I have added nodes to the tree and has set color for the nodes using 'STYLE' parameter. Now if I have to add the style info to the style(color) then how do I do it using the object I have?
    Edited by: Sujay V Koparde on Feb 20, 2008 4:27 AM

    Yes Eshwar, its similar to what you have written but my problem was that the style has already been assigned in the code and now I want to assign the style info(tooltip text) to the style(colour). I have an object of class cl_gui_alv_tree as of now and I am not able to find out as to how do I proceed to assign style information

  • Help with menus and variables in different classes.

    1) how do I change variables in different classes? My situation..
    I have a few tabbed panels/planes, that ask for different user inputs. I want the last tabbed panel/plane to have the inputs on 1 plane. Is that confusing?
    Code:
            JTabbedPane tp = new JTabbedPane();
            tp.addTab ("Kitchen", new KitchenPanel());
            tp.addTab ("Living Room", new LivingRoomPanel());
            tp.addTab ("Master Bedroom", new MasterBedPanel());
            tp.addTab ("Bedroom 1", new Bedroom1Panel());
            tp.addTab ("Bedroom 2", new Bedroom2Panel());
            tp.addTab ("Misc Use", new MiscPanel());
            tp.addTab ("Totals", new TotalsPanel());not the full thing obviously, but just so u see what im working with.
    2) How do popup menus work? I have a menu (File -> About | File -> How to Contact)
    I want The File->About menu item, to prompt a dialog
    The File -> How to to prompt a dialog
    Contact Menu(Not Item) to load a webpage
    thanks again for the help, and i hope its not to confusing
    Edited by: 2point2ek on May 25, 2009 9:51 PM

    It's better to think in terms of transferring data between object, rather than between classes.
    What you need is for the tab pane objects to have a reference to some common object to which the data is to be sent. This common object might be the total pane. It's generally better design to keep the data in separate objects from the presentation (in this case the totals pane), but at this stage that's probably just going to confuse you.
    The simplest way to get this reference in is to the pane objects is as a constructor argument, which the constructor of your pane objects saves in a field. As you create each pane you pass it a reference and it stores that reference for when it needs to save data.
    Then, when you click detect the action by which the user tells the program to store the data he's entered the pane class should call a method on the central data object, passing all the data from that pane. If there's a lot of it, wrap it up in an object (typically called a "data transfer object").
    The central data object would be responsible for dealing with this data, amending totals etc.. It might delegate responsibility for updating the display to a separate total pane object.

  • How do I access a gui component in a different class?

    I have a jpanel (mainwindow) in a japplet. mainwindow loads and displays a jpanel form (content1). How do I code a button on conent1 so that mainwindow loads and displays a different jpanel form(content2)? mainwindow, content1, and content2 are all in different classes/packages. Thanks in advance!

    Let your JPanel content1 forward its ActionEvents to its parent. For instance, you could define your content1 as follows:
    public class Content1 extends JPanel
        private ArrayList<ActionListener> actionListeners;
        private JButton myButton;
              public Content1()
             actionListeners = new ArrayList<ActionListener>();
             myButton = new JButton("Test");
             myButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                             forwardAction(e);
              public void addActionListener(ActionListener listener) {
             actionListeners.add(listener);
        protected void forwardAction(ActionEvent e) {
          for (ActionListener l: actionListeners) {
               l.actionPerformed(e);
    }Then you could let your mainWindow listen to content1:
    // in your main windows' code:
    Content1 content1 = new Content1();
    content1.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
              swapPane(e);    // create a method swapPane in your mainwindow that handles the switch to content2.
    });

  • How to trigger New page while using ALV with classes/oops?

    Hi All
    I am trying to print a report which has to show the data in two pages.
    I am using ALV with classes/oops.
    Though I am able to print the report but a new page is not coming. Whole of the data is coming in one single page.
    Please tell me as to how to trigger a NEW PAGE while using ALV with classes/oops.
    Please send some code samples also if available.
    Thanks in advance.
    Jerry

    using sort option you can do it. in case of grid/oo alv class ALV you can view that only in print mode/preview mode.
    in case of list you can view that directly.
    sort-fieldname = 'FIELDNAME'.
    sort-group = '*'  "triggers new page
    sort-up = 'X'.
    append sort to it_sort.

  • How to use the different class for each screen as well as function.

    Hi Experts,
    How to use the different class for each screen as well as function.
    With BestRegards,
    M.Thippa Reddy.

    Hi ThippaReddy,
    see this sample code
    Public Class ClsMenInBlack
    #Region "Declarations"
        'Class objects
        'UI and Di objects
        Dim objForm As SAPbouiCOM.Form
        'Variables
        Dim strQuery As String
    #End Region
    #Region "Methods"
        Private Function GeRate() As Double
                Return Double
        End Function
    #End Region
    Public Sub SBO_Appln_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean)
            If pVal.BeforeAction = True Then
                If pVal.MenuUID = "ENV_Menu_MIB" Then
                End If
            Else ' Before Action False
                End If
        End Sub
    #End Region
    End Class
    End Class
    Rgds
    Micheal
    Vasu Anna Regional Feeling a???? Just Kidding
    Edited by: micheal willis on Jul 27, 2009 5:49 PM
    Edited by: micheal willis on Jul 27, 2009 5:50 PM

Maybe you are looking for

  • Programmatically checking the security in content repository

    Hi all, Is there any way to programmatically check whether a user has access to the documents under a particular node in content repository(in my case I have to use deligated administration role to check for the role in my code)? I am using BEA conte

  • Can't get the correct Oracle Developer Suite 10g disk 1

    I tried to download Oracle Developer Suite 10g disk 1. After download completed, I check the size is only around 560mb, not 577mb. It is so wield. Then I followed the instruction and double-click the exe. I always got error it is not a win32 applicat

  • Problem with Cue Cards tutorial

    Hello, I have new JDeveloper, version 11.1.1.1.0. Now I'm trying to do some tutorials and I have a problem with «Build Web Application with EJB, JPA and JSF » . I think that I followed the instructions quite accurate, even if there is a light differe

  • How Long Is the Initial Start-Up Sequence of Time Capsule?

    My machine is still showing solid amber after 35+ minutes. I just configured it the first time with AirPort Utility. How long is a normal wait? In the event of what should I do? Thanks.

  • How to install Utility updates?

    I received a Toshiba Website Alert e-mail from [email protected] <[email protected]>. I downloaded the file "FTP-URL utils-xp-18142.zip". I did not find any instructions on how to install this update. Can someone please let me know what the installat