会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132905个问题

client

rmiclient.rar


server

rmiDemo.rar


Exception in thread "main" java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: 

java.net.ConnectException: Connection refused: connect

at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)

at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)

at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)

at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:342)

at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)

at java.rmi.Naming.lookup(Naming.java:101)

at com.bjsxt.Client.main(Client.java:12)

Caused by: java.net.ConnectException: Connection refused: connect

at java.net.DualStackPlainSocketImpl.connect0(Native Method)

at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)

at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)

at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)

at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)

at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)

at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

at java.net.Socket.connect(Socket.java:589)

at java.net.Socket.connect(Socket.java:538)

at java.net.Socket.<init>(Socket.java:434)

at java.net.Socket.<init>(Socket.java:211)

at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)

at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148)

at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)

... 6 more


Process finished with exit code 1



image.png


JAVA 全系列/第十一阶段:分布式RPC调用和分布式文件存储/Zookeeper 15301楼

# coding=utf-8
"""开发记事本软件的菜单
"""


from tkinter.filedialog import *
from tkinter.colorchooser import *
from tkinter import *

class Application(Frame):

    def __init__(self, master=None):
        super().__init__(master)        # super()代表的是父类的定义,而不是父类对象
        self.master = master
        self.textpad = None             # textpad表示Text文本框对象
        self.pack()
        self.createWidget()

    def createWidget(self):
        # 创建主菜单栏
        menubar = Menu(root)

        # 创建子菜单
        menuFile = Menu(menubar)
        menuEdit = Menu(menubar)
        menuHelp = Menu(menubar)

        # 将子菜单加入到主菜单栏
        menubar.add_cascade(label="文件(F)", menu=menuFile)
        menubar.add_cascade(label="编辑(E)", menu=menuEdit)
        menubar.add_cascade(label="帮助(H)", menu=menuHelp)

        # 添加菜单项
        menuFile.add_command(label="新建", accelerator="ctrl+n", command=self.newfile)
        menuFile.add_command(label="打开", accelerator="ctrl+o", command=self.openfile)
        menuFile.add_command(label="保存", accelerator="ctrl+s",command=self.savefile)
        menuFile.add_separator()  # 添加分割线
        menuFile.add_command(label="退出", accelerator="ctrl+q",command=self.exit)


        # 将主菜单栏加到根窗口
        root["menu"] = menubar

        #增加快捷键的处理
        root.bind("<Control-n>",lambda event:self.newfile())
        root.bind("<Control-o>",lambda event:self.openfile())
        root.bind("<Control-s>", lambda event: self.savefile())
        root.bind("<Control-q>", lambda event: self.exit())

        #文本编辑区
        self.textpad = Text(root, width=50, height=30)
        self.textpad.pack()

        # 创建上下菜单
        self.contextMenu = Menu(root)
        self.contextMenu.add_command(label="背景颜色", command=self.openAskColor)

        #为右键绑定事件
        root.bind("<Button-3>",self.createContextMenu)

    def newfile(self):
        self.textpad.delete("1.0", "end")  # 把text控件中所有的内容清空
        self.filename=asksaveasfilename(title="另存为",initialfile="未命名.txt",
                          filetypes=[("文本文档","*.txt")],
                          defaultextension=".txt") # initialfile初始化名称
        self.savefile()



    def openfile(self):
        self.textpad.delete("1.0","end")  #  把text控件中所有的内容清空
        with askopenfile(title="打开文本文件") as f:
            self.textpad.insert(INSERT,f.read())
            self.filename=f.name

    def savefile(self):
        with open(self.filename,"w") as f:
            c=self.textpad.get(1.0,END)
            f.write(c)

    def exit(self):
        root.quit()


    def openAskColor(self):
        s1=askcolor(color="red",title="选择背景色颜色")
        #  (0,0,0,255),"0000ff"
        self.textpad.config(bg=s1[1])

    def createContextMenu(self,event):
        # 菜单在鼠标右键单击的坐标处显示
        self.contextMenu.post(event.x_root, event.y_root)


if __name__ == '__main__':
    root = Tk()
    root.geometry("450x300+200+300")
    root.title("百战程序员的简易记事本")
    app = Application(master=root)
    root.mainloop()

老师,这个是什么错误?


(venv) D:\百战课堂练习第二阶段\gui>pyinstaller -F notebook.py
SyntaxError: Non-UTF-8 code starting with '\xb0' in file D:\百战课堂练习第二阶段\gui\venv\Scri
pts\pyinstaller-script.py on line 1, but no encoding declared; see http://python.org/dev/peps/
pep-0263/ for details


Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 15303楼
Python 全系列/第二十三阶段:人工智能基础_机器学习理论和实战(旧)/无约束最优化问题的求解算法 15304楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/反射技术 15305楼
JAVA 全系列/第六阶段:项目管理与SSM框架/SpringMVC旧 15308楼
JAVA 全系列/第三阶段:数据库编程/JDBC技术(旧) 15310楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/多线程技术(旧) 15311楼
JAVA 全系列/第一阶段:JAVA 快速入门/面向对象详解和JVM底层内存分析 15312楼
Python 全系列/第一阶段:Python入门/序列 15313楼
WEB前端全系列/第十四阶段:微信小程序/实战_百战商城 15314楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637