Help needed in swing

HI friends,
I have a GUI with 4 paem nels .On one panel ..i have a menu item
called "Create" when i click it an oval will be drawn on a canvas.
And i have the Buttons on the other panel .
I need to drag these buttons and drop them into the ovals.
Can any one help me wih the drag and drop functionality using swing.
Thanks in avance

Did you know there is a Swing forum where you can post Swing questions?
http://forum.java.sun.com/forum.jspa?forumID=57
If you do repost this there, please put a link in this thread to direct interested people to the new post.
I don't know anything about how to do drag-and-drop in Swing, so I can't help you directly with that. Good luck!

Similar Messages

  • Urgent help need on swing problem

    Dear friends,
    I met a problem and need urgent help from guru here, I am Swing newbie,
    I have following code and hope to draw lines between any two components at RUN-TIME, not at design time
    Please throw some skeleton code, Thanks so much!!
    code:
    package com.swing.test;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class LongguConnectLineCommponent
        public static void main(String[] args)
            JFrame f = new JFrame("Connecting Lines");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new ConnectionPanel());
            f.setSize(400,300);
            f.setLocation(200,200);
            f.setVisible(true);
    class ConnectionPanel extends JPanel
        JLabel label1, label2, label3, label4;
        JLabel[] labels;
        JLabel selectedLabel;
        int cx, cy;
        public ConnectionPanel()
            setLayout(null);
            addLabels();
            label1.setBounds( 25,  50, 125, 25);
            label2.setBounds(225,  50, 125, 25);
            label3.setBounds( 25, 175, 125, 25);
            label4.setBounds(225, 175, 125, 25);
            determineCenterOfComponents();
            ComponentMover mover = new ComponentMover();
            addMouseListener(mover);
            addMouseMotionListener(mover);
        public void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            Point[] p;
            for(int i = 0; i < labels.length; i++)
                for(int j = i + 1; j < labels.length; j++)
                    p = getEndPoints(labels, labels[j]);
    //g2.draw(new Line2D.Double(p[0], p[1]));
    private Point[] getEndPoints(Component c1, Component c2)
    Point
    p1 = new Point(),
    p2 = new Point();
    Rectangle
    r1 = c1.getBounds(),
    r2 = c2.getBounds();
    int direction = r1.outcode(r2.x, r2.y);
    switch(direction) // r2 located < direction > of r1
    case (Rectangle.OUT_LEFT): // West
    p1.x = r1.x;
    p1.y = r1.y;
    p2.x = r2.x + r2.width;
    p2.y = r2.y;
    if(r1.y > cy)
    p1.y = r1.y + r1.height;
    p2.y = r2.y + r2.height;
    break;
    case (Rectangle.OUT_TOP): // North
    p1.x = r1.x;
    p1.y = r1.y;
    p2.x = r2.x;
    p2.y = r2.y + r2.height;
    if(r1.x > cx && r2.x > cx)
    p1.x = r1.x + r1.width;
    p2.x = r2.x + r2.width;
    break;
    case (Rectangle.OUT_LEFT + Rectangle.OUT_TOP): // NW
    p1.x = r1.x;
    p1.y = r1.y;
    p2.x = r2.x + r2.width;
    p2.y = r2.y;
    if(r1.y > r2.y + r2.height)
    p2.y = r2.y + r2.height;
    break;
    case (Rectangle.OUT_RIGHT): // East
    p1.x = r1.x + r1.width;
    p1.y = r1.y;
    p2.x = r2.x;
    p2.y = r2.y;
    if(r1.y > cy)
    p1.y = r1.y + r1.height;
    p2.y = r2.y + r2.height;
    break;
    case (Rectangle.OUT_TOP + Rectangle.OUT_RIGHT): // NE
    p1.x = r1.x + r1.width;
    p1.y = r1.y;
    p2.x = r2.x;
    p2.y = r2.y;
    if(r1.y > cy)
    p1.y = r1.y + r1.height;
    p2.y = r2.y + r2.height;
    if(r1.y > r2.y + r2.height)
    p1.y = r1.y;
    else
    if(r1.y > r2.y + r2.height)
    p2.y = r2.y + r2.height;
    break;
    case (Rectangle.OUT_BOTTOM): // South
    p1.x = r1.x;
    p1.y = r1.y + r1.height;
    p2.x = r2.x;
    p2.y = r2.y;
    if(r1.x > cx && r2.x > cx)
    p1.x = r1.x + r1.width;
    p2.x = r2.x + r2.width;
    break;
    case (Rectangle.OUT_RIGHT + Rectangle.OUT_BOTTOM): // SE
    p1.x = r1.x + r1.width;
    p1.y = r1.y + r1.height;
    p2.x = r2.x;
    p2.y = r2.y;
    break;
    case (Rectangle.OUT_BOTTOM + Rectangle.OUT_LEFT): // SW
    p1.x = r1.x;
    p1.y = r1.y + r1.height;
    p2.x = r2.x;
    p2.y = r2.y;
    if(r1.x > r2.x + r2.width)
    p2.x = r2.x + r2.width;
    if(r1.x > cx && r2.x > cx)
    p1.x = r1.x + r1.width;
    p2.x = r2.x + r2.width;
    return new Point[] {p1, p2};
    private void determineCenterOfComponents()
    int
    xMin = Integer.MAX_VALUE,
    yMin = Integer.MAX_VALUE,
    xMax = 0,
    yMax = 0;
    for(int i = 0; i < labels.length; i++)
    Rectangle r = labels[i].getBounds();
    if(r.x < xMin)
    xMin = r.x;
    if(r.y < yMin)
    yMin = r.y;
    if(r.x + r.width > xMax)
    xMax = r.x + r.width;
    if(r.y + r.height > yMax)
    yMax = r.y + r.height;
    cx = xMin + (xMax - xMin)/2;
    cy = yMin + (yMax - yMin)/2;
    private class ComponentMover extends MouseInputAdapter
    Point offsetP = new Point();
    boolean dragging;
    public void mousePressed(MouseEvent e)
    Point p = e.getPoint();
    for(int i = 0; i < labels.length; i++)
    Rectangle r = labels[i].getBounds();
    if(r.contains(p))
    selectedLabel = labels[i];
    offsetP.x = p.x - r.x;
    offsetP.y = p.y - r.y;
    dragging = true;
    break;
    public void mouseReleased(MouseEvent e)
    dragging = false;
    public void mouseDragged(MouseEvent e)
    if(dragging)
    Rectangle r = selectedLabel.getBounds();
    r.x = e.getX() - offsetP.x;
    r.y = e.getY() - offsetP.y;
    selectedLabel.setBounds(r.x, r.y, r.width, r.height);
    determineCenterOfComponents();
    repaint();
    private void addLabels()
    label1 = new JLabel("Label 1");
    label2 = new JLabel("Label 2");
    label3 = new JLabel("Label 3");
    label4 = new JLabel("Label 4");
    labels = new JLabel[] {
    label1, label2, label3, label4
    for(int i = 0; i < labels.length; i++)
    labels[i].setHorizontalAlignment(SwingConstants.CENTER);
    labels[i].setBorder(BorderFactory.createEtchedBorder());
    add(labels[i]);

    If you need some help, be respectful of the forum rules and people will help. By using "urgent" in the title and bumping your message every 2 hours you're just asking to be ignored (which is what you ended up with).

  • Help needed in swing!urgently!

    Hi im new to java envirnoment.Im working on a project,i need to design a tutorial page.
    How do i write a program for asking user to input values for a matrix form? how to i design the page for this?
    How do i invoke a Japplet?Is it the same procedure as a awt applet?For awt applet,a html file is written inorder to invoke the program. so how about Japplets or more generally for swing components?
    Is there any reference for new users in the designing of user interface components.I need to bulid a simple one,with buttons,scroll.
    Anyone knows how to plot line graphs??

    Have a loo at the Java Tutorial:
    http://java.sun.com/docs/books/tutorial/
    and the Book "Java Look and Feel Design Guidelines":
    http://java.sun.com/products/jlf/ed2/book/index.html
    -Puce

  • Help needed with swings for socket Programming

    Im working on a Project for my MScIT on Distributed Computing...which involves socket programming(UDP)....im working on some algorithms like Token Ring, Message Passing interface, Byzantine, Clock Syncronisation...i hav almost finished working on these algorithms...but now i wanna give a good look to my programs..using swings but im very new to swings...so can anyone help me with some examples involving swings with socket programming...any reference...any help would be appreciated...please help im running out of time..
    thanking u in advance
    anDy

    hi im Anand(AnDY),
    i hav lost my AnDY account..plz reply to this topic keeping me in mind :p

  • Small help needed in Swing

    I have written a small hellow world code in swing....
    *import javax.swing.JFrame;*
    *import javax.swing.JLabel;*
    *public class HelloWorldSwing {*
      *public static void main(String[] args) {*
        *JFrame frame = new JFrame("HelloWorldSwing");*
        *final JLabel label = new JLabel("Hello World");*
        *frame.getContentPane().add(label);*
        *frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);*
        *frame.pack();*
        *frame.setVisible(true);*
    I've compiled this in a remote server, with the help of this site....
    http://www.innovation.ch/java/java_compile.html
    I have only JRE1.6.0_03 installed in my machine.....
    when I am trying to execute the program by.....
    F:>java HelloWorldSwing
    it is saying....
    Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldSwing
    Then I tried to run it othe way by html file....
    *<html>*
    *<applet class="HelloWorldSwing.class" height=200 width=200>*
    *</html>*
    can any one suggest....what to do to get it running?

    um.... how about get the JDK?
    Also, please don't try to use a non-applet program as if it were an applet. It won't work.
    Also, please go through the Sun Java tutorials, especially the first ones about getting started.
    Edited by: Encephalopathic on Feb 26, 2008 9:56 PM

  • Help needed with swing

    hi,
    Hi, .
    I have created a Jmenu called " Menu System Test window " and it contains toplevel menu item "File" and File Menu contains subitems "Product Evaluation" and "Exit".
    When i click File->Product Evaluation it displays a new Frame named "ProductEvaluationMeasurementTool" with some check boxes ,radiobuttons, buttons . Everything is ok with my code.
    My question is now i want to convert my application into applet ( at present it is written using swing and AWT).
    Can anyone tell me is it possible to converty my code into applet so that i can place it in a web page
    i am sending my code..
    Thanks in advance
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Component;
    import java.awt.Checkbox;
    import javax.swing.*;
    import java.text.DecimalFormat;
    // Make a main window with a top-level menu: File
    public class MainWindow extends JFrame {
      public MainWindow() {
        super("Menu System Test Window");
        setSize(500, 500);
        // make a top level File menu
        FileMenu fileMenu = new FileMenu(this);
        // make a menu bar for this frame
        // and add top level menus File and Menu
        JMenuBar mb = new JMenuBar();
        mb.add(fileMenu);
        setJMenuBar(mb);
        addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            exit();
      public void exit() {
        setVisible(false); // hide the Frame
        dispose(); // tell windowing system to free resources
        System.exit(0); // exit
      public static void main(String args[]) {
        MainWindow w = new MainWindow();
        w.setVisible(true);
    private static MainWindow w ;
    // Encapsulate the look and behavior of the File menu
    class FileMenu extends JMenu implements ActionListener {
        private MainWindow mw; // who owns us?
      private JMenuItem itmPE   = new JMenuItem("ProductEvaluation");
      private JMenuItem itmExit = new JMenuItem("Exit");
      public FileMenu(MainWindow main)
        super("File");
        this.mw = main;
        this.itmPE.addActionListener(this);
        this.itmExit.addActionListener(this);
        this.add(this.itmPE);
        this.add(this.itmExit);
      // respond to the Exit menu choice
      public void actionPerformed(ActionEvent e)
        if (e.getSource() == this.itmPE)
         Frame f1 = new Frame("ProductMeasurementEvaluationTool");
         f1.setSize(1290,1290);
         f1.setLayout(null);
         Label l1 = new Label("Select the appropriate metrics for Measurement Process Evaluation");
         l1.setBounds(380, 50, 380, 20);
         f1.add(l1);
         Label l2 = new Label("Architecture Metrics");
         l2.setBounds(170, 100, 110, 20);
         f1.add(l2);
         Label l3 = new Label("RunTime Metrics");
         l3.setBounds(500, 100, 110, 20);
         f1.add(l3);
         Label l4 = new Label("Documentation Metrics");
         l4.setBounds(840, 100, 130, 20);
         f1.add(l4);
         JRadioButton rb1 = new JRadioButton("Componenent Metrics",false);
         rb1.setBounds(190, 140, 133, 20);
         f1.add(rb1);
         JRadioButton rb2 = new JRadioButton("Task Metrics",false);
         rb2.setBounds(540, 140, 95, 20);
         f1.add(rb2);
         JRadioButton rb3 = new JRadioButton("Manual Metrics",false);
         rb3.setBounds(870, 140, 108, 20);
         f1.add(rb3);
         JRadioButton rb4 = new JRadioButton("Configuration Metrics",false);
         rb4.setBounds(190, 270, 142, 20);
         f1.add(rb4);
         JRadioButton rb6 = new JRadioButton("DataHandling Metrics",false);
         rb6.setBounds(540, 270, 142, 20);
         f1.add(rb6);
         JRadioButton rb8 = new JRadioButton("Development Metrics",false);
         rb8.setBounds(870, 270, 141, 20);
         f1.add(rb8);
         Checkbox  c10 = new Checkbox("Size");
         c10.setBounds(220, 170, 49, 20);
         f1.add(c10);
         Checkbox c11 = new Checkbox("Structure");
         c11.setBounds(220, 190, 75, 20);
         f1.add(c11);
         Checkbox c12 = new Checkbox("Complexity");
         c12.setBounds(220, 210, 86, 20);
         f1.add(c12);
         Checkbox c13 = new Checkbox("Size");
         c13.setBounds(220, 300, 49, 20);
         f1.add(c13);
         Checkbox c14 = new Checkbox("Structure");
         c14.setBounds(220, 320, 75, 20);
         f1.add(c14);
         Checkbox c15 = new Checkbox("Complexity");
         c15.setBounds(220, 340, 86, 20);
         f1.add(c15);
         Checkbox c19 = new Checkbox("Size");
         c19.setBounds(580, 170, 49, 20);
         f1.add(c19);
         Checkbox c20 = new Checkbox("Structure");
         c20.setBounds(580, 190, 75, 20);
         f1.add(c20);
         Checkbox c21 = new Checkbox("Complexity");
         c21.setBounds(580, 210, 86, 20);
         f1.add(c21);
         Checkbox c22 = new Checkbox("Size");
         c22.setBounds(580, 300, 49, 20);
         f1.add(c22);
         Checkbox c23 = new Checkbox("Structure");
         c23.setBounds(580, 320, 75, 20);
         f1.add(c23);
         Checkbox c24 = new Checkbox("Complexity");
         c24.setBounds(580, 340, 86, 20);
         f1.add(c24);
         Checkbox c28 = new Checkbox("Size");
         c28.setBounds(920, 170, 49, 20);
         f1.add(c28);
         Checkbox c29 = new Checkbox("Structure");
         c29.setBounds(920, 190, 75, 20);
         f1.add(c29);
         Checkbox c30 = new Checkbox("Complexity");
         c30.setBounds(920, 210, 86, 20);
         f1.add(c30);
         Checkbox c31 = new Checkbox("Size");
         c31.setBounds(920, 300, 49, 20);
         f1.add(c31);
         Checkbox c32 = new Checkbox("Structure");
         c32.setBounds(920, 320, 75, 20);
         f1.add(c32);
         Checkbox c33 = new Checkbox("Complexity");
         c33.setBounds(920, 340, 86, 20);
         f1.add(c33);
         JButton b1  = new JButton("Button1");
         b1.setBounds(230, 600, 120, 24);
         f1.add(b1);
         JButton b2  = new JButton("Button2");
         b2.setBounds(430, 600, 120, 24);
         f1.add(b2);
         JButton b3  = new JButton("Button3");
         b3.setBounds(630, 600, 120, 24);
         f1.add(b3);
         JButton b4  = new JButton("Button4");
         b4.setBounds(840, 600, 120, 24);
         f1.add(b4);
               f1.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e)
              System.exit(0);
         f1.setVisible(true);
        else
       { mw.exit();}

    The other thinks you needed depends upon your application
    i changed ur code to an applet program(a 2 min. job)
    please try it:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Component;
    import java.awt.Checkbox;
    import javax.swing.*;
    import java.text.DecimalFormat;
    //<APPLET CODE="MainWindow3.class" WIDTH=625 HEIGHT=500></APPLET>
    // Make a main window with a top-level menu: File
    public class MainWindow3 extends JApplet {
    public void init() {
    //setSize(500, 500);
    // make a top level File menu
    FileMenu fileMenu = new FileMenu(this);
    // make a menu bar for this frame
    // and add top level menus File and Menu
    JMenuBar mb = new JMenuBar();
    mb.add(fileMenu);
    setJMenuBar(mb);
    setVisible(true);
    /*addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    exit();
    public void exit() {
    setVisible(false); // hide the Frame
    //dispose(); // tell windowing system to free resources
    stop();
    setVisible(false);
    destroy();
    //System.exit(0); // exit
    /* public static void main(String args[]) {
    MainWindow3 w = new M();
    w.setVisible(true);
    private static MainWindow3 w ;
    // Encapsulate the look and behavior of the File menu
    class FileMenu extends JMenu implements ActionListener {
    private MainWindow3 mw; // who owns us?
    private JMenuItem itmPE = new JMenuItem("ProductEvaluation");
    private JMenuItem itmExit = new JMenuItem("Exit");
    public FileMenu(MainWindow3 main)
    super("File");
    this.mw = main;
    this.itmPE.addActionListener(this);
    this.itmExit.addActionListener(this);
    this.add(this.itmPE);
    this.add(this.itmExit);
    // respond to the Exit menu choice
    public void actionPerformed(ActionEvent e)
    if (e.getSource() == this.itmPE)
    JFrame f1 = new JFrame("ProductMeasurementEvaluationTool");
    f1.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    f1.setSize(1290,1290);
    f1.setLayout(null);
    Label l1 = new Label("Select the appropriate metrics for Measurement Process Evaluation");
    l1.setBounds(380, 50, 380, 20);
    f1.add(l1);
    Label l2 = new Label("Architecture Metrics");
    l2.setBounds(170, 100, 110, 20);
    f1.add(l2);
    Label l3 = new Label("RunTime Metrics");
    l3.setBounds(500, 100, 110, 20);
    f1.add(l3);
    Label l4 = new Label("Documentation Metrics");
    l4.setBounds(840, 100, 130, 20);
    f1.add(l4);
    JRadioButton rb1 = new JRadioButton("Componenent Metrics",false);
    rb1.setBounds(190, 140, 133, 20);
    f1.add(rb1);
    JRadioButton rb2 = new JRadioButton("Task Metrics",false);
    rb2.setBounds(540, 140, 95, 20);
    f1.add(rb2);
    JRadioButton rb3 = new JRadioButton("Manual Metrics",false);
    rb3.setBounds(870, 140, 108, 20);
    f1.add(rb3);
    JRadioButton rb4 = new JRadioButton("Configuration Metrics",false);
    rb4.setBounds(190, 270, 142, 20);
    f1.add(rb4);
    JRadioButton rb6 = new JRadioButton("DataHandling Metrics",false);
    rb6.setBounds(540, 270, 142, 20);
    f1.add(rb6);
    JRadioButton rb8 = new JRadioButton("Development Metrics",false);
    rb8.setBounds(870, 270, 141, 20);
    f1.add(rb8);
    Checkbox c10 = new Checkbox("Size");
    c10.setBounds(220, 170, 49, 20);
    f1.add(c10);
    Checkbox c11 = new Checkbox("Structure");
    c11.setBounds(220, 190, 75, 20);
    f1.add(c11);
    Checkbox c12 = new Checkbox("Complexity");
    c12.setBounds(220, 210, 86, 20);
    f1.add(c12);
    Checkbox c13 = new Checkbox("Size");
    c13.setBounds(220, 300, 49, 20);
    f1.add(c13);
    Checkbox c14 = new Checkbox("Structure");
    c14.setBounds(220, 320, 75, 20);
    f1.add(c14);
    Checkbox c15 = new Checkbox("Complexity");
    c15.setBounds(220, 340, 86, 20);
    f1.add(c15);
    Checkbox c19 = new Checkbox("Size");
    c19.setBounds(580, 170, 49, 20);
    f1.add(c19);
    Checkbox c20 = new Checkbox("Structure");
    c20.setBounds(580, 190, 75, 20);
    f1.add(c20);
    Checkbox c21 = new Checkbox("Complexity");
    c21.setBounds(580, 210, 86, 20);
    f1.add(c21);
    Checkbox c22 = new Checkbox("Size");
    c22.setBounds(580, 300, 49, 20);
    f1.add(c22);
    Checkbox c23 = new Checkbox("Structure");
    c23.setBounds(580, 320, 75, 20);
    f1.add(c23);
    Checkbox c24 = new Checkbox("Complexity");
    c24.setBounds(580, 340, 86, 20);
    f1.add(c24);
    Checkbox c28 = new Checkbox("Size");
    c28.setBounds(920, 170, 49, 20);
    f1.add(c28);
    Checkbox c29 = new Checkbox("Structure");
    c29.setBounds(920, 190, 75, 20);
    f1.add(c29);
    Checkbox c30 = new Checkbox("Complexity");
    c30.setBounds(920, 210, 86, 20);
    f1.add(c30);
    Checkbox c31 = new Checkbox("Size");
    c31.setBounds(920, 300, 49, 20);
    f1.add(c31);
    Checkbox c32 = new Checkbox("Structure");
    c32.setBounds(920, 320, 75, 20);
    f1.add(c32);
    Checkbox c33 = new Checkbox("Complexity");
    c33.setBounds(920, 340, 86, 20);
    f1.add(c33);
    JButton b1 = new JButton("Button1");
    b1.setBounds(230, 600, 120, 24);
    f1.add(b1);
    JButton b2 = new JButton("Button2");
    b2.setBounds(430, 600, 120, 24);
    f1.add(b2);
    JButton b3 = new JButton("Button3");
    b3.setBounds(630, 600, 120, 24);
    f1.add(b3);
    JButton b4 = new JButton("Button4");
    b4.setBounds(840, 600, 120, 24);
    f1.add(b4);
    f1.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e)
    { mw.destroy();
    //System.exit(1);
    f1.setVisible(true);
    else
    { mw.exit();}
    If this program is a demo one then, no problem if it is a live & more important one. It is not OK!. It need more professional............

  • HELP NEEDED: FIRST SWING AT ECOMMERCE

    Im doing a site for a catering company and I need to get my
    hands on some tools that would be useful for building the ecommerce
    part. I havnt really done that much with ecommerce and the company
    wants nothing to do with paypal. They want orders to be sent via
    email to both the company and the customer as well (basically as a
    confirmation) . Any help getting pointed in the right direction
    would be amazing!
    thanks

    I second the nomination for cartweaver
    In addition to ease of customization and good company
    support,
    there is a fairly active newgroup-based user community as
    well.
    "JetCityKid(WA)" <[email protected]> wrote
    in message
    news:fnmo5l$a81$[email protected]..
    > Im doing a site for a catering company and I need to get
    my hands on some
    > tools
    > that would be useful for building the ecommerce part. I
    havnt really done
    > that
    > much with ecommerce and the company wants nothing to do
    with paypal. They
    > want
    > orders to be sent via email to both the company and the
    customer as well
    > (basically as a confirmation) . Any help getting pointed
    in the right
    > direction
    > would be amazing!
    >
    > thanks
    >

  • Help needed regarding swing

    i have a frame which contains a number of internal frames these internal frames contains jtable .my probem is that i need to update the cell data of on jtable upon pop action and then display that data upon another internal frames jtable .

    my actual problem is that i have a frame which contains may internal frames these internal frames contains jtable.now what i wans to do is suppose i do popup ipon any internal frames jtables cell then a popup menu comes which has a textbox and a ok button when i click ok then that integer values goes into the databse and at the same time this particular value get dis[layed upon another internal frames jtable.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Help needed-regarding swing component and linux

    Hi
    I am trying to run java program on Linux machine which doesn't have GUI support. Due to that following exception is throwing,
    java.awt.HeadlessException:
    No X11 DISPLAY variable was set, but this program performed an operation which requires it.
    at java.awt.GraphicsEnvironment.checkHeadless(Unknown Source)
    at java.awt.Window.<init>(Unknown Source)
    at java.awt.Frame.<init>(Unknown Source)
    at javax.swing.JFrame.<init>(Unknown Source)
    at org.jfree.ui.ApplicationFrame.<init>(ApplicationFrame.java:66)
    at ismschart.AbstractIsmsChart.<init>(AbstractIsmsChart.java:82)
    at ismschart.CHART_DAILY_PEAK_ACTIVITY.<init>(CHART_DAILY_PEAK_ACTIVITY.java:56)
    at ismschart.jChartTbl.createIsmsChart(jChartTbl.java:197)
    at ismschart.jChartTbl.main(jChartTbl.java:98)
    Can any one tell me, How to overcome this?
    Is there any tool which provides UI support for Linux?
    Thnaks
    -Ravi

    cut and paste from API
    Thrown when code that is dependent on a keyboard, display, or mouse is called in an environment that does not support a keyboard, display, or mouse.
    environment issue

  • Help needed in understanding GridBagLayout situation

    I have a JPanel with a JInternalFrame and a few JPanels inside of it. The JPanel is using GridBagLayout.
    When a user moves the JInternalFrame inside of the panel what is happening exactly? How is it moving the frame with relation to the Layout? It doesn't appear to be bound by the Layout. When the user drags the frame to a new location what methods are being invoked?

    Having looked at the JXMapViewer which extedns XJPanel and XJPanel extends JPanel.
    so if you want to get notified you need to add ComponentListener to the instance of JXMapViewer to get notificed when the following happens
    The below is a copy from java tutorial for internalframe and I have added the MyComponentListener just to give you some ideas.
    Hope this could help
    import javax.swing.JInternalFrame;
    import javax.swing.JDesktopPane;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import javax.swing.JMenuBar;
    import javax.swing.JFrame;
    import javax.swing.KeyStroke;
    import java.awt.event.*;
    import java.awt.*;
    * InternalFrameDemo.java requires:
    *   MyInternalFrame.java
    public class InternalFrameDemo extends JFrame
                                   implements ActionListener {
        JDesktopPane desktop;
        public InternalFrameDemo() {
            super("InternalFrameDemo");
            //Make the big window be indented 50 pixels from each edge
            //of the screen.
            int inset = 50;
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            setBounds(inset, inset,
                      screenSize.width  - inset*2,
                      screenSize.height - inset*2);
            //Set up the GUI.
            desktop = new JDesktopPane(); //a specialized layered pane
            createFrame(); //create first "window"
            setContentPane(desktop);
            setJMenuBar(createMenuBar());
            //Make dragging a little faster but perhaps uglier.
            desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
        protected JMenuBar createMenuBar() {
            JMenuBar menuBar = new JMenuBar();
            //Set up the lone menu.
            JMenu menu = new JMenu("Document");
            menu.setMnemonic(KeyEvent.VK_D);
            menuBar.add(menu);
            //Set up the first menu item.
            JMenuItem menuItem = new JMenuItem("New");
            menuItem.setMnemonic(KeyEvent.VK_N);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(
                    KeyEvent.VK_N, ActionEvent.ALT_MASK));
            menuItem.setActionCommand("new");
            menuItem.addActionListener(this);
            menu.add(menuItem);
            //Set up the second menu item.
            menuItem = new JMenuItem("Quit");
            menuItem.setMnemonic(KeyEvent.VK_Q);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(
                    KeyEvent.VK_Q, ActionEvent.ALT_MASK));
            menuItem.setActionCommand("quit");
            menuItem.addActionListener(this);
            menu.add(menuItem);
            return menuBar;
        //React to menu selections.
        public void actionPerformed(ActionEvent e) {
            if ("new".equals(e.getActionCommand())) { //new
                createFrame();
            } else { //quit
                quit();
        //Create a new internal frame.
        protected void createFrame() {
            MyInternalFrame frame = new MyInternalFrame();
            MyComponentListener listener = new MyComponentListener();
            frame.addComponentListener(listener);
            frame.setVisible(true); //necessary as of 1.3
            desktop.add(frame);
            try {
                frame.setSelected(true);
            } catch (java.beans.PropertyVetoException e) {}
        //Quit the application.
        protected void quit() {
            System.exit(0);
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            InternalFrameDemo frame = new InternalFrameDemo();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Display the window.
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    private class MyComponentListener implements ComponentListener {
              * Invoked when the component's size changes.
             public void componentResized(ComponentEvent e) {
                  System.out.println("comp resized");
              * Invoked when the component's position changes.
             public void componentMoved(ComponentEvent e) {
                  System.out.println("comp moved");
              * Invoked when the component has been made visible.
             public void componentShown(ComponentEvent e) {
                  System.out.println("comp shown");
              * Invoked when the component has been made invisible.
             public void componentHidden(ComponentEvent e) {
                  System.out.println("comp hidden");
         } // listener class
    /* Used by InternalFrameDemo.java. */
    private class MyInternalFrame extends JInternalFrame {
         int openFrameCount = 0;
         final int xOffset = 30, yOffset = 30;
        public MyInternalFrame() {
            super("Document #",
                  true, //resizable
                  true, //closable
                  true, //maximizable
                  true);//iconifiable
            //...Create the GUI and put it in the window...
            //...Then set the window size or call pack...
            setSize(300,300);
            //Set the window's location.
            setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
    }Regards,
    Alan Mehio
    London, UK

  • JCmboBox setSelectedIndex help needed !!!!!!!!!!!!

    hi,
    I hope it's a trivial question but I am not able to solve it so need your help plz. I have a demo program if you run it you will see what I mean. Actually I am adding items to my JComboBox dynamically. My problem is that if I add the items with the same name and then explicitly set them selected my first item with same name is always highlighted and selected even though I say to select the last item which I add. But when I pull down the comboBox my first item with the same name is selected and highlighted not the last one. Please run the program and see. How can I solve this problem help needed.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ComboBoxDemo extends JPanel {
    JButton picture;
    public ComboBoxDemo() {
    String[] petStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig" };
    // Create the combo box, select the pig
    final JComboBox petList = new JComboBox(petStrings);
    picture = new JButton("ADD");
    picture.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    petList.addItem("TEST ");
                   int nodeTotal =     petList.getItemCount();
                   petList.setSelectedIndex(nodeTotal-1);
    setLayout(new BorderLayout());
    add(petList, BorderLayout.NORTH);
    add(picture, BorderLayout.SOUTH);
    setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
    public static void main(String s[]) {
    JFrame frame = new JFrame("ComboBoxDemo");
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {System.exit(0);}
    frame.setContentPane(new ComboBoxDemo());
    frame.pack();
    frame.setVisible(true);
    I want to select the last item I add even if there exists an item with same name.
    Any help is greatly appreciated.
    Thanks.

    never mind I got the answer.
    Tnaks

  • Troubleshoting help needed:  My iMac keeps crashing and restarting with a report detail: "spinlock application timed out"  What can I do to fix this?timed out"

    Troubleshooting help needed:  My iMac keeps crashing and restarting with a notice: "Spinlock application timed out"  What can I do?

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the page that opens.
    Select the most recent panic log under System Diagnostic Reports. Post the contents — the text, please, not a screenshot. In the interest of privacy, I suggest you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header and body of the report, if it’s present (it may not be.) Please don't post shutdownStall, spin, or hang reports.

  • Help needed for writing query

    help needed for writing query
    i have the following tables(with data) as mentioned below
    FK*-foregin key (SUBJECTS)
    FK**-foregin key (COMBINATION)
    1)SUBJECTS(table name)     
    SUB_ID(NUMBER) SUB_CODE(VARCHAR2) SUB_NAME (VARCHAR2)
    2           02           Computer Science
    3           03           Physics
    4           04           Chemistry
    5           05           Mathematics
    7           07           Commerce
    8           08           Computer Applications
    9           09           Biology
    2)COMBINATION
    COMB_ID(NUMBER) COMB_NAME(VARCHAR2) SUB_ID1(NUMBER(FK*)) SUB_ID2(NUMBER(FK*)) SUB_ID3(NUMBER(FK*)) SUBJ_ID4(NUMBER(FK*))
    383           S1      9           4           2           3
    384           S2      4           2           5           3
    ---------I actually designed the ABOVE table also like this
    3) a)COMBINATION
    COMB_ID(NUMBER) COMB_NAME(VARCHAR2)
    383           S1
    384           S2
    b)COMBINATION_DET
    COMBDET_ID(NUMBER) COMB_ID(FK**) SUB_ID(FK*)
    1               383          9
    2               383          4
    3               383          2
    4               383          3
    5               384          4
    6               384          2          
    7               384          5
    8               384          3
    Business rule: a combination consists of a maximum of 4 subjects (must contain)
    and the user is less relevant to a COMB_NAME(name of combinations) but user need
    the subjects contained in combinations
    i need the following output
    COMB_ID COMB_NAME SUBJECT1 SUBJECT2      SUBJECT3      SUBJECT4
    383     S1     Biology Chemistry      Computer Science Physics
    384     S2     Chemistry Computer Science Mathematics Physics
    or even this is enough(what i actually needed)
    COMB_ID     subjects
    383           Biology,Chemistry,Computer Science,Physics
    384           Chemistry,Computer Science,Mathematics,Physics
    you can use any of the COMBINATION table(either (2) or (3))
    and i want to know
    1)which design is good in this case
    (i think SUB_ID1,SUB_ID2,SUB_ID3,SUB_ID4 is not a
    good method to link with same table but if 4 subjects only(and must) comes
    detail table is not neccessary )
    now i am achieving the result by program-coding in C# after getting the rows from oracle
    i am using oracle 9i (also ODP.NET)
    i want to know how can i get the result in the stored procedure itsef.
    2)how it could be designed in any other way.
    any help/suggestion is welcome
    thanks for your time --Pradeesh

    Well I forgot the table-alias, here now with:
    SELECT C.COMB_ID
    , C.COMB_NAME
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID1) AS SUBJECT_NAME1
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID2) AS SUBJECT_NAME2
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID3) AS SUBJECT_NAME3
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID4) AS SUBJECT_NAME4
    FROM COMBINATION C;
    As you need exactly 4 subjects, the columns-solution is just fine I would say.

  • Help needed I have a canon 40D. I am thinking of buying a canon 6D.But not sure that my len

    Hi all help needed I have a canon 40D. I am thinking of buying a canon 6D.
    But not sure that my lenses will work.
    I have a 170mm/ 500mm APO Sigma.
    A 10/20 ex  Sigma   HSM  IF.
    And a 180 APO Sigma Macro or do I have to scrap them and buy others.
    ALL Help will be greatly received. Yours  BRODIE

    In short, I love it. I was going to buy the 5DMark III. After playing with it for a while at my local Fry's store where they put 5DMII, 5DMIII and 6D next to each other, using the same 24-105L lens, I decided to get the 6D and pocket the different for lens later.
    I'm upgrading from the 30D. So I think you'll love it. It's a great camera. I have used 5DMII extensively before (borrowing from a close friend).
    Funny thing is at first I don't really care about the GPS and Wifi much. I thought they're just marketing-gimmick. But once you have it, it is actually really fun and helpful. For example, I can place the 6D on a long "monopod", then use the app on the phone to control the camera to get some unique perspective on some scenes. It's fun and great. GPS is also nice for travel guy like me.
    Weekend Travelers Blog | Eastern Sierra Fall Color Guide

  • Help needed! Raid degraded again!

    Hi!
    Help needed! I hava made bootable RAID with two S-ATAII 250Gb HDD and its not working! Every now and then at bootup I get a message RAID -> DEGRADED... Must be seventh time! Rebuild takes its own time!
    What am I doing wrong!
    T: Ekku
    K8N Neo4 Ultra
    AMD 64 4200+
    2 Gb RAM
    2 x 250 Gb HDD (Maxtor)
    nVidia RAID (in mb)
    P.S. I wery SORRY with my poor language!

    I'm going to blame the nVRAID because I've seen issues with it in the past. If your motherboard has another non-nVidia RAID solution, use that instead. Using the nVidia SATA ports as BASE or JBOD is fine and dandy but RAIDing always had issues. It's not even a driver issue I think it's just instability. Latest drivers and even boxed drivers never helped. Granted, some will report success with their rig. But on a professional level I've seen nForce issues on different motherboards and different hard drives that had RAID disaster stories.
    Good luck and if you don't have another RAID solution, my suggestion would be to buy a dedicated RAID controller card.
    LPB

