如何在eclipse中打开查看.class文件(查看源码)

-如何通过eclipse读取.class文件
–配置环境:macOS high Sierra 10.13.6/window10
–生产环境:eclipse2018.a


  • 打开eclipse macketplace:help–eclipse macketplace
  • 输入Enhanced Class Decompiler
    在这里插入图片描述
  • 然后等待安装完成,重启eclipse。
  • 右击.class文件,然后选择open class with…–>jad
    在这里插入图片描述
  • 如图所示:

在这里插入图片描述

  • 补充
    支持的版本是
    Eclipse Versions:
    2021-06 (4.20), 2021-03 (4.19), 2020-12 (4.18), 2020-09 (4.17), 2020-06 (4.16), 2020-03 (4.15), 2019-12 (4.14), 2019-09 (4.13), 2019-06 (4.12), 2019-03 (4.11), 2018-12 (4.10), 2018-09 (4.9), Photon (4.8)下载前可以通过
    help–about eclipse查看自己的eclipse版本。如果版本偏旧,可以通过升级/改用网上的另外的工具如JD-GUI.app等
  • 14
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 14
    评论
org.eclipse.jface.dialogs.Dialog 是 Eclipse JFace 库的一个类,它提供了一个可定制的对话框窗口,可以用于显示信息、获取用户输入或进行其他交互。Dialog 类实现了一个标准窗口 shell,可以包含任意的 SWT 控件。 使用 Dialog 类创建一个对话框窗口的基本步骤如下: 1. 创建一个继承自 Dialog 类的子类,并实现必要的构造函数和 createDialogArea() 方法,该方法创建对话框的主要内容。 2. 在构造函数设置对话框的标题和样式,例如是否支持调整大小、是否具有模态行为等。 3. 重写 createContents() 方法,该方法创建对话框的按钮区域和其他控件。 4. 提供必要的 getter 和 setter 方法,以便其他类可以访问对话框的数据。 5. 如果需要对用户输入进行验证,可以重写 validateInput() 方法。 下面是一个简单的示例代码,演示了如何使用 Dialog 类创建一个简单的对话框窗口: ``` import org.eclipse.jface.dialogs.Dialog; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; public class MyDialog extends Dialog { private Text text; private String input; public MyDialog(Shell parentShell) { super(parentShell); setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); setText("My Dialog"); } @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); GridLayout layout = new GridLayout(2, false); layout.marginRight = 5; layout.marginLeft = 10; container.setLayout(layout); Label lblNewLabel = new Label(container, SWT.NONE); lblNewLabel.setText("Input:"); text = new Text(container, SWT.BORDER); text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); return container; } @Override protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.OK_ID, "OK", true); createButton(parent, IDialogConstants.CANCEL_ID, "Cancel", false); } @Override protected void buttonPressed(int buttonId) { if (buttonId == IDialogConstants.OK_ID) { input = text.getText(); } else { input = null; } super.buttonPressed(buttonId); } @Override protected void configureShell(Shell shell) { super.configureShell(shell); shell.setSize(300, 200); } @Override protected boolean isResizable() { return true; } public String getInput() { return input; } public void setInput(String input) { this.input = input; } @Override protected void okPressed() { validateInput(); super.okPressed(); } private void validateInput() { if (text.getText().isEmpty()) { setErrorMessage("Input must not be empty"); } else { setErrorMessage(null); } } } ``` 在这个示例,我们创建了一个名为 MyDialog 的子类,它包含一个文本框用于输入文本。我们在构造函数设置了对话框的标题和样式,并在 createDialogArea() 方法创建了文本框。我们还重写了 createButtonsForButtonBar() 方法以创建 OK 和 Cancel 按钮,并重写了 buttonPressed() 方法以处理按钮点击事件。最后,我们提供了 getter 和 setter 方法以便其他类可以访问对话框的数据,并重写了 okPressed() 方法和 validateInput() 方法以验证用户输入。 通过调用 MyDialog.open() 方法,我们可以在 Eclipse 应用程序显示这个对话框窗口: ``` MyDialog dialog = new MyDialog(shell); if (dialog.open() == Window.OK) { String input = dialog.getInput(); // Do something with the input } ``` 在这个示例,我们创建了一个 MyDialog 对象,并调用其 open() 方法以显示对话框窗口。如果用户单击 OK 按钮,我们可以通过调用 getInput() 方法获取用户输入的文本。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值