IntelliJ IDEA多屏后窗口不显示问题解决方案
作者:贾树丙 时间:2022-11-17 14:40:45
IDEA 在接入外接屏且扩展的情况下,如果突然拔掉外接屏,就可能会产生IDEA 整个窗口只在屏幕的右侧显示一点点边框且无法拖拽到当前屏幕的情况。
在不再次接入外接屏的情况下,想要把IDEA窗口拖拽回当前屏幕,可以找到项目中.idea 文件夹下的workspace.xml 文件
全文搜索ProjectFrameBounds 关键字,修改x和y的值为0或者直接将name="x",name="y"的这两行删除即可,然后重启IDEA即可
因为经常遇到这种情况,所以自己写了个java 小工具,一键删除 name="x",name="y" 这两行记录,同时生成一个原始文件的.bak 文件,入参只需要文件路径
其中的核心代码逻辑示例如下:
(标签: 使用Java 实现删除某个文件中 包含特定字符的行)
import java.io.*;
/**
* @author jiashubing
* @since 2019/5/22
*/
public class DeleteLine {
public static void main(String[] args) {
String path = "C:\\Users\\jiashubing\\Desktop\\ttt\\workspace.xml";
deleteLine(path);
}
private static String deleteLine(String path) {
int a = path.lastIndexOf('/');
int b = path.lastIndexOf('\\');
if (a < 0 && b < 0) {
return "没有目录分隔符";
}
//删除原来的备份文件
String bakpath = path + ".bak";
if (deleteFile(bakpath)) {
return "删除原始的备份文件失败,备份文件为:" + bakpath;
}
String bakpath2 = path + ".bak2";
if (deleteFile(bakpath2)) {
return "删除原始的临时备份文件失败,备份文件为:" + bakpath2;
}
//创建临时备份文件
File bakFile2 = new File(bakpath2);
boolean nFlag = false;
try {
nFlag = bakFile2.createNewFile();
} catch (IOException e) {
return "创建临时备份文件失败,备份文件为:" + bakpath2 + " 错误信息为:" + e.getMessage();
}
if (!nFlag) {
return "创建临时备份文件失败,备份文件为:" + bakpath2;
}
String ans = getAns(path);
if (ans == null) {
return "读取并修改原始文件失败";
}
if (!addNewFile(bakpath2, ans)) {
return "将修改后的内容写入到新文件失败";
}
File oldFile = new File(path);
boolean mvFlag = oldFile.renameTo(new File(bakpath));
if (!mvFlag) {
return "将原始文件重命名成备份文件失败";
}
boolean mvFlag2 = bakFile2.renameTo(new File(path));
if (!mvFlag2) {
return "将临时备份文件重命名成原始文件失败";
}
return "执行成功";
}
private static boolean deleteFile(String bakpath) {
File bakFile = new File(bakpath);
if (bakFile.exists() && bakFile.isFile()) {
boolean delFlag = bakFile.delete();
if (!delFlag) {
return true;
}
}
return false;
}
private static String getAns(String path) {
File oldFile = new File(path);
if (!oldFile.exists() || !oldFile.isFile()) {
return null;
}
StringBuilder ans = new StringBuilder();
String encoding = "UTF-8";
try (InputStreamReader read = new InputStreamReader(
new FileInputStream(oldFile), encoding);
BufferedReader bufferedReader = new BufferedReader(read)) {
String lineTxt = null;
while ((lineTxt = bufferedReader.readLine()) != null) {
if (lineTxt.contains("name=\"x\"") || lineTxt.contains("name=\"y\"")) {
continue;
}
ans.append(lineTxt + "\n");
}
} catch (Exception e) {
return null;
}
return ans.toString();
}
private static boolean addNewFile(String path, String ans) {
File file = new File(path);
try (Writer out = new FileWriter(file)) {
out.write(ans);
} catch (IOException e) {
return false;
}
return true;
}
}
来源:https://www.cnblogs.com/acm-bingzi/p/idea_name_x.html
标签:IntelliJ,IDEA,多屏,窗口
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
SpringBoot整合Zookeeper详细教程
2022-07-24 11:33:09
![](https://img.aspxhome.com/file/2023/2/63392_0s.png)
SpringBoot中使用Servlet三大组件的方法(Servlet、Filter、Listener)
2021-07-19 18:41:43
![](https://img.aspxhome.com/file/2023/3/104703_0s.png)
解读JSONArray删除元素的两种方式
2022-10-31 11:40:50
Android自定义Seekbar滑动条 Pop提示跟随滑动按钮滑动
2021-11-02 20:32:06
![](https://img.aspxhome.com/file/2023/5/108315_0s.gif)
为什么Java开发需要配置环境变量
2023-08-13 13:11:03
![](https://img.aspxhome.com/file/2023/2/58052_0s.png)
C#全局热键设置与窗体热键设置实例
2022-09-30 05:38:52
Android EditText限制输入字符的方法总结
2023-04-22 03:16:24
![](https://img.aspxhome.com/file/2023/6/92606_0s.png)
struts2单个文件上传的两种实现方式
2023-04-23 05:33:30
![](https://img.aspxhome.com/file/2023/4/88734_0s.jpg)
C++多重继承二义性原理实例解析
2021-10-08 20:18:33
![](https://img.aspxhome.com/file/2023/4/112304_0s.png)
详解C#中的依赖注入和IoC容器
2023-03-11 09:05:19
![](https://img.aspxhome.com/file/2023/2/82232_0s.png)
在C#中global关键字的作用及其用法
2021-12-24 04:33:19
Android中解决EditText放到popupWindow中,原有复制、粘贴、全选、选择功能失效问题
2021-07-12 10:51:49
![](https://img.aspxhome.com/file/2023/8/139358_0s.png)
Java Springboot整合支付宝接口的教程详解
2023-11-06 19:41:49
![](https://img.aspxhome.com/file/2023/9/58749_0s.png)
c# wpf如何附加依赖项属性
2023-01-09 05:05:56
![](https://img.aspxhome.com/file/2023/5/88415_0s.png)
MyBatis实现物理分页的实例
2023-03-13 04:21:45
Java开发必备的三大修饰符
2021-10-19 10:11:01
![](https://img.aspxhome.com/file/2023/0/75780_0s.png)
Java四种常用线程池的详细介绍
2021-09-29 17:45:46
mybatis中<if>标签bool值类型为false判断方法
2023-11-20 11:28:33
Android系统中的蓝牙连接程序编写实例教程
2023-09-06 08:59:01
android仿直播圆点加载效果
2023-11-13 07:11:10
![](https://img.aspxhome.com/file/2023/1/139231_0s.png)