Maybe you are looking for

  • Question re synching with Ipad under different ICloud account

    My question concerns how I sync my ICloud with an Ipad under my wife's email. I have an iCloud account on my MacBookPro, my iphone and my ipad.  They work fine. I also want to send my calendar and other info shared on my 3 devices to my wife's ipad.

  • FREIGHT DISCOUNT QUERY

    Dear All, I am having Query regarding Freight: Vendor is sending material (A) on which VAT is applicable Let us say he sends Qty 1000 @ 10 So BAsic Price is 10000 Vat @ 4% 400 1) So Price inclusive VAT is 10400 Rs The Freight is Applicable on the MAt

  • Retriving a a deleted abap program

    A Custom ABAP program was accidentally deleted a few weeks ago and the transport made it to production and all systems.  Are there any options to get a copy of the program back from somewhere? anywhere? Message was edited by: Scott Hoelscher

  • MATERIAL MASTER DATA ARCHIVING

    Dear Experts, I have archive material master data from the data base. As a prerequisite for material master data archive, Purchase orders for the materials are archived already. Invoices documents are archived already Material documents are archived

  • All the free space on my hard drive has vanished!

    My hard drive space has disappeared. About two months ago I freed up about 30 gigs and havent really downloaded anything since then. I checked last week and I had about 1 gig left. This was bad and I didnt know the cause of it. I deleted some things