Skip to content

Commit 5eaee7d

Browse files
committed
Fixed rendering for some components.
1 parent 35b31e0 commit 5eaee7d

File tree

11 files changed

+282
-253
lines changed

11 files changed

+282
-253
lines changed

.gitattributes

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
*.sln merge=union
7+
*.csproj merge=union
8+
*.vbproj merge=union
9+
*.fsproj merge=union
10+
*.dbproj merge=union
11+
12+
# Standard to msysgit
13+
*.doc diff=astextplain
14+
*.DOC diff=astextplain
15+
*.docx diff=astextplain
16+
*.DOCX diff=astextplain
17+
*.dot diff=astextplain
18+
*.DOT diff=astextplain
19+
*.pdf diff=astextplain
20+
*.PDF diff=astextplain
21+
*.rtf diff=astextplain
22+
*.RTF diff=astextplain

.gitignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/nbproject/
2-
3-
/build.xml
4-
/manifest.mf
1+
/nbproject/
2+
/build/
3+
4+
/build.xml
5+
/manifest.mf
File renamed without changes.

dist/lyrics.jar

19.9 KB
Binary file not shown.

lib/jsoup.jar

290 KB
Binary file not shown.

src/Extensions.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
2-
import org.jsoup.nodes.Node;
3-
4-
5-
/**
6-
*
7-
* @author DJohnny
8-
*/
9-
public class Extensions {
10-
// Jsoup extension
11-
public static void removeComments(Node node) {
12-
for (int i = 0; i < node.childNodes().size();) {
13-
Node child = node.childNode(i);
14-
if (child.nodeName().equals("#comment")) { child.remove(); }
15-
else { removeComments(child); i++; }
16-
}
17-
}
18-
}
1+
2+
import org.jsoup.nodes.Node;
3+
4+
5+
/**
6+
*
7+
* @author DJohnny
8+
*/
9+
public class Extensions {
10+
// Jsoup extension
11+
public static void removeComments(Node node) {
12+
for (int i = 0; i < node.childNodes().size();) {
13+
Node child = node.childNode(i);
14+
if (child.nodeName().equals("#comment")) { child.remove(); }
15+
else { removeComments(child); i++; }
16+
}
17+
}
18+
}

src/GUI.form

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
1515
<Color id="Default Cursor"/>
1616
</Property>
17-
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
18-
<Dimension value="[540, 600]"/>
19-
</Property>
2017
<Property name="resizable" type="boolean" value="false"/>
2118
</Properties>
2219
<SyntheticProperties>
@@ -236,6 +233,11 @@
236233
</SubComponents>
237234
</Container>
238235
<Container class="javax.swing.JPanel" name="lastfmPanel">
236+
<Properties>
237+
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
238+
<Dimension value="[530, 467]"/>
239+
</Property>
240+
</Properties>
239241
<Constraints>
240242
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
241243
<JTabbedPaneConstraints tabName="Last.fm">
@@ -248,43 +250,45 @@
248250
<DimensionLayout dim="0">
249251
<Group type="103" groupAlignment="0" attributes="0">
250252
<Group type="102" attributes="0">
251-
<Component id="usernameLabel" min="-2" max="-2" attributes="0"/>
252-
<EmptySpace type="unrelated" max="-2" attributes="0"/>
253-
<Component id="usernameField" max="32767" attributes="0"/>
254-
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
255-
</Group>
256-
<Group type="102" attributes="0">
257-
<Component id="apikeyLabel" min="-2" max="-2" attributes="0"/>
258-
<EmptySpace min="21" pref="21" max="-2" attributes="0"/>
259253
<Group type="103" groupAlignment="0" attributes="0">
260254
<Group type="102" attributes="0">
261-
<Component id="saveButton" min="-2" max="-2" attributes="0"/>
262-
<EmptySpace min="0" pref="416" max="32767" attributes="0"/>
255+
<Component id="apikeyLabel" min="-2" max="-2" attributes="0"/>
256+
<EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
257+
<Component id="apikeyField" pref="462" max="32767" attributes="0"/>
263258
</Group>
264259
<Group type="102" attributes="0">
265-
<Component id="apikeyField" max="32767" attributes="0"/>
266-
<EmptySpace max="-2" attributes="0"/>
260+
<EmptySpace min="62" pref="62" max="-2" attributes="0"/>
261+
<Component id="saveButton" min="-2" max="-2" attributes="0"/>
262+
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
263+
</Group>
264+
<Group type="102" alignment="0" attributes="0">
265+
<Component id="usernameLabel" min="-2" max="-2" attributes="0"/>
266+
<EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
267+
<Component id="usernameField" pref="462" max="32767" attributes="0"/>
267268
</Group>
268269
</Group>
270+
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
269271
</Group>
270272
</Group>
271273
</DimensionLayout>
272274
<DimensionLayout dim="1">
273275
<Group type="103" groupAlignment="0" attributes="0">
274-
<Group type="102" alignment="0" attributes="0">
275-
<EmptySpace max="-2" attributes="0"/>
276-
<Group type="103" groupAlignment="3" attributes="0">
277-
<Component id="usernameLabel" alignment="3" min="-2" max="-2" attributes="0"/>
278-
<Component id="usernameField" alignment="3" min="-2" max="-2" attributes="0"/>
276+
<Group type="102" attributes="0">
277+
<EmptySpace min="10" pref="10" max="-2" attributes="0"/>
278+
<Group type="103" groupAlignment="0" attributes="0">
279+
<Group type="102" attributes="0">
280+
<EmptySpace min="4" pref="4" max="-2" attributes="0"/>
281+
<Component id="usernameLabel" min="-2" max="-2" attributes="0"/>
282+
</Group>
283+
<Component id="usernameField" min="-2" max="-2" attributes="0"/>
279284
</Group>
280-
<EmptySpace max="-2" attributes="0"/>
281-
<Group type="103" groupAlignment="3" attributes="0">
282-
<Component id="apikeyLabel" alignment="3" min="-2" max="-2" attributes="0"/>
283-
<Component id="apikeyField" alignment="3" min="-2" max="-2" attributes="0"/>
285+
<EmptySpace min="10" pref="10" max="-2" attributes="0"/>
286+
<Group type="103" groupAlignment="0" attributes="0">
287+
<Component id="apikeyLabel" min="-2" max="-2" attributes="0"/>
288+
<Component id="apikeyField" min="-2" max="-2" attributes="0"/>
284289
</Group>
285-
<EmptySpace min="-2" pref="14" max="-2" attributes="0"/>
290+
<EmptySpace min="11" pref="11" max="-2" attributes="0"/>
286291
<Component id="saveButton" min="-2" max="-2" attributes="0"/>
287-
<EmptySpace pref="373" max="32767" attributes="0"/>
288292
</Group>
289293
</Group>
290294
</DimensionLayout>

