Skip to content

Commit

Permalink
Show legend for color codes in input components.
Browse files Browse the repository at this point in the history
  • Loading branch information
breaker27 committed Jun 29, 2014
1 parent 9dd5535 commit 5b53812
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
25 changes: 24 additions & 1 deletion tools/shc_e2p_editor/src/main/java/shcee/ValueEditorPanel.java
Expand Up @@ -19,6 +19,7 @@
package shcee;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Rectangle;
Expand All @@ -28,6 +29,8 @@
import java.io.IOException;
import java.util.ArrayList;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
Expand Down Expand Up @@ -81,6 +84,20 @@ public ValueEditorPanel()

JPanel headingPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 6, 6));
headingPanel.add(headingLabel);

// Description
JPanel colorCodesPanel = new JPanel();
colorCodesPanel.setLayout(new BoxLayout(colorCodesPanel, javax.swing.BoxLayout.X_AXIS));

colorCodesPanel.add(new JLabel("Color codes:"));
colorCodesPanel.add(Box.createRigidArea(new Dimension(6, 6)));
colorCodesPanel.add(createColorCodeLabel(" invalid ", Color.RED));
colorCodesPanel.add(Box.createRigidArea(new Dimension(6, 6)));
colorCodesPanel.add(createColorCodeLabel(" default ", Color.WHITE));
colorCodesPanel.add(Box.createRigidArea(new Dimension(6, 6)));
colorCodesPanel.add(createColorCodeLabel(" differs from default ", Color.YELLOW));

headingPanel.add(colorCodesPanel);

// create buttons
JButton buttonSave = new JButton("Save");
Expand Down Expand Up @@ -134,7 +151,13 @@ public void actionPerformed(ActionEvent e)
initAccordingEepromLayout();
}


private JLabel createColorCodeLabel(String text, Color color)
{
JLabel label = new JLabel(text);
label.setOpaque(true);
label.setBackground(color);
return label;
}

protected void onButtonAbout()
{
Expand Down
Expand Up @@ -61,7 +61,6 @@ public BoolEditor(Node root, Color baseColor, int arrayIndex)

// add input
JPanel inputPanel = new JPanel();
//inputPanel.setLayout(new BoxLayout(inputPanel, javax.swing.BoxLayout.X_AXIS));
inputPanel.setLayout(new BorderLayout());
inputPanel.setBackground(this.getBackground());

Expand Down

0 comments on commit 5b53812

Please sign in to comment.