据我所知,这已经过去很多次了,我一直在谷歌搜索这几个小时但由于某种原因,我不能让这个工作。请放轻松我...我是java的菜鸟,我是一个vb.net男孩。 感谢您的帮助
这是我的调用页面中的按钮监听器代码。我收到错误
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);
}
}
我也试过这个听众。同样错误
private class BtnEditPayMouseListener extends MouseAdapter {
@Override
public void mouseClicked(MouseEvent e) {
Pay_Types p = new Pay_Types();
p.setvisable(true);
}
}
这是我的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);
}
}
再次......感谢帮助
谢谢安德鲁我确实忘记了这个问题......我做错了什么?答案 0 :(得分:1)
要么Pay_Types extends JFrame
或p.getFrame().setVisible(true);
Pay_Types不是帧类型,因此您收到上述错误。