src/GUI.java

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ private void initComponents() {
5252
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
5353
setTitle("Lyrics");
5454
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
55-
setPreferredSize(new java.awt.Dimension(540, 600));
5655
setResizable(false);
5756

5857
lyricPanel.setPreferredSize(new java.awt.Dimension(530, 400));
@@ -157,6 +156,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
157156

158157
lyricTab.addTab("Lyric", lyricPanel);
159158

159+
lastfmPanel.setPreferredSize(new java.awt.Dimension(530, 467));
160+
160161
usernameLabel.setText("Username:");
161162

162163
apikeyLabel.setText("API key:");
@@ -173,35 +174,36 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
173174
lastfmPanelLayout.setHorizontalGroup(
174175
lastfmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
175176
.addGroup(lastfmPanelLayout.createSequentialGroup()
176-
.addComponent(usernameLabel)
177-
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
178-
.addComponent(usernameField)
179-
.addGap(10, 10, 10))
180-
.addGroup(lastfmPanelLayout.createSequentialGroup()
181-
.addComponent(apikeyLabel)
182-
.addGap(21, 21, 21)
183177
.addGroup(lastfmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
184178
.addGroup(lastfmPanelLayout.createSequentialGroup()
179+
.addComponent(apikeyLabel)
180+
.addGap(22, 22, 22)
181+
.addComponent(apikeyField, javax.swing.GroupLayout.DEFAULT_SIZE, 462, Short.MAX_VALUE))
182+
.addGroup(lastfmPanelLayout.createSequentialGroup()
183+
.addGap(62, 62, 62)
185184
.addComponent(saveButton)
186-
.addGap(0, 416, Short.MAX_VALUE))
185+
.addGap(0, 0, Short.MAX_VALUE))
187186
.addGroup(lastfmPanelLayout.createSequentialGroup()
188-
.addComponent(apikeyField)
189-
.addContainerGap())))
187+
.addComponent(usernameLabel)
188+
.addGap(11, 11, 11)
189+
.addComponent(usernameField, javax.swing.GroupLayout.DEFAULT_SIZE, 462, Short.MAX_VALUE)))
190+
.addGap(10, 10, 10))
190191
);
191192
lastfmPanelLayout.setVerticalGroup(
192193
lastfmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
193194
.addGroup(lastfmPanelLayout.createSequentialGroup()
194-
.addContainerGap()
195-
.addGroup(lastfmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
196-
.addComponent(usernameLabel)
195+
.addGap(10, 10, 10)
196+
.addGroup(lastfmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
197+
.addGroup(lastfmPanelLayout.createSequentialGroup()
198+
.addGap(4, 4, 4)
199+
.addComponent(usernameLabel))
197200
.addComponent(usernameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
198-
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
199-
.addGroup(lastfmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
201+
.addGap(10, 10, 10)
202+
.addGroup(lastfmPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
200203
.addComponent(apikeyLabel)
201204
.addComponent(apikeyField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
202-
.addGap(14, 14, 14)
203-
.addComponent(saveButton)
204-
.addContainerGap(373, Short.MAX_VALUE))
205+
.addGap(11, 11, 11)
206+
.addComponent(saveButton))
205207
);
206208

207209
lyricTab.addTab("Last.fm", lastfmPanel);
@@ -241,7 +243,7 @@ private void getLyricsButtonActionPerformed(java.awt.event.ActionEvent evt) {//G
241243
}//GEN-LAST:event_getLyricsButtonActionPerformed
242244

243245
private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
244-
246+
if(lastfmCheckBox.isSelected()==true) { getLyricsButton.doClick(); }
245247
}//GEN-LAST:event_saveButtonActionPerformed
246248

247249
/**

src/Lastfm.java

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
1-
2-
import java.io.IOException;
3-
import java.net.URI;
4-
import java.net.URISyntaxException;
5-
import org.jsoup.Jsoup;
6-
import org.jsoup.nodes.Document;
7-
import org.jsoup.select.Elements;
8-
9-
/**
10-
*
11-
* @author DJohnny
12-
*/
13-
public class Lastfm {
14-
private String username,apikey;
15-
16-
public String getUsername() { return username; }
17-
public void setUsername(String username) { this.username = username; }
18-
public String getApikey() { return apikey; }
19-
public void setApikey(String apikey) { this.apikey = apikey; }
20-
21-
public Lastfm(String username, String apikey) {
22-
this.username = username;
23-
this.apikey = apikey;
24-
}
25-
26-
public String getArtist() {
27-
String url="";
28-
try {
29-
URI uri=new URI("http","ws.audioscrobbler.com","/2.0/","method=user.getrecenttracks&user="+username+"&api_key="+apikey+"&limit=1",null);
30-
url=uri.toASCIIString();
31-
} catch(URISyntaxException use) { System.err.println(use); }
32-
33-
String output="";
34-
try {
35-
Document doc=Jsoup.connect(url).get();
36-
Elements lyr=doc.select("artist");
37-
output=lyr.first().html().replace("&amp;","&");
38-
} catch(IOException ioe) { System.err.println(ioe); }
39-
40-
if(output.equals("")) { System.err.println("Bad artist."); }
41-
return output;
42-
}
43-
44-
public String getTrack() {
45-
String url="";
46-
try {
47-
URI uri=new URI("http","ws.audioscrobbler.com","/2.0/","method=user.getrecenttracks&user="+username+"&api_key="+apikey+"&limit=1",null);
48-
url=uri.toASCIIString();
49-
} catch(URISyntaxException use) { System.err.println(use); }
50-
51-
String output="";
52-
try {
53-
Document doc=Jsoup.connect(url).get();
54-
Elements lyr=doc.select("name");
55-
output=lyr.first().html();
56-
} catch(IOException ioe) { System.err.println(ioe); }
57-
58-
if(output.equals("")) { System.err.println("Bad track."); }
59-
return output;
60-
}
61-
62-
@Override
63-
public String toString() {
64-
return "Lastfm{" + "username=" + username + ", apikey=" + apikey + '}';
65-
}
66-
}
1+
2+
import java.io.IOException;
3+
import java.net.URI;
4+
import java.net.URISyntaxException;
5+
import org.jsoup.Jsoup;
6+
import org.jsoup.nodes.Document;
7+
import org.jsoup.select.Elements;
8+
9+
/**
10+
*
11+
* @author DJohnny
12+
*/
13+
public class Lastfm {
14+
private String username,apikey;
15+
16+
public String getUsername() { return username; }
17+
public void setUsername(String username) { this.username = username; }
18+
public String getApikey() { return apikey; }
19+
public void setApikey(String apikey) { this.apikey = apikey; }
20+
21+
public Lastfm(String username, String apikey) {
22+
this.username = username;
23+
this.apikey = apikey;
24+
}
25+
26+
public String getArtist() {
27+
String url="";
28+
try {
29+
URI uri=new URI("http","ws.audioscrobbler.com","/2.0/","method=user.getrecenttracks&user="+username+"&api_key="+apikey+"&limit=1",null);
30+
url=uri.toASCIIString();
31+
} catch(URISyntaxException use) { System.err.println(use); }
32+
33+
String output="";
34+
try {
35+
Document doc=Jsoup.connect(url).get();
36+
Elements lyr=doc.select("artist");
37+
output=lyr.first().html().replace("&amp;","&");
38+
} catch(IOException ioe) { System.err.println(ioe); }
39+
40+
if(output.equals("")) { System.err.println("Bad artist."); }
41+
return output;
42+
}
43+
44+
public String getTrack() {
45+
String url="";
46+
try {
47+
URI uri=new URI("http","ws.audioscrobbler.com","/2.0/","method=user.getrecenttracks&user="+username+"&api_key="+apikey+"&limit=1",null);
48+
url=uri.toASCIIString();
49+
} catch(URISyntaxException use) { System.err.println(use); }
50+
51+
String output="";
52+
try {
53+
Document doc=Jsoup.connect(url).get();
54+
Elements lyr=doc.select("name");
55+
output=lyr.first().html();
56+
} catch(IOException ioe) { System.err.println(ioe); }
57+
58+
if(output.equals("")) { System.err.println("Bad track."); }
59+
return output;
60+
}
61+
62+
@Override
63+
public String toString() {
64+
return "Lastfm{" + "username=" + username + ", apikey=" + apikey + '}';
65+
}
66+
}

0 commit comments

Comments
 (0)