Help with JcomboBoxes

Hi,
Im having trouble with a combobox
I have created a bean class for an ftp site, that contains;
- ftp site name
- address
- username
- password
I then create an array of these sites and add them to the jComboBox.
I only want to display the ftp site name in the box, however, when i select a certain site, i then want to pass the rest of the info. (ie. address, username, and password) to a connect method i have in another class.
I'm quite sure this is a reasonably simply task but i just cant get my head around it.
can anybody please help me?
Much Thanks!

Check out this posting for a solution:
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=613731

Similar Messages

  • Web Guy Using Swing - Need Help With jComboBox

    I'm new to doing desktop Java development (come from a web application background) and am trying to accomplish migrating some of a web application's functionality to a desktop app for distribution. I'm already a bit stuck when it comes to using the jComboBox. What is intuitive to me in the web world would be to have one combo box/select box that after making a selection, it returns it's value so I could use that to run another query that would populate the next drop down menu. Populating the display of the combo box isn't the problem, that seems easy enough, but what I so far can't find is how I can attach a value to the combo box; that is for instance, having the drop down show a list of country names, and needing to have that list of country names correspond to a country code. For the web, you'd just have the option value tied to the code and the contents of the option be the name.
    Is this do-able? Am I completely thinking about this in the wrong way when working in desktop GUI things? I am using NetBeans 6.0 for my GUI layout and such, don't know if that helps or hurts matters. Also currently using Java 1.5.
    Any information or points in the right direction are greatly appreciated.
    Cheers.

    If I understand you correctly, you need to have a class that holds country name and country code, with a toString override method that returns just the country name (this is what the combobox shows). You then put an array of these objects in your jcombobox, obtain the selected object, get it's country code, and you're off and running.
    Edited by: Encephalopathic on Mar 31, 2008 3:26 PM

  • Help with JComboBox-JTable

    Hi there!
    I'll try to explain my problem the best I can, I hope you can understand me so you may get to help me, I'd really appreciate it. I'm trying to make a JTable to render a cell as a JComboBox, that's ok and it's working fine. The problem comes when I try to change the combo value. The itemStateChanged method is supposed to get some values from a database, if the first is bigger than the second it shows an alert, else it makes an update to the database. Now, the problem is that, if the combobox default value is blank (""), it works fine, but if it's filled with something as a name ("anything") it automatically shows the alert, even if I'm not changing the combo value. The second problem is that it shows the alert twice, I'll try to explain with code:
    class Cambia_Cita extends javax.swing.AbstractCellEditor implements javax.swing.table.TableCellEditor ,java.awt.event.ItemListener{
        protected EventListenerList listenerList = new EventListenerList();
        protected ChangeEvent changeEvent = new ChangeEvent(this);   
        protected javax.swing.JComboBox combo = new javax.swing.JComboBox();
        int i;
        String valor = "";
        int j;
        javax.swing.JTable tabla = new javax.swing.JTable();
        public Cambia_Cita() {
            super();
            combo.addItemListener(this);
            Base base = new Base();
            Statement sta = base.conectar();
            try {
                ResultSet rs = sta.executeQuery("SELECT DISTINCT Nombre_Completo FROM Pacientes WHERE Alta = 'n'");
                combo.addItem("");
                while(rs.next())
                    combo.addItem(rs.getString("Nombre_Completo"));
            }catch(SQLException e) {
                System.out.println (e.getMessage());
            } finally {
                base.cerrar(sta);
            combo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent event) {
                    System.out.println("algo");
                    tabla.setValueAt(valor,i,j);
        public Object getCellEditorValue() {
            return(combo.getSelectedItem());
        public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, Object value, boolean isSelected, int row, int column) {
            i = row;
            j = column;
            tabla = table;
            valor = value.toString();
            combo.setSelectedItem(tabla.getValueAt(i,j));
            System.out.println (i + "," + j);
            java.awt.Component c = table.getDefaultRenderer(String.class).getTableCellRendererComponent(table, value, isSelected, false, row, column);
            if (c != null) {
                combo.setBackground(c.getBackground());
            return combo;
        public void itemStateChanged(java.awt.event.ItemEvent e) {
            Base base = new Base();
            Statement sta = base.conectar();
            try {
                String asist;
                if (tabla.getValueAt(i,3).equals(new Boolean(true))) {
                    asist = "s";
                } else {
                    asist = "n";
                ResultSet rs = sta.executeQuery("SELECT COUNT(ID_Cita) FROM Cita JOIN Pacientes ON Cita.RFC_Paciente " +
                        "= Pacientes.RFC_Paciente WHERE Nombre_Completo = '" + combo.getSelectedItem() + "'");
                rs.next();
                int result = rs.getInt("COUNT(ID_Cita)");
                rs = sta.executeQuery("SELECT Consultas FROM Ciclo JOIN Pacientes ON Ciclo.RFC_Paciente = Pacientes." +
                        "RFC_Paciente WHERE Nombre_Completo = '"+ combo.getSelectedItem() +"' AND Ciclo.Numero_Ciclo = " +
                        "Pacientes.Ciclo");
                rs.next();
                int maximo = rs.getInt("Consultas");
                /* if maximo is bigger than result plus 1, then it shows the alert, but it is shown even if I don't change the combo value!!!, this part only works if the default value of the combo is blank */
                if (maximo >= result +1 ) {
                    sta.executeUpdate("UPDATE Cita,Pacientes SET Cita.RFC_Paciente = Pacientes.RFC_Paciente WHERE " +
                            "Nombre_Completo = '" + combo.getSelectedItem() + "' AND ID_Cita = " + tabla.getValueAt(i,0));
                }else
                    javax.swing.JOptionPane.showMessageDialog(null,"No se puede agregar otra cita...");
            }catch (ArrayIndexOutOfBoundsException ex) {
                System.out.println (ex.getMessage());
            } catch (SQLException ex) {
                System.out.println (ex.getMessage());
            } finally {
                base.cerrar(sta);
    }So, I'd like to know why the alert appears twice when it works and why it appears even if the combo value ain't changed. I really hope anyone can help me. Thank you!

    if the first is bigger than the second it shows an alertIf you want to know when data is changed in the table then you use a TableModelListener, not an ItemListener. Here is a simple example:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=566133
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

  • Help with JComboBox and Model creation

    hi,
    I'm trying to figure out the best way to set up the data behind the JComboBox and copy part of that data to be shown by the JComboBox. Here is what I would like it to do.
    My data:
    itemID, dbaseID, name
    1, 2, test1
    2, 2, test2
    3, 2, test3
    The JCombo will only display the name in this case "test1", "test2", or "test3". However when the user selects the name, I want to easily retrieve the hidden itemID or dbaseID. I've got the combobox working with just the "test1" but it doesn't tell me which dbase it is from. I have to search all of them and worry about identical names.
    What is the best way to set this up? I was thinking about an multiDimensional model but not sure how that would look. It is just not clicking how set up the data and then add parts of to the combo box.
    Any guidance or examples would be appreciated.

    From what I can tell both getSelectedItem() and getSelectedValue() return the string value of the GUI component. Read the API, that is not what they return. They return the "selected" Object.
    The renderer, by default, displays the toString() value of the Object.
    I'm casting the string into Item No you aren't, because that is not possible.
    My understanding was casting was just converting one thing to another.Casting does not "convert" anything. Time to get out your Java textbook and read up on casting.
    However this looks like it is actually grabbing the memory point to an item.Exactly. The getSelected... methods simply return a reference to the Object that was selected. Thats all any get... method does.

  • Help with JComboBox

    From the code below it looks like the only last competitor number entered get displayed in the JComboBox five times but if five of them is entered they all have to be different.
    public Integer[] listCompNumbers()
      // This should return an array of Integers that are the competitor numbers
      // of all the competitors in your competition.
      // it is called once to create the drop down list to select whom to enter result for
        Integer nums[] =  new Integer[5];
        // replace next line with code that gets the competitor numbers
        nums[0] = new Integer(gui.getAddCompetitorNumber());
        nums[1] = new Integer(gui.getAddCompetitorNumber());
        nums[2] = new Integer(gui.getAddCompetitorNumber());
        nums[3] = new Integer(gui.getAddCompetitorNumber());
        nums[4] = new Integer(gui.getAddCompetitorNumber());
        return nums;
      }

    What does the method gui.getAddCompetitorNumber() do?

  • Get help with JComboBox, itemStateChange

    hi, i get quite complex a problem.
    i have a list containing 2 types of list. one list is the car model and the other is the car type.
    so in one combo box, there will be a list of car model. when one car is selected in this, the other combo box will automatically update all the available car type (e.g. car model is BMW and car type is 318).
    i dont know how to keep the second combo box updated immediately after item of the first combo box changes state.
    some one help me pls

    hi,
    thanks for replying but my problem seems too hard for me.
    i just got another problem.
    i still have the file with a number of JFrames inside and the first, or considered to be the "main" JFrame. Now, when i click a button, a second JFrame after that will pop up but I dont know how to setVisible(false) for the main window using Netbeans. could you please help me do that?
    thanks alot

  • Help with GUI project.

    I need help with JcomboBox when I select the Exit in the File box it will open
    //inner class
    class exitListener implements ActionListener {
    I have the part of the parts of statement but I don't know how to assign the Keystoke. here is that part of the code
    filemenu.setMnemonic(KeyEvent.VK_X);Here is my code...
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class MyFrame extends JFrame {
         String[] file = { "New", "Open", "Exit" };//items for file
        String[] edit = { "Cut", "Copy", "Paste" };//items for edit
        JComboBox filemenu = new JComboBox();
        JComboBox editmenu = new JComboBox();
         public MyFrame(String title) {
              super(title);
              this.setSize(250, 250); //sets the size for the frame
              this.setLocation(200, 200);//location where frame is at
              this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              // setup contents
              makeComponents();
              initComponents();
              buildGUI();
              // display
              this.setVisible(true);
         private void makeComponents() {
              JPanel pane = new JPanel();
    //          file menu section
              filemenu = new JComboBox();
            JLabel fileLabel = new JLabel();
            pane.add(fileLabel);
            for (int i = 0; i < file.length; i++)
                 filemenu.addItem(file);
    pane.add(filemenu);
    add(pane);
    setVisible(true);
    //edit menu section
    editmenu = new JComboBox();
    JLabel editLabel = new JLabel();
    pane.add(editLabel);
    for (int i = 0; i < edit.length; i++)
         editmenu.addItem(edit[i]);
    pane.add(editmenu);
    add(pane);
    setVisible(true);
         private void initComponents() {
              filemenu.addActionListener(new exitListener());
         //inner class
    class exitListener implements ActionListener {
    public void actionPerformed(ActionEvent arg0) {
    int x = JOptionPane.showOptionDialog(MyFrame.this, "Exit Program?",
    "Exit Request", JOptionPane.YES_NO_OPTION,
    JOptionPane.QUESTION_MESSAGE, null, null,
    JOptionPane.NO_OPTION);
    if (x == JOptionPane.YES_OPTION) {
    MyFrame.this.dispose();
         private void buildGUI() {
              Container cont = this.getContentPane();// set gui components into the frame
              this.setLayout(new FlowLayout(FlowLayout.LEFT));// Comp are added to the frame
              cont.add(filemenu);
              cont.add(editmenu);
         // / inner classes
    public class ButtonFrame {
         public static void main(String[] args) {
              MyFrame f1 = new MyFrame("This is my Project for GUI");
    Thanks
    SandyR.

    One way is to
    1) pass a reference of the Window object to the USDListener class, and set a local Window variable say call it window, to this reference.
    2) Give the Window class a public method that returns a String and allows you to get the text from USDField. Same to allow you to set text on the euroField.
    3) Give the Listener class a Converter object.

  • Need help with JTextArea and Scrolling

    import java.awt.*;
    import java.awt.event.*;
    import java.text.DecimalFormat;
    import javax.swing.*;
    public class MORT_RETRY extends JFrame implements ActionListener
    private JPanel keypad;
    private JPanel buttons;
    private JTextField lcdLoanAmt;
    private JTextField lcdInterestRate;
    private JTextField lcdTerm;
    private JTextField lcdMonthlyPmt;
    private JTextArea displayArea;
    private JButton CalculateBtn;
    private JButton ClrBtn;
    private JButton CloseBtn;
    private JButton Amortize;
    private JScrollPane scroll;
    private DecimalFormat calcPattern = new DecimalFormat("$###,###.00");
    private String[] rateTerm = {"", "7years @ 5.35%", "15years @ 5.5%", "30years @ 5.75%"};
    private JComboBox rateTermList;
    double interest[] = {5.35, 5.5, 5.75};
    int term[] = {7, 15, 30};
    double balance, interestAmt, monthlyInterest, monthlyPayment, monPmtInt, monPmtPrin;
    int termInMonths, month, termLoop, monthLoop;
    public MORT_RETRY()
    Container pane = getContentPane();
    lcdLoanAmt = new JTextField();
    lcdMonthlyPmt = new JTextField();
    displayArea = new JTextArea();//DEFINE COMBOBOX AND SCROLL
    rateTermList = new JComboBox(rateTerm);
    scroll = new JScrollPane(displayArea);
    scroll.setSize(600,170);
    scroll.setLocation(150,270);//DEFINE BUTTONS
    CalculateBtn = new JButton("Calculate");
    ClrBtn = new JButton("Clear Fields");
    CloseBtn = new JButton("Close");
    Amortize = new JButton("Amortize");//DEFINE PANEL(S)
    keypad = new JPanel();
    buttons = new JPanel();//DEFINE KEYPAD PANEL LAYOUT
    keypad.setLayout(new GridLayout( 4, 2, 5, 5));//SET CONTROLS ON KEYPAD PANEL
    keypad.add(new JLabel("Loan Amount$ : "));
    keypad.add(lcdLoanAmt);
    keypad.add(new JLabel("Term of loan and Interest Rate: "));
    keypad.add(rateTermList);
    keypad.add(new JLabel("Monthly Payment : "));
    keypad.add(lcdMonthlyPmt);
    lcdMonthlyPmt.setEditable(false);
    keypad.add(new JLabel("Amortize Table:"));
    keypad.add(displayArea);
    displayArea.setEditable(false);//DEFINE BUTTONS PANEL LAYOUT
    buttons.setLayout(new GridLayout( 1, 3, 5, 5));//SET CONTROLS ON BUTTONS PANEL
    buttons.add(CalculateBtn);
    buttons.add(Amortize);
    buttons.add(ClrBtn);
    buttons.add(CloseBtn);//ADD ACTION LISTENER
    CalculateBtn.addActionListener(this);
    ClrBtn.addActionListener(this);
    CloseBtn.addActionListener(this);
    Amortize.addActionListener(this);
    rateTermList.addActionListener(this);//ADD PANELS
    pane.add(keypad, BorderLayout.NORTH);
    pane.add(buttons, BorderLayout.SOUTH);
    pane.add(scroll, BorderLayout.CENTER);
    addWindowListener( new WindowAdapter()
    public void windowClosing(WindowEvent e)
    System.exit(0);
    public void actionPerformed(ActionEvent e)
    String arg = lcdLoanAmt.getText();
    int combined = Integer.parseInt(arg);
    if (e.getSource() == CalculateBtn)
    try
    JOptionPane.showMessageDialog(null, "Got try here", "Error", JOptionPane.ERROR_MESSAGE);
    catch(NumberFormatException ev)
    JOptionPane.showMessageDialog(null, "Got here", "Error", JOptionPane.ERROR_MESSAGE);
    if ((e.getSource() == CalculateBtn) && (arg != null))
    try{
    if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 1))
    monthlyInterest = interest[0] / (12 * 100);
    termInMonths = term[0] * 12;
    monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest,  -termInMonths))));
    lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
    if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 2))
    monthlyInterest = interest[1] / (12 * 100);
    termInMonths = term[1] * 12;
    monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest,  -termInMonths))));
    lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
    if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 3))
    monthlyInterest = interest[2] / (12 * 100);
    termInMonths = term[2] * 12;
    monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest,  -termInMonths))));
    lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
    catch(NumberFormatException ev)
    JOptionPane.showMessageDialog(null, "Invalid Entry!\nPlease Try Again", "Error", JOptionPane.ERROR_MESSAGE);
    }                    //IF STATEMENTS FOR AMORTIZATION
    if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 1))
    loopy(7, 5.35);
    if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 2))
    loopy(15, 5.5);
    if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 3))
    loopy(30, 5.75);
    if (e.getSource() == ClrBtn)
    rateTermList.setSelectedIndex(0);
    lcdLoanAmt.setText(null);
    lcdMonthlyPmt.setText(null);
    displayArea.setText(null);
    if (e.getSource() == CloseBtn)
    System.exit(0);
    private void loopy(int lTerm,double lInterest)
    double total, monthly, monthlyrate, monthint, monthprin, balance, lastint, paid;
    int amount, months, termloop, monthloop;
    String lcd2 = lcdLoanAmt.getText();
    amount = Integer.parseInt(lcd2);
    termloop = 1;
    paid = 0.00;
    monthlyrate = lInterest / (12 * 100);
    months = lTerm * 12;
    monthly = amount *(monthlyrate/(1-Math.pow(1+monthlyrate,-months)));
    total = months * monthly;
    balance = amount;
    while (termloop <= lTerm)
    displayArea.setCaretPosition(0);
    displayArea.append("\n");
    displayArea.append("Year " + termloop + " of " + lTerm + ": payments\n");
    displayArea.append("\n");
    displayArea.append("Month\tMonthly\tPrinciple\tInterest\tBalance\n");
    monthloop = 1;
    while (monthloop <= 12)
    monthint = balance * monthlyrate;
    monthprin = monthly - monthint;
    balance -= monthprin;
    paid += monthly;
    displayArea.setCaretPosition(0);
    displayArea.append(monthloop + "\t" + calcPattern.format(monthly) + "\t" + calcPattern.format(monthprin) + "\t");
    displayArea.append(calcPattern.format(monthint) + "\t" + calcPattern.format(balance) + "\n");
    monthloop ++;
    termloop ++;
    public static void main(String args[])
    MORT_RETRY f = new MORT_RETRY();
    f.setTitle("MORTGAGE PAYMENT CALCULATOR");
    f.setBounds(600, 600, 500, 500);
    f.setLocationRelativeTo(null);
    f.setVisible(true);
    }need help with displaying the textarea correctly and the scroll bar please.
    Message was edited by:
    new2this2020

    What's the problem you're having ???
    PS.

  • Help with dropdown menu in JCombo box,Pleaseeeeeee

    Hi,
    I posted earlier but I`II try again. Someone must know how to do this. I have a JComboBox and I want the drop down menu to be a bit wider then the comboBox.
    I tried using this method
    public void setPreferredSize()
              Dimension d = jcbo.getPreferredSize(d);
              jcbo.setPreferredSize(new Dimension(20, d.height));
              jcbo.setPopupWidth(d.width);
    but I recieved a couldn`t resolve symbol error for the last line.
    I imported these into the program]
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    Is there something else I should of imported as well to make this work, or is it another problem all together.Any help would be greatly appreciated.

    Hi , What I want to do is have the dropmenu a bit wider then the comboBox. Here is my code.Please excuse any odd ball mistakes, At this point I have been trying anything.This is an exercise that I have to do fo a java assignment, Hence the weird GUI. In the example pic they gave me.It shows the dropmenu a bit wider than the comboBox, I am sure they through this in to screw with my brain, I have put comment tags Around the stuff I tried to use. Any help with this would be greatly appreciated.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    //import javax.swing.plaf.basic.*;
    public class Exercise9_3 extends JFrame implements ActionListener
         private JTextField nameField;
         private JTextArea nameArea;
         private JButton storeButton;
         private JComboBox jcbo;
         private JPopupMenu popup;
         protected int popupWidth;
         String newline = "\n";
         public Exercise9_3()
              createComponets();
              addComponets();
              setTitle("Exercise9_3");
         private void createComponets ()
              nameField = new JTextField(19);
              nameArea = new JTextArea(10, 15);
              storeButton = new JButton("Store");
              storeButton.addActionListener(this);
              jcbo = new JComboBox();
              jcbo.addActionListener(this);
         /*8public void setPreferredSize()
              Dimension d = jcbo.getPreferredSize(d);
              //jcbo.setPreferredSize(new Dimension(20, d.height));
              //jcbo.setPopupWidth(d.width);
         private void addComponets()
              JPanel p1 = new JPanel();
              p1.setLayout (new FlowLayout());
              p1.add(nameField);
              p1.add(nameArea);
              p1.add(jcbo);
              JPanel p2 = new JPanel();
              p2.setLayout (new FlowLayout());
              p2.add (storeButton);
              getContentPane().setLayout(new BorderLayout());
              getContentPane().add(p1, BorderLayout.CENTER);
              getContentPane().add(p2, BorderLayout.SOUTH);
         public void actionPerformed(ActionEvent e)
              if(e.getSource() == storeButton)
                   String s = nameField.getText();
                   jcbo.addItem(s);
                   jcbo.setSelectedItem(s);
                   String textArea = s ;
                   String text = nameField.getText();
                   nameArea.append(text + newline);
         nameField.selectAll();
         nameField.setText("");
         nameField.requestFocus();
              if (e.getSource() == jcbo)
    /**retrieve the input as a string*/
    String selectedName = (String)jcbo.getSelectedItem();
    /**set the name that was selected from the ComboBox and add it to textfield*/
    nameField.setText(selectedName);
         public static void main(String [] args)
              Exercise9_3 frame = new Exercise9_3();
              frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
              frame.pack();
              frame.setVisible(true);
              Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
              int screenWidth = screenSize.width;
              int screenHeight = screenSize.height;
              // Get dimension of the frame
              Dimension frameSize = frame.getSize();
              int x = (screenWidth - frameSize.width)/2;
              int y = (screenHeight- frameSize.height)/2;
         frame.setLocation(x,y);

  • Need a little help with some errors.

    Receiving some errors..
    btn2.addActionListener(new ActionListener() {
    and also
    frame.setLocation(400,400);
    frame.setVisible(true);
    }<<~~has 2 errors here...
    Both above have class or interface expected errors..clueless on what i'm missing at the moment.
    Anyone mind pointing out what {'s and }'s i'm missing?
         btn1.addActionListener(new ActionListener() {
                             public void actionPerformed(ActionEvent evt) {
                                  btn1actions();
              private void btn1actions() {
                   if (radio1.isSelected()) System.out.println("Radio Button 1 is selected.");
                   if (radio2.isSelected()) System.out.println("Radio Button 2 is selected.");
         btn2.addActionListener(new ActionListener() {
                                       public void actionPerformed(ActionEvent evt) {
                                            btn2actions();
                        private void btn2actions() {
                             if (radio1.isSelected()) System.out.println("Radio Button 1 is selected.");
                             if (radio2.isSelected()) System.out.println("Radio Button 2 is selected.");
                   btn3.addActionListener(new ActionListener() {
                                       public void actionPerformed(ActionEvent evt) {
                                            btn1actions();
                        private void btn3actions() {
                             txt1.setText("");
                             txt1.requestFocus();
    public static void main(String[] args) {
        Test2 frame = new Test2();
        frame.setTitle("Test Frame");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 300);
        frame.setLocation(400,400);
        frame.setVisible(true);
    }

    All my code..finally posted...just need help with more errors.
    F:\DocumentsTest2.java:169: ';' expected
              btn1.addActionListener(new ActionListener()) {
    ^
    F:\Documents\Test2.java:176: illegal start of expression
              private void btn1actions() {
    ^
    F:\Documents\Test2.java:191: illegal start of expression
              private void btn2actions() {
    ^
    F:\Documents\.java:202: illegal start of expression
              private void btn3actions() {
    ^
    4 errors
    Tool completed with exit code 1
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test2 extends JFrame{
         static JButton btn1,btn2,btn3;
         static JTextField txt1;
         static JRadioButton radio1,radio2;
           public Test2() {
             Container container = getContentPane();
             container.setLayout(new BorderLayout());
              //Create Panels
                JPanel Panel1 = new JPanel();
                JPanel Panel2 = new JPanel();
                JPanel Panel3 = new JPanel();
                JPanel Panel4 = new JPanel();
                JPanel Panel5 = new JPanel();
                JPanel Panel6 = new JPanel();
                JPanel Panel7 = new JPanel();
                JPanel Panel8 = new JPanel();
                JPanel Panel9 = new JPanel();
                JPanel Panel10 = new JPanel();
              //Set Layout for Panels
              Panel3.setLayout(new BorderLayout());
              Panel4.setLayout(new BorderLayout());
              Panel5.setLayout(new BorderLayout());
              Panel6.setLayout(new BorderLayout());
              Panel10.setLayout(new BorderLayout());
              //Create the Various Fonts and Colors for this GUI
              Font font1 = new Font("SansSerif", Font.BOLD, 20);
              Font font2 = new Font("Serif", Font.PLAIN, 15);
              Color color1 = new Color(3,15,125);//A Dark Blue Color
              Color color2 = new Color(201,29,10);//A Red Color
              Color color3 = new Color(127,127,127);//A Grey Color
              //Create Buttons and Labels
             btn1 = new JButton("Submit");
             btn2 = new JButton("Display Schedule");
             btn3 = new JButton("Enter New Name");
             JLabel label1 = new JLabel("Student Name");
             JLabel label2 = new JLabel("Course Number");
              JLabel label3 = new JLabel("Welcome to the Java Community College");
              JLabel label4 = new JLabel("Registration System!");
              //Declare Text Field For Entering Student Names
              txt1 = new JTextField(15);
              //"Put Course Number from another Method Here"
              String[] courseStrings = { "CISM2230 A", "CISM2230 B", "CISM1110 A", "CISM1110 B", "CISM1120 A", "CISM1120 B" };
              JComboBox Combo1 = new JComboBox(courseStrings);
              //Declare Radio Buttons for Add and Drop Course
              radio1 = new JRadioButton("Add a Course", false);
              radio2 = new JRadioButton("Drop a Course", false);
              ButtonGroup radioButtons = new ButtonGroup();
              radioButtons.add(radio1);
              radioButtons.add(radio2);
              //Panel 10 is the Main Displaying Panel
              Panel10.add(Panel3, BorderLayout.NORTH);
              Panel10.add(Panel4, BorderLayout.CENTER);
              Panel10.add(Panel8, BorderLayout.SOUTH);
              //Panel 3 Used to Display Label 3 and 4 using Panels 1 and 2
              Panel3.add(Panel1, BorderLayout.NORTH);
              Panel3.add(Panel2, BorderLayout.CENTER);
              Panel1.add(label3);
             Panel2.add(label4);
              //Panel 4 Used to Display Student Name, Txt1, Course Number, Combo Box and Radio Buttons
             Panel5.add(label1, BorderLayout.NORTH);
             Panel5.add(txt1, BorderLayout.CENTER);
             Panel6.add(label2, BorderLayout.NORTH);
              Panel6.add(Combo1, BorderLayout.CENTER);
              Panel7.add(radio1, BorderLayout.NORTH);
              Panel7.add(radio2, BorderLayout.CENTER);
              Panel4.add(Panel5, BorderLayout.NORTH);
              Panel4.add(Panel6, BorderLayout.CENTER);
              Panel4.add(Panel7, BorderLayout.SOUTH);
              //Panel 8 Used to Display the Buttons
              Panel9.add(btn1, BorderLayout.CENTER);
              Panel9.add(btn2, BorderLayout.CENTER);
              Panel9.add(btn3, BorderLayout.SOUTH);
              Panel8.add(Panel9, BorderLayout.CENTER);
              //Setting Background, ForeGround and Font of all Text.
             Panel1.setBackground(color3);
             Panel2.setBackground(color3);
             Panel3.setBackground(color3);
             Panel4.setBackground(color3);
             Panel5.setBackground(color3);
             Panel6.setBackground(color3);
             Panel7.setBackground(color3);
             Panel8.setBackground(color3);
             Panel9.setBackground(color3);
             Panel10.setBackground(color3);
             btn1.setBackground(color3);
             btn2.setBackground(color3);
             btn3.setBackground(color3);
             radio1.setBackground(color3);
             radio2.setBackground(color3);
             btn1.setFont(font2);
             btn2.setFont(font2);
             btn3.setFont(font2);
             Combo1.setFont(font2);
             Combo1.setBackground(color3);
             Combo1.setForeground(color1);
             label1.setFont(font2);
             label2.setFont(font2);
             label3.setFont(font1);
             label4.setFont(font1);
             label1.setForeground(color2);
             label2.setForeground(color2);
             label3.setForeground(color1);
             label4.setForeground(color1);
             container.add(Panel10);
              //Setting Keyboard Shortcuts to Radio Buttons and Regular Buttons
              btn1.setMnemonic('S');
              btn2.setMnemonic('D');
              btn3.setMnemonic('E');
              radio1.setMnemonic('A');
              radio2.setMnemonic('C');
              //ActionListener
              btn1.addActionListener(new ActionListener()) {
                   public void actionPerformed(ActionEvent evt) {
                        btn1actions();
              private void btn1actions() {
                   if (radio1.isSelected()){ System.out.println("Radio Button 1 is selected. Button 1")};
                   if (radio2.isSelected()){ System.out.println("Radio Button 2 is selected. Button 1")};
              btn2.addActionListener(new ActionListener()) {
                   public void actionPerformed(ActionEvent evt) {
                                            btn2actions();
              private void btn2actions() {
                   if (radio1.isSelected()) System.out.println("Radio Button 1 is selected(Button 2).");
                   if (radio2.isSelected()) System.out.println("Radio Button 2 is selected.Button 2");
              btn3.addActionListener(new ActionListener()) {
                   public void actionPerformed(ActionEvent evt) {
                        btn1actions();
              private void btn3actions() {
                   txt1.setText("");
                   txt1.requestFocus();
         public static void main(String[] args) {
             JavaCollegeTest2 frame = new JavaCollegeTest2();
             frame.setTitle("Project 4");
             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             frame.setSize(400, 300);
             frame.setLocation(400,400);
             frame.setVisible(true);
    }

  • Help with if statement in cursor and for loop to get output

    I have the following cursor and and want to use if else statement to get the output. The cursor is working fine. What i need help with is how to use and if else statement to only get the folderrsn that have not been updated in the last 30 days. If you look at the talbe below my select statement is showing folderrs 291631 was updated only 4 days ago and folderrsn 322160 was also updated 4 days ago.
    I do not want these two to appear in my result set. So i need to use if else so that my result only shows all folderrsn that havenot been updated in the last 30 days.
    Here is my cursor:
    /*Cursor for Email procedure. It is working Shows userid and the string
    You need to update these folders*/
    DECLARE
    a_user varchar2(200) := null;
    v_assigneduser varchar2(20);
    v_folderrsn varchar2(200);
    v_emailaddress varchar2(60);
    v_subject varchar2(200);
    Cursor c IS
    SELECT assigneduser, vu.emailaddress, f.folderrsn, trunc(f.indate) AS "IN DATE",
    MAX (trunc(fpa.attemptdate)) AS "LAST UPDATE",
    trunc(sysdate) - MAX (trunc(fpa.attemptdate)) AS "DAYS PAST"
    --MAX (TRUNC (fpa.attemptdate)) - TRUNC (f.indate) AS "NUMBER OF DAYS"
    FROM folder f, folderprocess fp, validuser vu, folderprocessattempt fpa
    WHERE f.foldertype = 'HJ'
    AND f.statuscode NOT IN (20, 40)
    AND f.folderrsn = fp.folderrsn
    AND fp.processrsn = fpa.processrsn
    AND vu.userid = fp.assigneduser
    AND vu.statuscode = 1
    GROUP BY assigneduser, vu.emailaddress, f.folderrsn, f.indate
    ORDER BY fp.assigneduser;
    BEGIN
    FOR c1 IN c LOOP
    IF (c1.assigneduser = v_assigneduser) THEN
    dbms_output.put_line(' ' || c1.folderrsn);
    else
    dbms_output.put(c1.assigneduser ||': ' || 'Overdue Folders:You need to update these folders: Folderrsn: '||c1.folderrsn);
    END IF;
    a_user := c1.assigneduser;
    v_assigneduser := c1.assigneduser;
    v_folderrsn := c1.folderrsn;
    v_emailaddress := c1.emailaddress;
    v_subject := 'Subject: Project for';
    END LOOP;
    END;
    The reason I have included the folowing table is that I want you to see the output from the select statement. that way you can help me do the if statement in the above cursor so that the result will look like this:
    emailaddress
    Subject: 'Project for ' || V_email || 'not updated in the last 30 days'
    v_folderrsn
    v_folderrsn
    etc
    [email protected]......
    Subject: 'Project for: ' Jim...'not updated in the last 30 days'
    284087
    292709
    [email protected].....
    Subject: 'Project for: ' Kim...'not updated in the last 30 days'
    185083
    190121
    190132
    190133
    190159
    190237
    284109
    286647
    294631
    322922
    [email protected]....
    Subject: 'Project for: Joe...'not updated in the last 30 days'
    183332
    183336
    [email protected]......
    Subject: 'Project for: Sam...'not updated in the last 30 days'
    183876
    183877
    183879
    183880
    183881
    183882
    183883
    183884
    183886
    183887
    183888
    This table is to shwo you the select statement output. I want to eliminnate the two days that that are less than 30 days since the last update in the last column.
    Assigneduser....Email.........Folderrsn...........indate.............maxattemptdate...days past since last update
    JIM.........      jim@ aol.com.... 284087.............     9/28/2006.......10/5/2006...........690
    JIM.........      jim@ aol.com.... 292709.............     3/20/2007.......3/28/2007............516
    KIM.........      kim@ aol.com.... 185083.............     8/31/2004.......2/9/2006.............     928
    KIM...........kim@ aol.com.... 190121.............     2/9/2006.........2/9/2006.............928
    KIM...........kim@ aol.com.... 190132.............     2/9/2006.........2/9/2006.............928
    KIM...........kim@ aol.com.... 190133.............     2/9/2006.........2/9/2006.............928
    KIM...........kim@ aol.com.... 190159.............     2/13/2006.......2/14/2006............923
    KIM...........kim@ aol.com.... 190237.............     2/23/2006.......2/23/2006............914
    KIM...........kim@ aol.com.... 284109.............     9/28/2006.......9/28/2006............697
    KIM...........kim@ aol.com.... 286647.............     11/7/2006.......12/5/2006............629
    KIM...........kim@ aol.com.... 294631.............     4/2/2007.........3/4/2008.............174
    KIM...........kim@ aol.com.... 322922.............     7/29/2008.......7/29/2008............27
    JOE...........joe@ aol.com.... 183332.............     1/28/2004.......4/23/2004............1585
    JOE...........joe@ aol.com.... 183336.............     1/28/2004.......3/9/2004.............1630
    SAM...........sam@ aol.com....183876.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183877.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183879.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183880.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183881.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183882.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183883.............3/5/2004.........3/8/2004.............1631
    SAM...........sam@ aol.com....183884.............3/5/2004.........3/8/2004............     1631
    SAM...........sam@ aol.com....183886.............3/5/2004.........3/8/2004............     1631
    SAM...........sam@ aol.com....183887.............3/5/2004.........3/8/2004............     1631
    SAM...........sam@ aol.com....183888.............3/5/2004.........3/8/2004............     1631
    PAT...........pat@ aol.com.....291630.............2/23/2007.......7/8/2008............     48
    PAT...........pat@ aol.com.....313990.............2/27/2008.......7/28/2008............28
    NED...........ned@ aol.com.....190681.............4/4/2006........8/10/2006............746
    NED...........ned@ aol.com......95467.............6/14/2006.......11/6/2006............658
    NED...........ned@ aol.com......286688.............11/8/2006.......10/3/2007............327
    NED...........ned@ aol.com.....291631.............2/23/2007.......8/21/2008............4
    NED...........ned@ aol.com.....292111.............3/7/2007.........2/26/2008............181
    NED...........ned@ aol.com.....292410.............3/15/2007.......7/22/2008............34
    NED...........ned@ aol.com.....299410.............6/27/2007.......2/27/2008............180
    NED...........ned@ aol.com.....303790.............9/19/2007.......9/19/2007............341
    NED...........ned@ aol.com.....304268.............9/24/2007.......3/3/2008............     175
    NED...........ned@ aol.com.....308228.............12/6/2007.......12/6/2007............263
    NED...........ned@ aol.com.....316689.............3/19/2008.......3/19/2008............159
    NED...........ned@ aol.com.....316789.............3/20/2008.......3/20/2008............158
    NED...........ned@ aol.com.....317528.............3/25/2008.......3/25/2008............153
    NED...........ned@ aol.com.....321476.............6/4/2008.........6/17/2008............69
    NED...........ned@ aol.com.....322160.............7/3/2008.........8/21/2008............4
    MOE...........moe@ aol.com.....184169.............4/5/2004.......12/5/2006............629
    [email protected]/27/2004.......3/8/2004............1631
    How do I incorporate a if else statement in the above cursor so the two days less than 30 days since last update are not returned. I do not want to send email if the project have been updated within the last 30 days.
    Edited by: user4653174 on Aug 25, 2008 2:40 PM

    analytical functions: http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/functions2a.htm#81409
    CASE
    http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/02_funds.htm#36899
    http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/04_struc.htm#5997
    Incorporating either of these into your query should assist you in returning the desired results.

  • I need help with Sunbird Calendar, how can I transfer it from one computer to the other and to my iphone?

    I installed Sunbird in one computer and my calendar has all my infos, events, and task that i would like to see on another computer that i just downloaded Sunbird into. Also, is it possible I can access Sunbird on my iphone?
    Thank you in advance,

    Try the forum here - http://forums.mozillazine.org/viewforum.php?f=46 - for help with Sunbird, this forum is for Firefox support.

  • Hoping for some help with a very frustrating issue!   I have been syncing my iPhone 5s and Outlook 2007 calendar and contacts with iCloud on my PC running Vista. All was well until the events I entered on the phone were showing up in Outlook, but not

    Hoping for some help with a very frustrating issue!
    I have been syncing calendar and contacts on my iPhone 5 and Outlook 2007 using iCloud  2.1.3 (my PC is running Vista). All was well until the events I entered on the phone were showing up in Outlook, but not the other way around. I’ve tried the usual recommended steps: deselecting calendar and contacts in the iCloud control panel and then re-selecting, signing out of the panel and back in, and repairing the Outlook installation in control panel.  I even uninstalled iCloud on the PC and downloaded it again (same version). 
    The furthest I’ve gotten is step 2 (and once, step 3) of 7 while performing “Outlook Setup For iCloud.” At that point I get, “Your setup couldn’t be started because of an unexpected error.”  After the first attempt at all this, all my calendar events disappeared from Outlook, although they are still in iCloud calendar and on my phone.
    Sound familiar?  Any ideas on how to solve this iCloud/Outlook issue?  Thanks much in advance!

    Hoping for some help with a very frustrating issue!
    I have been syncing calendar and contacts on my iPhone 5 and Outlook 2007 using iCloud  2.1.3 (my PC is running Vista). All was well until the events I entered on the phone were showing up in Outlook, but not the other way around. I’ve tried the usual recommended steps: deselecting calendar and contacts in the iCloud control panel and then re-selecting, signing out of the panel and back in, and repairing the Outlook installation in control panel.  I even uninstalled iCloud on the PC and downloaded it again (same version). 
    The furthest I’ve gotten is step 2 (and once, step 3) of 7 while performing “Outlook Setup For iCloud.” At that point I get, “Your setup couldn’t be started because of an unexpected error.”  After the first attempt at all this, all my calendar events disappeared from Outlook, although they are still in iCloud calendar and on my phone.
    Sound familiar?  Any ideas on how to solve this iCloud/Outlook issue?  Thanks much in advance!

  • Help with HP Laser Printer 1200se

    HP Support Line,
    Really need your assistance.  I have tried both contacting HP by phone (told they no longer support our printer via phone help), the tech told me that I needed to contact HP by e-mail for assistance.   I then sent an e-mail for assistance and got that reply today, the reply is as follows  "Randall, unfortunately, HP does not offer support via e-mail for your product.  However many resources are available on the HP web site that may provide the answer to your inquiry.  Support is also available via telephone.  A list of technical support numbers can be round at the following URL........."  The phone numbers listed are the ones I called and the ones that told me I needed to contact the e-mail support for help.
    So here I am looking for your help with my issue.
    We just bought a new HP Pavillion Slimline Desk Top PC (as our 6 year old HP Pavillion PC died on us).  We have 2 HP printers, one (an all-in-one type printer, used maily for copying and printing color, when needed) is connected and it is working fine with the exception of the scanning option (not supported by Windows 7).  However we use our Laser Printer for all of our regular prining needs.  This is the HP LaserPrinter 1200se, which is about 6 years old but works really well.  For this printer we currently only have a parallel connection type cord and there is not a parallel port on the Slimline HP PC.  The printer also has the option to connedt a USB cable (we do not currently have this type of cable).
    We posed the following two questions:
    1.  Is the Laser Jet 1200se compatible with Windows 7?
    and if this is the case
    2.  Can we purchase either a) a USC connection cord (generic or do we need a printer specific cord)? or b) is there there a printer cable converter adapater to attach to our parallel cable to convert to a USB connection?
    We do not want to purchase the USB cable if Windows 7 will not accept the connection, or if doing this will harm the PC.
    We really would appreciate any assitance that you might give us.
    Thank you,
    Randy and Leslie Gibson

    Sorry, both cannot be enabled by design.  That said, devices on a network do not care how others are connected.  You can print from a wireless connection to a wired (Ethernet) printer and v/v.
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • Going to Australia and need help with Power converters

    Facts:
    US uses 110v on 60hz
    Australia 220v on 50hz
    Making sure I understood that correctly.  Devices I plan on bringing that will use power are PS3 Slim, MacBook Pro 2008 model, and WD 1TB External HDD.  My DS, and Cell are charging via USB to save trouble of other cables.
    Ideas I've had or thought of:
    1.  Get a power converter for a US Powerstrip, and then plug in my US items into the strip and then the strip into an AUS Converter into Australian outlet.  Not sure if this fixes the voltage/frequency change.
    2.  Get power converters for all my devices.  But, not sure if my devices needs ways of lowering the voltage/increasing frequency or something to help with the adjustment.
    3.  Buy a universal powerstrip, which is extremely costly and I wouldn't be able to have here in time (I leave Thursday).  Unless Best Buy carrys one.  

    godzillafan868 wrote:
    Facts:
    US uses 110v on 60hz
    Australia 220v on 50hz
    Making sure I understood that correctly.  Devices I plan on bringing that will use power are PS3 Slim, MacBook Pro 2008 model, and WD 1TB External HDD.  My DS, and Cell are charging via USB to save trouble of other cables.
    Ideas I've had or thought of:
    1.  Get a power converter for a US Powerstrip, and then plug in my US items into the strip and then the strip into an AUS Converter into Australian outlet.  Not sure if this fixes the voltage/frequency change.
    2.  Get power converters for all my devices.  But, not sure if my devices needs ways of lowering the voltage/increasing frequency or something to help with the adjustment.
    3.  Buy a universal powerstrip, which is extremely costly and I wouldn't be able to have here in time (I leave Thursday).  Unless Best Buy carrys one.  
    Check the specs on input voltage/frequency of your power supplies.
    Many laptop power supplies are "universal/global" and are specced something like 80-265 volts AC 50/60 Hz, but not all.  These will just need a connector adapter.
    Unsure about the PS3 Slim - if it isn't universal it could be difficult as you'll need a 110/220 transformer, one big enough (power-handling wise) for the PS3 will be very bulky.
    For the external WD HDD, if it doesn't have a universal supply, you're probably best off just finding a new wallwart for it that is capable of running on 220/50.
    *disclaimer* I am not now, nor have I ever been, an employee of Best Buy, Geek Squad, nor of any of their affiliate, parent, or subsidiary companies.

Maybe you are looking for