Skip to content

Commit b835302

Browse files
committed
fix #1 IllegalComponentStateException: The frame is decorated
1 parent efb75c1 commit b835302

File tree

3 files changed

+2
-51
lines changed

3 files changed

+2
-51
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>net.java.dev.dcd</groupId>
66
<artifactId>dcd</artifactId>
7-
<version>2.0</version>
7+
<version>2.1</version>
88
<packaging>jar</packaging>
99
<name>Dead Code Detector</name>
1010
<url>https://github.com/evernat/dead-code-detector/wiki</url>

src/main/java/dcd/DcdHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ final class DcdHelper {
4444
/**
4545
* Nom et copyright de DCD.
4646
*/
47-
static final String APPLICATION_NAME = "Dead Code Detector, Copyright 2008-2017 by Emeric Vernat";
47+
static final String APPLICATION_NAME = "Dead Code Detector, Copyright 2008-2018 by Emeric Vernat";
4848
private static final char METHOD_SEPARATOR = ' ';
4949
private static final int VISIBILITY_PUBLIC_OR_PROTECTED = Modifier.PUBLIC | Modifier.PROTECTED;
5050

src/main/java/dcd/ui/DeadCodeDetectorUI.java

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,9 @@
2424
import java.awt.Graphics;
2525
import java.awt.Graphics2D;
2626
import java.awt.Paint;
27-
import java.awt.Window;
28-
import java.awt.event.ActionEvent;
29-
import java.awt.event.ActionListener;
3027
import java.awt.event.WindowAdapter;
3128
import java.awt.event.WindowEvent;
3229
import java.io.File;
33-
import java.lang.reflect.Method;
3430

3531
import javax.swing.JFrame;
3632
import javax.swing.JOptionPane;
@@ -49,10 +45,7 @@
4945
public class DeadCodeDetectorUI extends JPanel {
5046
private static final long serialVersionUID = 1L;
5147
private static final Color GRADIENT_COLOR = new Color(166, 202, 240);
52-
private static final int APPEAR_STEP = 25;
53-
private static final int APPEAR_DURATION = 750;
5448
final ParametersPanel parametersPanel;
55-
javax.swing.Timer appearTimer;
5649

5750
/**
5851
* Constructeur du panel.
@@ -122,55 +115,13 @@ public void windowClosing(WindowEvent e) {
122115
final Dimension dimension = frame.getToolkit().getScreenSize();
123116
frame.setLocation(dimension.width / 2 - frame.getWidth() / 2,
124117
dimension.height / 2 - frame.getHeight() / 2);
125-
ui.disappear();
126118
frame.setVisible(true);
127-
ui.appear();
128119
} catch (final Exception e) {
129120
DcdUiHelper.printStackTrace(e);
130121
JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
131122
}
132123
}
133124

134-
private void appear() {
135-
final JFrame frame = (JFrame) SwingUtilities.windowForComponent(this);
136-
final long startTime = System.currentTimeMillis();
137-
appearTimer = new javax.swing.Timer(APPEAR_STEP, new ActionListener() {
138-
/** {@inheritDoc} */
139-
@Override
140-
public void actionPerformed(ActionEvent e) {
141-
// calculate elapsed time
142-
final long elapsed = System.currentTimeMillis() - startTime;
143-
final float alpha = Math.min(1f, 1.0f * elapsed / APPEAR_DURATION);
144-
setWindowOpacity(frame, alpha);
145-
if (elapsed >= APPEAR_DURATION) { // should we stop timer?
146-
appearTimer.stop();
147-
}
148-
}
149-
});
150-
151-
appearTimer.start();
152-
}
153-
154-
private void disappear() {
155-
final JFrame frame = (JFrame) SwingUtilities.windowForComponent(this);
156-
setWindowOpacity(frame, 0f);
157-
}
158-
159-
static void setWindowOpacity(JFrame frame, float alpha) {
160-
// cette méthode fonctionne à partir de Java 1.6.0_10 (update 10)
161-
try {
162-
//invoke AWTUtilities.setWindowOpacity(win, alpha);
163-
final Class<?> awtutil = Class.forName("com.sun.awt.AWTUtilities");
164-
final Method setWindowOpaque = awtutil.getMethod("setWindowOpacity", Window.class,
165-
float.class);
166-
setWindowOpaque.invoke(null, frame, alpha);
167-
} catch (final Throwable ex) { // NOPMD
168-
// pour MAC OS X
169-
frame.getRootPane().putClientProperty("Window.alpha", Float.valueOf(alpha));
170-
// sinon pas v1.6.0_u10 ou + : tant pis
171-
}
172-
}
173-
174125
/** {@inheritDoc} */
175126
@Override
176127
protected void paintComponent(Graphics graphics) {

0 commit comments

Comments
 (0)