小编sAa*_*aNu的帖子

如何从Java中的ArrayList中删除特定对象?

如何从ArrayList中删除特定对象?假设我有一个如下课程:

import java.util.ArrayList;    
public class ArrayTest {
    int i;

    public static void main(String args[]){
        ArrayList<ArrayTest> test=new ArrayList<ArrayTest>();
        ArrayTest obj;
        obj=new ArrayTest(1);
        test.add(obj);
        obj=new ArrayTest(2);
        test.add(obj);
        obj=new ArrayTest(3);
        test.add(obj);
    }
    public ArrayTest(int i){
        this.i=i;
    }
}
Run Code Online (Sandbox Code Playgroud)

如何new ArrayTest(1)从我的删除对象ArrayList<ArrayList>

java arraylist

22
推荐指数
5
解决办法
15万
查看次数

如何在android中的AlertDialog中包含自定义标题视图?

我如何在alertDialog中包含自定义标题栏?我知道android sdk提供了setCustomTitle方法,但它不起作用

编辑:

    AlertDialog alert = new AlertDialog.Builder(this).setTitle("Test").setMessage("hello").show();
    View view=alert.getLayoutInflater().inflate(R.layout.titlebar, null);
    alert.setCustomTitle(view);
Run Code Online (Sandbox Code Playgroud)

但上面的代码不起作用

注意: 我不是在寻找自定义对话框,而是只想使其标题布局自定义.如下所示喜欢这个用关闭按钮

android custom-titlebar android-alertdialog

16
推荐指数
1
解决办法
3万
查看次数

ResultSet:异常:set type是TYPE_FORWARD_ONLY - 为什么?

我有非常简单的代码:

pstat=con.prepareStatement("select typeid from users where username=? and password=?");             
pstat.setString(1, username);
pstat.setString(2, password);
rs=pstat.executeQuery();
int rowCount=0;
while(rs.next())
{       
    rowCount++;         
}
rs.beforeFirst();
if(rowCount>=1)
{
while(rs.next())
{
    typeID=rs.getInt(1);
}
Run Code Online (Sandbox Code Playgroud)

但是当执行这段代码时我得到了......

java.sql.SQLException: Result set type is TYPE_FORWARD_ONLY
at sun.jdbc.odbc.JdbcOdbcResultSet.beforeFirst(Unknown Source)
at server.ClientImpl.login(ClientImpl.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown …
Run Code Online (Sandbox Code Playgroud)

java sql resultset jdbc-odbc

13
推荐指数
5
解决办法
6万
查看次数

停止后无法启动RMI服务器

我在停止后重新启动RMI注册表时遇到问题:

import java.rmi.*;
import java.rmi.registry.*;
import java.rmi.server.UnicastRemoteObject;
import javax.swing.JOptionPane;

public class CinemaServer
{
    private Registry registry;
    ClientImpl clientImple; //remote interface implemented class
    private static String title="Cinema Pvt Ltd";

    public CinemaServer() {
        try {
            clientImple = new ClientImpl();
            registry=LocateRegistry.createRegistry(3311);
            registry.rebind("RMI_INSTANCE", clientImple);
    } catch (RemoteException e) {
            JOptionPane.showMessageDialog(null, "Can't Start RMI Server",title,JOptionPane.ERROR_MESSAGE);
        }
    }

    public void stopServer()
    {
        try {
            registry.unbind("RMI_INSTANCE");
            UnicastRemoteObject.unexportObject(clientImple, true);
        } catch (NotBoundException e) {
            JOptionPane.showMessageDialog(null, "Can't Stop Server",title,JOptionPane.ERROR_MESSAGE);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)
  1. 我启动服务器: CinemaServer ser=new CinemaServer();

  2. 当我打电话给ser.stopServer();它停止. …

java rmi

12
推荐指数
1
解决办法
1万
查看次数

如何使用eclipse包含jar文件中的所有图像

我创建了一个java应用程序并将所有类捆绑在一个jar文件中.当我从eclipse运行项目时,我的应用程序运行成功.但是当我尝试运行我的.jar文件时,我没有得到我的应用程序使用的图标.在代码中,我从项目文件夹中的images目录中获取了我的图标.使用jar时,如何将这些图像文件呈现给最终用户?

我正在加载图像:

 final public ImageIcon iReport=new ImageIcon("images/Report.png");
Run Code Online (Sandbox Code Playgroud)

我也试过了

final public ImageIcon iquit=new ImageIcon(getClass().getResource("images/quit.png"));
Run Code Online (Sandbox Code Playgroud)

final public ImageIcon iquit=new ImageIcon(getClass().getResource("/images/quit.png"));
Run Code Online (Sandbox Code Playgroud)

但这会导致错误:

Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
Run Code Online (Sandbox Code Playgroud)

java eclipse jar

8
推荐指数
1
解决办法
3万
查看次数

如何在Android-x86模拟器(VirtualBox)中模拟gps位置?

我想在Android模拟器(移植到Android x86中)获取经度和纬度进行测试.

任何人都可以指导我如何实现这一目标吗?

如何将仿真器的位置设置为测试位置?

maps android android-x86

4
推荐指数
1
解决办法
1万
查看次数

从选定的JTable中获取对象

我有一个JTable显示书的列表,它可以过滤和排序

BookSwing.java

package com.bookretailer.ui;

import java.awt.Component;
import java.awt.EventQueue;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.RowFilter;
import javax.swing.RowSorter;
import javax.swing.SortOrder;
import javax.swing.border.TitledBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;

import com.bookretailer.modules.Book;
import com.bookretailer.modules.utils.BookDB;

public class BookSwing extends JFrame {
    private final static String TITLE = "Book Retailer - Books";

    private JPanel jpInfo = …
Run Code Online (Sandbox Code Playgroud)

java swing jtable listselectionlistener

3
推荐指数
1
解决办法
2万
查看次数

从两个表的两列中获得最大值

我有两张桌子

T1

id     name
1      saanu
3      abc
Run Code Online (Sandbox Code Playgroud)

delT1

id    name
2     val2
4     val4
Run Code Online (Sandbox Code Playgroud)

我必须从两个表中找出id(int)的最大值.

sql select

1
推荐指数
1
解决办法
982
查看次数