Skip to content

Commit 7656393

Browse files
committedDec 27, 2024
Update 2.1.0 fix duplicate button
Merge custom run button and run button into one
1 parent 1df5684 commit 7656393

File tree

3 files changed

+8
-62
lines changed

3 files changed

+8
-62
lines changed
 

‎src/Scrcpy_GUI.java

+1-26
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,6 @@ public static List<String> adb_devices() {
4949
return output;
5050
}
5151

52-
/**
53-
* Method to run scrcpy, this method execute
54-
* {@code scrcpy -s device_code -m 1024 -b 2M} command using ProcessBuilder.
55-
*
56-
* @param device_code device ID from adb devices list
57-
*
58-
* @author opelooo
59-
*/
60-
public static void run_scrcpy(String device_code) {
61-
new Thread(() -> {
62-
try {
63-
// Create a process to execute 'scrcpy'
64-
ProcessBuilder pb
65-
= new ProcessBuilder(
66-
"scrcpy", "-s", device_code, "-m 1024", "-b 2M"
67-
);
68-
69-
pb.start();
70-
// Optionally, monitor the process if needed
71-
} catch (IOException e) {
72-
e.printStackTrace(); // Handle exceptions properly
73-
}
74-
}).start(); // Start the new thread
75-
}
76-
7752
/**
7853
* Method to customize run scrcpy, this method execute
7954
* {@code scrcpy -s device_code -m 1024 -b 2M} command using ProcessBuilder.
@@ -87,7 +62,7 @@ public static void run_scrcpy(String device_code) {
8762
*
8863
* @author opelooo
8964
*/
90-
public static void custom_run_scrcpy(
65+
public static void run_scrcpy(
9166
String device_code, String maxSize, String bitRate,
9267
boolean videoOn, boolean screenOn, boolean stayAwake) {
9368
new Thread(() -> {

‎src/scrcpy_main_panel.form

+3-14
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
<Group type="103" groupAlignment="0" max="-2" attributes="0">
8383
<Component id="refreshButton" max="32767" attributes="0"/>
8484
<Component id="selectButton" max="32767" attributes="0"/>
85-
<Component id="runDefaultButton" max="32767" attributes="0"/>
8685
<Component id="runCustomButton" max="32767" attributes="0"/>
8786
<Component id="tcpipButton" max="32767" attributes="0"/>
8887
</Group>
@@ -98,15 +97,13 @@
9897
<EmptySpace max="-2" attributes="0"/>
9998
<Component id="selectButton" min="-2" max="-2" attributes="0"/>
10099
<EmptySpace max="-2" attributes="0"/>
101-
<Component id="runDefaultButton" min="-2" max="-2" attributes="0"/>
102-
<EmptySpace max="-2" attributes="0"/>
103100
<Component id="runCustomButton" min="-2" max="-2" attributes="0"/>
104101
<EmptySpace max="-2" attributes="0"/>
105102
<Component id="tcpipButton" min="-2" max="-2" attributes="0"/>
106-
<EmptySpace pref="199" max="32767" attributes="0"/>
103+
<EmptySpace max="32767" attributes="0"/>
107104
</Group>
108105
<Group type="102" alignment="0" attributes="0">
109-
<Component id="jScrollPane1" max="32767" attributes="0"/>
106+
<Component id="jScrollPane1" pref="338" max="32767" attributes="0"/>
110107
<EmptySpace max="-2" attributes="0"/>
111108
</Group>
112109
</Group>
@@ -154,17 +151,9 @@
154151
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="refreshButtonActionPerformed"/>
155152
</Events>
156153
</Component>
157-
<Component class="javax.swing.JButton" name="runDefaultButton">
158-
<Properties>
159-
<Property name="text" type="java.lang.String" value="Run"/>
160-
</Properties>
161-
<Events>
162-
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="runDefaultButtonButtonActionPerformed"/>
163-
</Events>
164-
</Component>
165154
<Component class="javax.swing.JButton" name="runCustomButton">
166155
<Properties>
167-
<Property name="text" type="java.lang.String" value="Custom"/>
156+
<Property name="text" type="java.lang.String" value="Run"/>
168157
</Properties>
169158
<Events>
170159
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="runCustomButtonButtonActionPerformed"/>

‎src/scrcpy_main_panel.java

+4-22
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ private void initComponents() {
5252
list_devices = new javax.swing.JList<>();
5353
selectButton = new javax.swing.JButton();
5454
refreshButton = new javax.swing.JButton();
55-
runDefaultButton = new javax.swing.JButton();
5655
runCustomButton = new javax.swing.JButton();
5756
tcpipButton = new javax.swing.JButton();
5857
jPanel3 = new javax.swing.JPanel();
@@ -95,14 +94,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
9594
}
9695
});
9796

98-
runDefaultButton.setText("Run");
99-
runDefaultButton.addActionListener(new java.awt.event.ActionListener() {
100-
public void actionPerformed(java.awt.event.ActionEvent evt) {
101-
runDefaultButtonButtonActionPerformed(evt);
102-
}
103-
});
104-
105-
runCustomButton.setText("Custom");
97+
runCustomButton.setText("Run");
10698
runCustomButton.addActionListener(new java.awt.event.ActionListener() {
10799
public void actionPerformed(java.awt.event.ActionEvent evt) {
108100
runCustomButtonButtonActionPerformed(evt);
@@ -126,7 +118,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
126118
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
127119
.addComponent(refreshButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
128120
.addComponent(selectButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
129-
.addComponent(runDefaultButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
130121
.addComponent(runCustomButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
131122
.addComponent(tcpipButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
132123
.addContainerGap(9, Short.MAX_VALUE))
@@ -139,14 +130,12 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
139130
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
140131
.addComponent(selectButton)
141132
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
142-
.addComponent(runDefaultButton)
143-
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
144133
.addComponent(runCustomButton)
145134
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
146135
.addComponent(tcpipButton)
147-
.addContainerGap(199, Short.MAX_VALUE))
136+
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
148137
.addGroup(jPanel2Layout.createSequentialGroup()
149-
.addComponent(jScrollPane1)
138+
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 338, Short.MAX_VALUE)
150139
.addContainerGap())
151140
);
152141

@@ -287,16 +276,10 @@ private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN
287276
updateDeviceList();
288277
}//GEN-LAST:event_refreshButtonActionPerformed
289278

290-
private void runDefaultButtonButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runDefaultButtonButtonActionPerformed
291-
// TODO add your handling code here:
292-
String selectedDevice = list_devices.getSelectedValue();
293-
Scrcpy_GUI.run_scrcpy(selectedDevice);
294-
}//GEN-LAST:event_runDefaultButtonButtonActionPerformed
295-
296279
private void runCustomButtonButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runCustomButtonButtonActionPerformed
297280
// TODO add your handling code here:
298281
String selectedDevice = list_devices.getSelectedValue();
299-
Scrcpy_GUI.custom_run_scrcpy(
282+
Scrcpy_GUI.run_scrcpy(
300283
selectedDevice, maxSize.getText(), videoBitRate.getText(),
301284
toggleVideoButton.isSelected(), toggleScreenButton.isSelected(),
302285
toggleStayAwake.isSelected()
@@ -372,7 +355,6 @@ public void run() {
372355
private javax.swing.JToggleButton recordVideoButton;
373356
private javax.swing.JButton refreshButton;
374357
private javax.swing.JButton runCustomButton;
375-
private javax.swing.JButton runDefaultButton;
376358
private javax.swing.JButton selectButton;
377359
private javax.swing.JButton tcpipButton;
378360
private javax.swing.JToggleButton toggleScreenButton;

0 commit comments

Comments
 (0)