-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathParameterNotesRow.java
More file actions
50 lines (38 loc) · 1.37 KB
/
ParameterNotesRow.java
File metadata and controls
50 lines (38 loc) · 1.37 KB
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
package nodebox.client;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.IOException;
public class ParameterNotesRow extends JComponent {
private JLabel notesLabel;
private static final int TOP_PADDING = 2;
private static final int BOTTOM_PADDING = 2;
private static Image notesBackgroundImage;
static {
try {
notesBackgroundImage = ImageIO.read(new File("res/notes-background.png"));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public ParameterNotesRow(String notes) {
setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
notesLabel = new JLabel(notes);
notesLabel.setFont(Theme.SMALL_FONT);
notesLabel.setForeground(Theme.TEXT_NORMAL_COLOR);
notesLabel.setBorder(BorderFactory.createEmptyBorder(TOP_PADDING, 0, BOTTOM_PADDING, 0));
add(Box.createHorizontalStrut(ParameterView.LABEL_WIDTH + 10));
add(this.notesLabel);
add(Box.createHorizontalGlue());
setBorder(Theme.PARAMETER_NOTES_BORDER);
}
@Override
protected void paintComponent(Graphics g) {
g.drawImage(notesBackgroundImage, ParameterView.LABEL_WIDTH, 0, getWidth(), 20, null);
}
@Override
public Dimension getPreferredSize() {
return new Dimension(400, 21);
}
}