IntelliJ IDEA多屏后窗口不显示问题解决方案

2025-05-29 0 15

IDEA 在接入外接屏且扩展的情况下,如果突然拔掉外接屏,就可能会产生IDEA 整个窗口只在屏幕的右侧显示一点点边框且无法拖拽到当前屏幕的情况。

在不再次接入外接屏的情况下,想要把IDEA窗口拖拽回当前屏幕,可以找到项目中.idea 文件夹下的workspace.xml 文件
全文搜索ProjectFrameBounds 关键字,修改x和y的值为0或者直接将name="x",name="y"的这两行删除即可,然后重启IDEA即可

IntelliJ IDEA多屏后窗口不显示问题解决方案

因为经常遇到这种情况,所以自己写了个java 小工具,一键删除 name="x",name="y" 这两行记录,同时生成一个原始文件的.bak 文件,入参只需要文件路径

其中的核心代码逻辑示例如下:

(标签: 使用Java 实现删除某个文件中 包含特定字符的行)

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113
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;

}

}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持快网idc。

原文链接:https://www.cnblogs.com/acm-bingzi/p/idea_name_x.html

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 IntelliJ IDEA多屏后窗口不显示问题解决方案 https://www.kuaiidc.com/116872.html

相关文章

发表评论
暂无评论