在第二帧的主框架上设置字符串

时间:2016-11-07 22:54:09

标签: java jframe

大家好我试图在我的主框架上设置一个字符串值,并在另一个框架中生成一个值,但我不知道该怎么做,这是我的代码到目前为止。

这是我的主机打开我输入数据的查询框架

std::unique_ptr<int> a;
LegacyFunctionRawPointer(a.get(), 1, 2.0f);

这是查询字段

public class InfoCd extends JFrame {

    private JPanel contentPane;
    private JTable table;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    InfoCd frame = new InfoCd();
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
Connection conn=null;
private JTextField verConsulta;


    /**
     * Create the frame.
     */
    public InfoCd() {

        conn=sqliteConnection.dbConnector();

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 753, 477);
        contentPane = new JPanel();
        contentPane.setBackground(SystemColor.activeCaption);
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(contentPane);
        contentPane.setLayout(null);

        JButton btnHacerConsulta = new JButton("Hacer Consulta");

        btnHacerConsulta.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    Query q = new Query();
                    q.setVisible(true);
                    String userQuery = Query.getqueryField();//here is the problem im sending the value before filling it in the second frame
                    Statement statement = conn.createStatement();
                    ResultSet rs = statement.executeQuery(userQuery);
                    table.setModel(DbUtils.resultSetToTableModel(rs));

                    //insert delete update

                } catch (Exception e2) {
                    e2.printStackTrace();
                }

            }
        });
        btnHacerConsulta.setBounds(20, 388, 169, 39);
        contentPane.add(btnHacerConsulta);

        JScrollPane scrollPane = new JScrollPane();
        scrollPane.setBounds(10, 0, 737, 367);
        contentPane.add(scrollPane);

        table = new JTable();
        scrollPane.setViewportView(table);

        verConsulta = new JTextField();
        verConsulta.setBounds(260, 388, 359, 29);
        contentPane.add(verConsulta);
        verConsulta.setColumns(10);
    }
}

0 个答案:

没有答案