Skip to content

Commit

Permalink
Tab Issue Fixed
Browse files Browse the repository at this point in the history
Fixed the issue of the tabs moving around
  • Loading branch information
GwinProGrammer committed Jul 19, 2022
1 parent 7c46b07 commit cf1f80a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import javax.swing.plaf.basic.BasicLookAndFeel;
import java.awt.*;



public class LegupLookAndFeel extends BasicLookAndFeel {
/**
* Return a short string that identifies this look and feel, e.g.
Expand Down Expand Up @@ -153,8 +155,13 @@ protected void initClassDefaults(UIDefaults table) {
table.put ("ToolTipUI", MaterialToolTipUI.class.getCanonicalName());
table.put ("SplitPaneUI", MaterialSplitPaneUI.class.getCanonicalName());
// table.put ("ColorChooserUI", );


}




@Override
protected void initComponentDefaults (UIDefaults table) {
super.initComponentDefaults(table);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ContradictionRulePanel extends RulePanel {
ContradictionRulePanel(RuleFrame ruleFrame) {
super(ruleFrame);
this.icon = new ImageIcon(ClassLoader.getSystemClassLoader().getResource("edu/rpi/legup/images/Legup/Contradictions.gif"));
this.name = "Contradiction Rules";
this.name = "C";
this.toolTip = "Contradiction Rules";
}
}
16 changes: 16 additions & 0 deletions src/main/java/edu/rpi/legup/ui/rulesview/RuleFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import edu.rpi.legup.model.Puzzle;
import edu.rpi.legup.model.gameboard.Board;
import edu.rpi.legup.model.rules.Rule;
import edu.rpi.legup.ui.lookandfeel.components.MaterialTabbedPaneUI;

import java.awt.BorderLayout;
import java.awt.Dimension;
Expand Down Expand Up @@ -34,12 +35,24 @@ public class RuleFrame extends JPanel {
private RuleController controller;

public RuleFrame(RuleController controller) {

MaterialTabbedPaneUI tabOverride = new MaterialTabbedPaneUI(){
@Override protected boolean shouldRotateTabRuns(int i){
return false;
}
};

this.controller = controller;

this.tabbedPane = new JTabbedPane();
this.tabbedPane.setUI(tabOverride);
this.status = new JLabel();
this.buttonGroup = new ButtonGroup();



this.tabbedPane.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT);

basicRulePanel = new BasicRulePanel(this);

tabbedPane.addTab(basicRulePanel.getName(), basicRulePanel.getIcon(), new JScrollPane(basicRulePanel), basicRulePanel.getToolTip());
Expand All @@ -50,6 +63,9 @@ public RuleFrame(RuleController controller) {
contradictionPanel = new ContradictionRulePanel(this);
tabbedPane.addTab(contradictionPanel.name, contradictionPanel.icon, new JScrollPane(contradictionPanel), contradictionPanel.toolTip);

contradictionPanel = new ContradictionRulePanel(this);
tabbedPane.addTab(contradictionPanel.name, contradictionPanel.icon, new JScrollPane(contradictionPanel), contradictionPanel.toolTip);

setLayout(new BorderLayout());
setMinimumSize(new Dimension(250, 256));
setPreferredSize(new Dimension(330, 256));
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/edu/rpi/legup/ui/rulesview/RulePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ public RulePanel(RuleFrame ruleFrame) {
setLayout(new WrapLayout());
}


/**
* Gets the rule rule buttons
*
* @return rule ruleButtons
*/

public RuleButton[] getRuleButtons() {
return ruleButtons;
}
Expand Down

0 comments on commit cf1f80a

Please sign in to comment.