0

I understand that this has be gone over many many times and I've been googling this for hours but for some reason I cant get this working. Please take it easy on me...I'm a noob to java, I'm a vb.net boy. Thanks For The Help

Here is my button listener code from my calling page. I get an error of

Method setvisable(boolean) is unidentified for the type Pay_Types

private class BtnEditPayActionListener implements ActionListener {
        public void actionPerformed(ActionEvent arg0) {
            Pay_Types p = new Pay_Types();
            p.setvisable(true);
        }
    }

I have also tried this listener. Same Error here

private class BtnEditPayMouseListener extends MouseAdapter {
    @Override
    public void mouseClicked(MouseEvent e) {
        Pay_Types p = new Pay_Types();
        p.setvisable(true);         
    }
}

Here is my code for Pay_Types.java.

package com.dooleyfam.bep1;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JCheckBox;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JButton;

public class Pay_Types {

    private JFrame frame;
    private JCheckBox chckbxEmpty;
    private JCheckBox chckbxPerLoadedMile;
    private JCheckBox chckbxHourly;
    private JCheckBox chckbxOvertime;
    private JPanel panel;
    private JPanel panel_1;
    private JPanel panel_2;
    private JCheckBox chckbxPerMile;
    private JCheckBox chckbxPerDay;
    private JCheckBox chckbxOther;
    private JPanel panel_3;
    private JCheckBox chckbxPerCwthundred;
    private JCheckBox chckbxPercentageOf;
    private JCheckBox chckbxOther_1;
    private JTextField textField;
    private JTextField textField_1;
    private JTextField textField_3;
    private JTextField textField_4;
    private JTextField textField_6;
    private JTextField textField_7;
    private JTextField textField_8;
    private JTextField textField_9;
    private JLabel lblDenotesThat;
    private JButton btnCancel;
    private JButton btnOk;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    Pay_Types window = new Pay_Types();
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the application.
     */
    public Pay_Types() {
        initialize();
    }

    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        frame = new JFrame();
        frame.setBounds(100, 100, 503, 285);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().setLayout(null);

        panel = new JPanel();
        panel.setBorder(new TitledBorder(null, "Per Mile", TitledBorder.LEADING, TitledBorder.TOP, null, null));
        panel.setBounds(6, 11, 166, 97);
        frame.getContentPane().add(panel);
        panel.setLayout(null);

        chckbxEmpty = new JCheckBox("Empty");
        chckbxEmpty.setBounds(102, 15, 55, 23);
        panel.add(chckbxEmpty);

        chckbxPerLoadedMile = new JCheckBox("Loaded");
        chckbxPerLoadedMile.setBounds(102, 41, 61, 23);
        panel.add(chckbxPerLoadedMile);

        chckbxOther = new JCheckBox("Other*");
        chckbxOther.setBounds(102, 67, 61, 23);
        panel.add(chckbxOther);

        textField_3 = new JTextField();
        textField_3.setBounds(10, 16, 86, 20);
        panel.add(textField_3);
        textField_3.setColumns(10);

        textField_4 = new JTextField();
        textField_4.setBounds(10, 42, 86, 20);
        panel.add(textField_4);
        textField_4.setColumns(10);

        panel_1 = new JPanel();
        panel_1.setBorder(new TitledBorder(null, "Hourly", TitledBorder.LEADING, TitledBorder.TOP, null, null));
        panel_1.setBounds(182, 11, 297, 71);
        frame.getContentPane().add(panel_1);
        panel_1.setLayout(null);

        chckbxOvertime = new JCheckBox("Overtime");
        chckbxOvertime.setBounds(102, 40, 86, 23);
        panel_1.add(chckbxOvertime);

        chckbxHourly = new JCheckBox("Regular");
        chckbxHourly.setBounds(102, 14, 68, 23);
        panel_1.add(chckbxHourly);

        textField_6 = new JTextField();
        textField_6.setBounds(10, 15, 86, 20);
        panel_1.add(textField_6);
        textField_6.setColumns(10);

        textField_7 = new JTextField();
        textField_7.setBounds(10, 41, 86, 20);
        panel_1.add(textField_7);
        textField_7.setColumns(10);

        panel_2 = new JPanel();
        panel_2.setBorder(new TitledBorder(null, "Per Diem", TitledBorder.LEADING, TitledBorder.TOP, null, null));
        panel_2.setBounds(0, 108, 172, 71);
        frame.getContentPane().add(panel_2);
        panel_2.setLayout(null);

