private static JPanel makePane(String name, int choiceCount, Option... opts) { JPanel pane = new JPanel(); pane.setBorder(BorderFactory.createTitledBorder(name)); GroupLayout layout = new GroupLayout(pane); pane.setLayout(layout); Group g = layout.createSequentialGroup(); Group g1 = layout.createParallelGroup(); for (int i = 0; i < choiceCount; i++) { g1 = layout.createParallelGroup(); for (Option o : opts) g1.addComponent(o.cChoices[i]); g.addGroup(g1); } layout.setHorizontalGroup(g); g = layout.createSequentialGroup(); for (Option o : opts) { g1 = layout.createParallelGroup(Alignment.BASELINE); for (int i = 0; i < choiceCount; i++) g1.addComponent(o.cChoices[i]); g.addGroup(g1); } layout.setVerticalGroup(g); return pane; }
private JPanel makeSettings() { JPanel p = new JPanel(); GroupLayout layout = new GroupLayout(p); p.setLayout(layout); List<JPanel> panels = generateOptionPanels(); sDef = new SimpleCodeHolder(res.definitions); sGlobLoc = new SimpleCodeHolder(res.globalLocals); sInit = new SimpleCodeHolder(res.initialization); sClean = new SimpleCodeHolder(res.cleanup); bDef = new JButton( Messages.getString("EnigmaSettingsFrame.BUTTON_DEFINITIONS"), CODE_ICON); // $NON-NLS-1$ bGlobLoc = new JButton( Messages.getString("EnigmaSettingsFrame.BUTTON_GLOBAL_LOCALS"), CODE_ICON); //$NON-NLS-1$ bInit = new JButton( Messages.getString("EnigmaSettingsFrame.BUTTON_INITIALIZATION"), CODE_ICON); //$NON-NLS-1$ bClean = new JButton( Messages.getString("EnigmaSettingsFrame.BUTTON_CLEANUP"), CODE_ICON); // $NON-NLS-1$ bDef.addActionListener(this); bGlobLoc.addActionListener(this); bInit.addActionListener(this); bClean.addActionListener(this); Group gh = layout.createParallelGroup(); SequentialGroup gv = layout.createSequentialGroup(); if (panels != null) for (JPanel pp : panels) { gh.addComponent(pp); gv.addComponent(pp); } layout.setHorizontalGroup( gh /**/ .addGroup( layout .createSequentialGroup() /* */ .addComponent(bDef) /* */ .addComponent(bGlobLoc)) /**/ .addGroup( layout .createSequentialGroup() /* */ .addComponent(bInit) /* */ .addComponent(bClean))); layout.setVerticalGroup( gv /**/ .addGroup( layout.createParallelGroup() /* */.addComponent(bDef) /* */.addComponent(bGlobLoc)) /**/ .addGroup( layout.createParallelGroup() /* */.addComponent(bInit) /* */.addComponent(bClean)) /**/ .addContainerGap()); return p; }