        chckbxPerMile = new JCheckBox("Per Mile");
        chckbxPerMile.setBounds(102, 14, 63, 23);
        panel_2.add(chckbxPerMile);

        chckbxPerDay = new JCheckBox("Per Day");
        chckbxPerDay.setBounds(102, 40, 63, 23);
        panel_2.add(chckbxPerDay);

        textField_8 = new JTextField();
        textField_8.setBounds(10, 15, 86, 20);
        panel_2.add(textField_8);
        textField_8.setColumns(10);

        textField_9 = new JTextField();
        textField_9.setBounds(10, 42, 86, 20);
        panel_2.add(textField_9);
        textField_9.setColumns(10);

        panel_3 = new JPanel();
        panel_3.setBorder(new TitledBorder(null, "Other", TitledBorder.LEADING, TitledBorder.TOP, null, null));
        panel_3.setBounds(182, 82, 297, 97);
        frame.getContentPane().add(panel_3);
        panel_3.setLayout(null);

        chckbxPerCwthundred = new JCheckBox("Per Hundred Weight (CWT)");
        chckbxPerCwthundred.setBounds(102, 14, 157, 23);
        panel_3.add(chckbxPerCwthundred);

        chckbxPercentageOf = new JCheckBox("Percentage of Line Haul (PLH)");
        chckbxPercentageOf.setBounds(102, 41, 169, 23);
        panel_3.add(chckbxPercentageOf);

        chckbxOther_1 = new JCheckBox("Other (Flat Rate, Percentage) *");
        chckbxOther_1.setBounds(102, 68, 189, 23);
        panel_3.add(chckbxOther_1);

        textField = new JTextField();
        textField.setBounds(10, 15, 86, 20);
        panel_3.add(textField);
        textField.setColumns(10);

        textField_1 = new JTextField();
        textField_1.setBounds(10, 42, 86, 20);
        panel_3.add(textField_1);
        textField_1.setColumns(10);

        lblDenotesThat = new JLabel("* Denotes that the amount is entered on the main screen.");
        lblDenotesThat.setBounds(85, 190, 283, 14);
        frame.getContentPane().add(lblDenotesThat);

        btnCancel = new JButton("Cancel");
        btnCancel.setBounds(390, 215, 89, 23);
        frame.getContentPane().add(btnCancel);

        btnOk = new JButton("OK");
        btnOk.setBounds(291, 215, 89, 23);
        frame.getContentPane().add(btnOk);
    }
}

Again...Thanks For The Help

Thx Andrew I did forget the question....What am I doing wrong?

Priyanka.Patil
  • 1,177
  • 2
  • 15
  • 34
mndooley
  • 3
  • 1
  • 3
  • 1
    1) See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/418556) 2) What is your question? [Edit the post](http://stackoverflow.com/posts/15518103/edit) and make sure to add a '?' to the end of it. – Andrew Thompson Mar 20 '13 at 07:57
  • 2
    @mKorbel That should be an answer. OP - 'coding by magic' never works. You need to consult the documentation. – Andrew Thompson Mar 20 '13 at 07:59
  • 1
    unrelated: don't do any manual sizing/locating of components, that's the exclusive task of the LayoutManager – kleopatra Mar 20 '13 at 08:42
  • @Andrew Thompson Ok, I get where your going with the bad practice and see where I'm going wrong right now with this particular problem. But, that link you posted does leave me with a question...if I may...my calling page will be my main window and the Pay_Type is more of a wizard to enter and edit data. I would like it to open in a new window and no extra icons in the task bar. What do you advise? – mndooley Mar 20 '13 at 08:58

1 Answers1

1

Either make Pay_Types extends JFrame or p.getFrame().setVisible(true);

Pay_Types is not of type frame hence you are getting the above error.

Michaël
  • 3,679
  • 7
  • 39
  • 64
Sudhanshu Umalkar
  • 4,174
  • 1
  • 23
  • 33
  • Your answer did help point me in the direction of where I went wrong...when I created Pay_Types I didn't create it as a jFrame but as an Application Window. But, your code didn't work I got the same error with getFrame() as I did with setVisible(). – mndooley Mar 20 '13 at 08:29
  • @mndooley we aren't debugging service here, this answer solved exception about that is this question.... – mKorbel Mar 20 '13 at 08:41
  • You need to provide that getter method in your class. – Sudhanshu Umalkar Mar 20 '13 at 08:41
  • After looking around a bit I see what you mean...your right. Thx – mndooley Mar 20 '13 at 08:53
  • @mKorbel I get that, and please understand that I'm still learning as stated in the original post. No need to be rude. – mndooley Mar 20 '13 at 08:57