List of usage examples for javax.swing BoxLayout Y_AXIS
int Y_AXIS
To view the source code for javax.swing BoxLayout Y_AXIS.
Click Source Link
From source file:AppearanceExplorer.java
TextureAttributesEditor(TextureAttributes init) { super(BoxLayout.Y_AXIS); textureAttr = init;/*from ww w. j av a 2 s .co m*/ mode = textureAttr.getTextureMode(); pcMode = textureAttr.getPerspectiveCorrectionMode(); textureAttr.getTextureBlendColor(blendColor); String[] modeNames = { "REPLACE", "MODULATE", "DECAL", "BLEND", }; int[] modeValues = { TextureAttributes.REPLACE, TextureAttributes.MODULATE, TextureAttributes.DECAL, TextureAttributes.BLEND, }; IntChooser modeChooser = new IntChooser("Mode:", modeNames, modeValues, mode); modeChooser.addIntListener(new IntListener() { public void intChanged(IntEvent event) { mode = event.getValue(); textureAttr.setTextureMode(mode); } }); add(modeChooser); Color4fEditor blendColorEditor = new Color4fEditor("Blend Color", blendColor); blendColorEditor.addColor4fListener(new Color4fListener() { public void colorChanged(Color4fEvent event) { event.getValue(blendColor); textureAttr.setTextureBlendColor(blendColor); } }); add(blendColorEditor); String[] pcModeNames = { "NICEST", "FASTEST", }; int[] pcModeValues = { TextureAttributes.NICEST, TextureAttributes.FASTEST, }; IntChooser pcModeChooser = new IntChooser("Perspective Correction:", pcModeNames, pcModeValues, pcMode); pcModeChooser.addIntListener(new IntListener() { public void intChanged(IntEvent event) { pcMode = event.getValue(); textureAttr.setPerspectiveCorrectionMode(pcMode); } }); add(pcModeChooser); }
From source file:AppearanceExplorer.java
TexCoordGenerationEditor(Appearance initApp, boolean initEnable, int initMode, Vector4f initPlaneS, Vector4f initPlaneT) {// www.ja va 2s.co m super(BoxLayout.Y_AXIS); app = initApp; enable = initEnable; mode = initMode; planeS.set(initPlaneS); planeT.set(initPlaneT); setTexGen(); // set up the initial texGen JCheckBox enableCheckBox = new JCheckBox("Enable Tex Coord Gen"); enableCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { enable = ((JCheckBox) e.getSource()).isSelected(); texGen.setEnable(enable); } }); add(new LeftAlignComponent(enableCheckBox)); // texture boundaries String[] modeNames = { "OBJECT_LINEAR", "EYE_LINEAR", "SPHERE_MAP", }; int[] modeValues = { TexCoordGeneration.OBJECT_LINEAR, TexCoordGeneration.EYE_LINEAR, TexCoordGeneration.SPHERE_MAP, }; // tex gen modes IntChooser modeChooser = new IntChooser("Generation Mode:", modeNames, modeValues); modeChooser.setValue(mode); modeChooser.addIntListener(new IntListener() { public void intChanged(IntEvent event) { int value = event.getValue(); mode = value; setTexGen(); } }); add(modeChooser); // make a panel for both sets of sliders and then two sub-panels, // one for each group of sliders Box sliderPanel = new Box(BoxLayout.Y_AXIS); add(sliderPanel); Box planeSPanel = new Box(BoxLayout.Y_AXIS); Box planeTPanel = new Box(BoxLayout.Y_AXIS); sliderPanel.add(planeSPanel); sliderPanel.add(planeTPanel); planeSPanel.add(new LeftAlignComponent(new JLabel("Plane S:"))); FloatLabelJSlider planeSxSlider = new FloatLabelJSlider("X:", 0.1f, -10.0f, 10.0f, planeS.x); planeSxSlider.setMajorTickSpacing(0.1f); planeSxSlider.setPaintTicks(true); planeSxSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { planeS.x = e.getValue(); setTexGen(); } }); planeSPanel.add(planeSxSlider); FloatLabelJSlider planeSySlider = new FloatLabelJSlider("Y:", 0.1f, -10.0f, 10.0f, planeS.y); planeSySlider.setMajorTickSpacing(0.1f); planeSySlider.setPaintTicks(true); planeSySlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { planeS.y = e.getValue(); setTexGen(); } }); planeSPanel.add(planeSySlider); FloatLabelJSlider planeSzSlider = new FloatLabelJSlider("Z:", 0.1f, -10.0f, 10.0f, planeS.z); planeSzSlider.setMajorTickSpacing(0.1f); planeSzSlider.setPaintTicks(true); planeSzSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { planeS.z = e.getValue(); setTexGen(); } }); planeSPanel.add(planeSzSlider); FloatLabelJSlider planeSwSlider = new FloatLabelJSlider("W:", 0.1f, -10.0f, 10.0f, planeS.w); planeSwSlider.setMajorTickSpacing(0.1f); planeSwSlider.setPaintTicks(true); planeSwSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { planeS.w = e.getValue(); setTexGen(); } }); planeSPanel.add(planeSwSlider); planeSPanel.add(new LeftAlignComponent(new JLabel("Plane T:"))); FloatLabelJSlider planeTxSlider = new FloatLabelJSlider("X:", 0.1f, -10.0f, 10.0f, planeT.x); planeTxSlider.setMajorTickSpacing(0.1f); planeTxSlider.setPaintTicks(true); planeTxSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { planeT.x = e.getValue(); setTexGen(); } }); planeTPanel.add(planeTxSlider); FloatLabelJSlider planeTySlider = new FloatLabelJSlider("Y:", 0.1f, -10.0f, 10.0f, planeT.y); planeTySlider.setMajorTickSpacing(0.1f); planeTySlider.setPaintTicks(true); planeTySlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { planeT.y = e.getValue(); setTexGen(); } }); planeTPanel.add(planeTySlider); FloatLabelJSlider planeTzSlider = new FloatLabelJSlider("Z:", 0.1f, -10.0f, 10.0f, planeT.z); planeTzSlider.setMajorTickSpacing(0.1f); planeTzSlider.setPaintTicks(true); planeTzSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { planeT.z = e.getValue(); setTexGen(); } }); planeTPanel.add(planeTzSlider); FloatLabelJSlider planeTwSlider = new FloatLabelJSlider("W:", 0.1f, -10.0f, 10.0f, planeT.w); planeTwSlider.setMajorTickSpacing(0.1f); planeTwSlider.setPaintTicks(true); planeTwSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { planeT.w = e.getValue(); setTexGen(); } }); planeTPanel.add(planeTwSlider); }
From source file:lcmc.gui.resources.ServiceInfo.java
/** Returns info panel with comboboxes for service parameters. */ @Override// w w w.j a v a 2 s. co m public JComponent getInfoPanel() { if (!getResourceAgent().isMetaDataLoaded()) { final JPanel p = new JPanel(); p.add(new JLabel(Tools.getString("ServiceInfo.LoadingMetaData"))); return p; } final CloneInfo ci = getCloneInfo(); if (ci == null) { getBrowser().getCRMGraph().pickInfo(this); } else { getBrowser().getCRMGraph().pickInfo(ci); } if (infoPanel != null) { return infoPanel; } /* init save button */ final boolean abExisted = getApplyButton() != null; final ServiceInfo thisClass = this; final ButtonCallback buttonCallback = new ButtonCallback() { private volatile boolean mouseStillOver = false; /** * Whether the whole thing should be enabled. */ @Override public final boolean isEnabled() { final Host dcHost = getBrowser().getDCHost(); if (dcHost == null) { return false; } if (Tools.versionBeforePacemaker(dcHost)) { return false; } return true; } @Override public final void mouseOut() { if (!isEnabled()) { return; } mouseStillOver = false; getBrowser().getCRMGraph().stopTestAnimation(getApplyButton()); getApplyButton().setToolTipText(null); } @Override public final void mouseOver() { if (!isEnabled()) { return; } mouseStillOver = true; getApplyButton().setToolTipText(ClusterBrowser.STARTING_PTEST_TOOLTIP); getApplyButton() .setToolTipBackground(Tools.getDefaultColor("ClusterBrowser.Test.Tooltip.Background")); Tools.sleep(250); if (!mouseStillOver) { return; } mouseStillOver = false; final CountDownLatch startTestLatch = new CountDownLatch(1); getBrowser().getCRMGraph().startTestAnimation(getApplyButton(), startTestLatch); final Host dcHost = getBrowser().getDCHost(); getBrowser().ptestLockAcquire(); final ClusterStatus cs = getBrowser().getClusterStatus(); cs.setPtestData(null); apply(dcHost, true); final PtestData ptestData = new PtestData(CRM.getPtest(dcHost)); getApplyButton().setToolTipText(ptestData.getToolTip()); cs.setPtestData(ptestData); getBrowser().ptestLockRelease(); startTestLatch.countDown(); } }; if (getResourceAgent().isGroup()) { initApplyButton(buttonCallback, Tools.getString("Browser.ApplyGroup")); } else { initApplyButton(buttonCallback); } if (ci != null) { ci.setApplyButton(getApplyButton()); ci.setRevertButton(getRevertButton()); } /* add item listeners to the apply button. */ if (!abExisted) { getApplyButton().addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { final Thread thread = new Thread(new Runnable() { @Override public void run() { getBrowser().clStatusLock(); apply(getBrowser().getDCHost(), false); getBrowser().clStatusUnlock(); } }); thread.start(); } }); getRevertButton().addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { final Thread thread = new Thread(new Runnable() { @Override public void run() { getBrowser().clStatusLock(); revert(); getBrowser().clStatusUnlock(); } }); thread.start(); } }); } /* main, button and options panels */ final JPanel mainPanel = new JPanel(); mainPanel.setBackground(ClusterBrowser.PANEL_BACKGROUND); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); final JPanel buttonPanel = new JPanel(new BorderLayout()); buttonPanel.setBackground(ClusterBrowser.BUTTON_PANEL_BACKGROUND); buttonPanel.setMinimumSize(new Dimension(0, 50)); buttonPanel.setPreferredSize(new Dimension(0, 50)); buttonPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, 50)); final JPanel optionsPanel = new JPanel(); optionsPanel.setBackground(ClusterBrowser.PANEL_BACKGROUND); optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS)); optionsPanel.setAlignmentX(Component.LEFT_ALIGNMENT); /* Actions */ final JMenuBar mb = new JMenuBar(); mb.setBackground(ClusterBrowser.PANEL_BACKGROUND); AbstractButton serviceMenu; if (ci == null) { serviceMenu = getActionsButton(); } else { serviceMenu = ci.getActionsButton(); } buttonPanel.add(serviceMenu, BorderLayout.EAST); String defaultValue = PRIMITIVE_TYPE_STRING; if (ci != null) { if (ci.getService().isMaster()) { defaultValue = MASTER_SLAVE_TYPE_STRING; } else { defaultValue = CLONE_TYPE_STRING; } } if (!getResourceAgent().isClone() && getGroupInfo() == null) { typeRadioGroup = new Widget(defaultValue, new String[] { PRIMITIVE_TYPE_STRING, CLONE_TYPE_STRING, MASTER_SLAVE_TYPE_STRING }, null, /* units */ Widget.Type.RADIOGROUP, null, /* regexp */ ClusterBrowser.SERVICE_LABEL_WIDTH + ClusterBrowser.SERVICE_FIELD_WIDTH, null, /* abbrv */ new AccessMode(ConfigData.AccessType.ADMIN, false)); if (!getService().isNew()) { typeRadioGroup.setEnabled(false); } typeRadioGroup.addListeners(new WidgetListener() { @Override public void check(final Object value) { changeType(((JRadioButton) value).getText()); } }); final JPanel tp = new JPanel(); tp.setBackground(ClusterBrowser.PANEL_BACKGROUND); tp.setLayout(new BoxLayout(tp, BoxLayout.Y_AXIS)); tp.add(typeRadioGroup); typeRadioGroup.setBackgroundColor(ClusterBrowser.PANEL_BACKGROUND); optionsPanel.add(tp); } if (ci != null) { /* add clone fields */ addCloneFields(optionsPanel, ClusterBrowser.SERVICE_LABEL_WIDTH, ClusterBrowser.SERVICE_FIELD_WIDTH); } getResource().setValue(GUI_ID, getService().getId()); /* get dependent resources and create combo boxes for ones, that * need parameters */ final String[] params = getParametersFromXML(); final Info savedMAIdRef = savedMetaAttrInfoRef; addParams(optionsPanel, params, ClusterBrowser.SERVICE_LABEL_WIDTH, ClusterBrowser.SERVICE_FIELD_WIDTH, getSameAsFields(savedMAIdRef)); if (ci == null) { /* score combo boxes */ addHostLocations(optionsPanel, ClusterBrowser.SERVICE_LABEL_WIDTH, ClusterBrowser.SERVICE_FIELD_WIDTH); } for (final String param : params) { if (isMetaAttr(param)) { final Widget wi = getWidget(param, null); wi.setEnabled(savedMAIdRef == null); } } if (!getService().isNew()) { getWidget(GUI_ID, null).setEnabled(false); } if (!getResourceAgent().isGroup() && !getResourceAgent().isClone()) { /* Operations */ addOperations(optionsPanel, ClusterBrowser.SERVICE_LABEL_WIDTH, ClusterBrowser.SERVICE_FIELD_WIDTH); /* add item listeners to the operations combos */ for (final String op : getResourceAgent().getOperationNames()) { for (final String param : getBrowser().getCRMOperationParams(op)) { addOperationListeners(op, param); } } } /* add item listeners to the host scores combos */ if (ci == null) { addHostLocationsListeners(); } else { ci.addHostLocationsListeners(); } /* apply button */ addApplyButton(buttonPanel); addRevertButton(buttonPanel); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { /* invoke later on purpose */ setApplyButtons(null, params); } }); mainPanel.add(optionsPanel); final JPanel newPanel = new JPanel(); newPanel.setBackground(ClusterBrowser.PANEL_BACKGROUND); newPanel.setLayout(new BoxLayout(newPanel, BoxLayout.Y_AXIS)); newPanel.add(buttonPanel); newPanel.add( getMoreOptionsPanel(ClusterBrowser.SERVICE_LABEL_WIDTH + ClusterBrowser.SERVICE_FIELD_WIDTH + 4)); newPanel.add(new JScrollPane(mainPanel)); /* if id textfield was changed and this id is not used, * enable apply button */ infoPanel = newPanel; infoPanelDone(); return infoPanel; }
From source file:AppearanceExplorer.java
public Color4fEditor(String initName, Color4f initColor) { super(BoxLayout.Y_AXIS); name = initName;/* ww w. j av a 2s . com*/ color.set(initColor); color3f.x = color.x; color3f.y = color.y; color3f.z = color.z; JPanel colorPanel = new JPanel(); colorPanel.setLayout(new BorderLayout()); add(colorPanel); JLabel label = new JLabel(name); preview = new JPanel(); preview.setPreferredSize(new Dimension(40, 40)); preview.setBackground(color3f.get()); preview.setBorder(BorderFactory.createRaisedBevelBorder()); button = new JButton("Set"); button.addActionListener(this); JPanel filler = new JPanel(); filler.setPreferredSize(new Dimension(100, 20)); Box box = new Box(BoxLayout.X_AXIS); colorPanel.add(box, BorderLayout.WEST); box.add(label); box.add(preview); box.add(button); box.add(filler); FloatLabelJSlider alphaSlider = new FloatLabelJSlider(" Alpha"); alphaSlider.setValue(color.w); alphaSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent event) { color.w = event.getValue(); valueChanged(); } }); add(alphaSlider); }
From source file:com.projity.pm.graphic.frames.GraphicManager.java
public void setToolBarAndMenus(final Container contentPane) { JToolBar toolBar;//ww w . j a va 2 s. c o m if (Environment.isRibbonUI()) { if (Environment.isNeedToRestart()) { contentPane.add(new JLabel(Messages.getString("Error.restart")), BorderLayout.CENTER); return; } setRibbon((JRibbonFrame) container, getMenuManager()); // JToolBar viewToolBar = getMenuManager().getToolBar(MenuManager.VIEW_TOOL_BAR_WITH_NO_SUB_VIEW_OPTION); // topTabs = new TabbedNavigation(); // JComponent tabs = topTabs.createContentPanel(getMenuManager(),viewToolBar,0,JTabbedPane.TOP,true); // tabs.setAlignmentX(0.0f); // so it is left justified // // // Box top = new Box(BoxLayout.Y_AXIS); // JComponent bottom; // top.add(tabs); // bottom = new TabbedNavigation().createContentPanel(getMenuManager(),viewToolBar,1,JTabbedPane.BOTTOM,false); // contentPane.add(top, BorderLayout.BEFORE_FIRST_LINE); // contentPane.add(bottom,BorderLayout.AFTER_LAST_LINE); // if (Environment.isNewLaf()) // contentPane.setBackground(Color.WHITE); // if (Environment.isMac()){ // //System.setProperty("apple.laf.useScreenMenuBar","true"); // //System.setProperty("com.apple.mrj.application.apple.menu.about.name", Messages.getMetaString("Text.ShortTitle")); // JMenuBar menu = getMenuManager().getMenu(Environment.getStandAlone()?MenuManager.MAC_STANDARD_MENU:MenuManager.SERVER_STANDARD_MENU); // //((JComponent)menu).setBorder(BorderFactory.createEmptyBorder()); // // ((JFrame)container).setJMenuBar(menu); // projectListMenu = (JMenu) menu.getComponent(5); // } } else if (Environment.isNewLook()) { if (Environment.isNeedToRestart()) { contentPane.add(new JLabel(Messages.getString("Error.restart")), BorderLayout.CENTER); return; } toolBar = getMenuManager().getToolBar(MenuManager.BIG_TOOL_BAR); if (!getLafManager().isToolbarOpaque()) toolBar.setOpaque(false); if (!isApplet()) getMenuManager().setActionVisible(ACTION_FULL_SCREEN, false); if (Environment.isExternal()) // external users only see project team getMenuManager().setActionVisible(ACTION_TEAM_FILTER, false); toolBar.addSeparator(new Dimension(20, 20)); toolBar.add(new Box.Filler(new Dimension(0, 0), new Dimension(0, 0), new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE))); toolBar.add(((DefaultFrameManager) getFrameManager()).getProjectComboPanel()); toolBar.add(Box.createRigidArea(new Dimension(20, 20))); if (Environment.isNewLaf()) toolBar.setBackground(Color.WHITE); toolBar.setFloatable(false); toolBar.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); Box top; JComponent bottom; top = new Box(BoxLayout.Y_AXIS); toolBar.setAlignmentX(0.0f); // so it is left justified top.add(toolBar); JToolBar viewToolBar = getMenuManager().getToolBar(MenuManager.VIEW_TOOL_BAR_WITH_NO_SUB_VIEW_OPTION); topTabs = new TabbedNavigation(); JComponent tabs = topTabs.createContentPanel(getMenuManager(), viewToolBar, 0, JTabbedPane.TOP, true); tabs.setAlignmentX(0.0f); // so it is left justified top.add(tabs); bottom = new TabbedNavigation().createContentPanel(getMenuManager(), viewToolBar, 1, JTabbedPane.BOTTOM, false); contentPane.add(top, BorderLayout.BEFORE_FIRST_LINE); contentPane.add(bottom, BorderLayout.AFTER_LAST_LINE); if (Environment.isNewLaf()) contentPane.setBackground(Color.WHITE); if (Environment.isMac()) { //System.setProperty("apple.laf.useScreenMenuBar","true"); //System.setProperty("com.apple.mrj.application.apple.menu.about.name", Messages.getMetaString("Text.ShortTitle")); JMenuBar menu = getMenuManager().getMenu(Environment.getStandAlone() ? MenuManager.MAC_STANDARD_MENU : MenuManager.SERVER_STANDARD_MENU); //((JComponent)menu).setBorder(BorderFactory.createEmptyBorder()); ((JFrame) container).setJMenuBar(menu); projectListMenu = (JMenu) menu.getComponent(5); } } else { toolBar = getMenuManager().getToolBar( Environment.isMac() ? MenuManager.MAC_STANDARD_TOOL_BAR : MenuManager.STANDARD_TOOL_BAR); filterToolBarManager = FilterToolBarManager.create(getMenuManager()); filterToolBarManager.addButtons(toolBar); contentPane.add(toolBar, BorderLayout.BEFORE_FIRST_LINE); JToolBar viewToolBar = getMenuManager().getToolBar(MenuManager.VIEW_TOOL_BAR); viewToolBar.setOrientation(JToolBar.VERTICAL); viewToolBar.setRollover(true); contentPane.add(viewToolBar, BorderLayout.WEST); JMenuBar menu = getMenuManager().getMenu(Environment.getStandAlone() ? (Environment.isMac() ? MenuManager.MAC_STANDARD_MENU : MenuManager.STANDARD_MENU) : MenuManager.SERVER_STANDARD_MENU); if (!Environment.isMac()) { ((JComponent) menu).setBorder(BorderFactory.createEmptyBorder()); JMenuItem logo = (JMenuItem) menu.getComponent(0); logo.setBorder(BorderFactory.createEmptyBorder()); logo.setMaximumSize(new Dimension(124, 52)); logo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } ((JFrame) container).setJMenuBar(menu); projectListMenu = (JMenu) menu.getComponent(Environment.isMac() ? 5 : 6); } //accelerators addCtrlAccel(KeyEvent.VK_G, ACTION_GOTO, null); addCtrlAccel(KeyEvent.VK_L, ACTION_GOTO, null); addCtrlAccel(KeyEvent.VK_F, ACTION_FIND, null); addCtrlAccel(KeyEvent.VK_Z, ACTION_UNDO, null); //- Sanhita addCtrlAccel(KeyEvent.VK_Y, ACTION_REDO, null); addCtrlAccel(KeyEvent.VK_N, ACTION_NEW_PROJECT, null); addCtrlAccel(KeyEvent.VK_O, ACTION_OPEN_PROJECT, null); addCtrlAccel(KeyEvent.VK_S, ACTION_SAVE_PROJECT, null); addCtrlAccel(KeyEvent.VK_P, ACTION_PRINT, null); //-Sanhita addCtrlAccel(KeyEvent.VK_I, ACTION_INSERT_TASK, null); addCtrlAccel(KeyEvent.VK_PERIOD, ACTION_INDENT, null); addCtrlAccel(KeyEvent.VK_COMMA, ACTION_OUTDENT, null); addCtrlAccel(KeyEvent.VK_PLUS, ACTION_EXPAND, new ExpandAction()); addCtrlAccel(KeyEvent.VK_ADD, ACTION_EXPAND, new ExpandAction()); addCtrlAccel(KeyEvent.VK_EQUALS, ACTION_EXPAND, new ExpandAction()); addCtrlAccel(KeyEvent.VK_MINUS, ACTION_COLLAPSE, new CollapseAction()); addCtrlAccel(KeyEvent.VK_SUBTRACT, ACTION_COLLAPSE, new CollapseAction()); // To force a recalculation. This normally shouldn't be needed. addCtrlAccel(KeyEvent.VK_R, ACTION_RECALCULATE, new RecalculateAction()); }
From source file:Tcpbw100.java
public void showOptions() { showStatus(messages.getString("showOptions")); if (optionsFrame == null) { optionsFrame = new clsFrame(); optionsFrame.setTitle(messages.getString("options")); JPanel optionsPanel = new JPanel(); optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS)); JPanel testsPanel = new JPanel(); testsPanel.setBorder(BorderFactory.createTitledBorder(messages.getString("performedTests"))); testsPanel.add(defaultTest);//from w w w . ja v a 2s . c o m optionsPanel.add(testsPanel); JPanel protocolPanel = new JPanel(); protocolPanel.setBorder(BorderFactory.createTitledBorder(messages.getString("ipProtocol"))); protocolPanel.add(preferIPv6); optionsPanel.add(protocolPanel); if (getParameter("enableMultipleTests") != null) { JPanel generalPanel = new JPanel(); generalPanel.setLayout(new BoxLayout(generalPanel, BoxLayout.Y_AXIS)); generalPanel.setBorder(BorderFactory.createTitledBorder(messages.getString("general"))); JPanel tmpPanel = new JPanel(); tmpPanel.add(new JLabel(messages.getString("numberOfTests") + ":")); tmpPanel.add(numOfTests); generalPanel.add(tmpPanel); tmpPanel = new JPanel(); tmpPanel.add(new JLabel(messages.getString("delayBetweenTests") + ":")); tmpPanel.add(delay); generalPanel.add(tmpPanel); optionsPanel.add(generalPanel); } optionsFrame.getContentPane().add(optionsPanel); Panel buttons = new Panel(); optionsFrame.getContentPane().add("South", buttons); JButton okButton = new JButton(messages.getString("ok")); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { optionsFrame.toBack(); optionsFrame.dispose(); } }); buttons.add("West", okButton); optionsFrame.pack(); } optionsFrame.setResizable(false); optionsFrame.setVisible(true); }
From source file:com.xilinx.ultrascale.gui.MainScreen.java
public JPanel createPanelForGraph(JPanel panel) { // dimensions Dimension dmsns = new Dimension(panel.getWidth(), panel.getHeight()); JPanel dmaStatsPanel = new JPanel(); dmaStatsPanel.setLayout(new BoxLayout(dmaStatsPanel, BoxLayout.Y_AXIS)); dmaStatsPanel.setSize(dmsns);//from w ww.j a v a 2 s.c o m return dmaStatsPanel; }
From source file:src.gui.ItSIMPLE.java
/** * @return Returns the planAnalysisFramePanel. */// ww w . j av a2 s .c o m private ItFramePanel getPlanAnalysisFramePanel() { if (planAnalysisFramePanel == null) { planAnalysisFramePanel = new ItFramePanel(":: Plan Analysis", ItFramePanel.NO_MINIMIZE_MAXIMIZE); // tool bar JToolBar chartsToolBar = new JToolBar(); chartsToolBar.add(new JButton(drawChartAction)); // charts panel chartsPanel = new JPanel(); chartsPanel.setLayout(new BoxLayout(chartsPanel, BoxLayout.Y_AXIS)); ItFramePanel variableSelectionPanel = new ItFramePanel(".: Select variables to be tracked", ItFramePanel.NO_MINIMIZE_MAXIMIZE); //variableSelectionPanel.setBackground(new Color(151,151,157)); JSplitPane split = new JSplitPane(); split.setContinuousLayout(true); split.setOrientation(JSplitPane.HORIZONTAL_SPLIT); split.setDividerLocation(2 * screenSize.height / 3); split.setDividerSize(8); //split.setPreferredSize(new Dimension(screenSize.width/4-20, screenSize.height/2 - 50)); //split.setPreferredSize(new Dimension(screenSize.width/4-20, 120)); split.setLeftComponent(new JScrollPane(variablesPlanTree)); split.setRightComponent(new JScrollPane(selectedVariablesPlanTree)); variableSelectionPanel.setContent(split, false); //variableSelectionPanel.setParentSplitPane() //JPanel variableSelectionPanel = new JPanel(new BorderLayout()); //variableSelectionPanel.add(new JScrollPane(variablesPlanTree), BorderLayout.CENTER); //variableSelectionPanel.add(new JScrollPane(selectedVariablesPlanTree), BorderLayout.EAST); ItFramePanel variableGraphPanel = new ItFramePanel(".: Chart", ItFramePanel.NO_MINIMIZE_MAXIMIZE); variableGraphPanel.setContent(chartsPanel, true); JSplitPane mainvariablesplit = new JSplitPane(); mainvariablesplit.setContinuousLayout(true); mainvariablesplit.setOrientation(JSplitPane.VERTICAL_SPLIT); mainvariablesplit.setDividerLocation(150); mainvariablesplit.setDividerSize(8); //mainvariablesplit.setPreferredSize(new Dimension(screenSize.width/4-20, screenSize.height/2 - 50)); mainvariablesplit.setTopComponent(variableSelectionPanel); mainvariablesplit.setBottomComponent(variableGraphPanel); // main charts panel - used to locate the tool bar above the charts panel JPanel mainChartsPanel = new JPanel(new BorderLayout()); mainChartsPanel.add(chartsToolBar, BorderLayout.NORTH); //mainChartsPanel.add(new JScrollPane(chartsPanel), BorderLayout.CENTER); mainChartsPanel.add(mainvariablesplit, BorderLayout.CENTER); //Results planInfoEditorPane = new JEditorPane(); planInfoEditorPane.setContentType("text/html"); planInfoEditorPane.setEditable(false); planInfoEditorPane.setCursor(new Cursor(Cursor.TEXT_CURSOR)); planInfoEditorPane.setBackground(Color.WHITE); JPanel resultsPanel = new JPanel(new BorderLayout()); JToolBar resultsToolBar = new JToolBar(); resultsToolBar.setRollover(true); JButton planReportButton = new JButton("View Full Report", new ImageIcon("resources/images/viewreport.png")); planReportButton.setToolTipText("<html>View full plan report.<br> For multiple plans you will need " + "access to the Internet.<br> The components used in the report require such access (no data is " + "sent through the Internet).</html>"); planReportButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { //Opens html with defaut browser String path = "resources/report/Report.html"; File report = new File(path); path = report.getAbsolutePath(); try { BrowserLauncher launcher = new BrowserLauncher(); launcher.openURLinBrowser("file://" + path); } catch (BrowserLaunchingInitializingException ex) { Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex); appendOutputPanelText("ERROR. Problem while trying to open the default browser. \n"); } catch (UnsupportedOperatingSystemException ex) { Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex); appendOutputPanelText("ERROR. Problem while trying to open the default browser. \n"); } } }); resultsToolBar.add(planReportButton); resultsToolBar.addSeparator(); JButton planReportDataButton = new JButton("Save Report Data", new ImageIcon("resources/images/savePDDL.png")); planReportDataButton.setToolTipText("<html>Save report data to file</html>"); planReportDataButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { //Save report data if (solveResult != null) { Element lastOpenFolderElement = itSettings.getChild("generalSettings") .getChild("lastOpenFolder"); JFileChooser fc = new JFileChooser(lastOpenFolderElement.getText()); fc.setDialogTitle("Save Report Data"); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setFileFilter(new XMLFileFilter()); int returnVal = fc.showSaveDialog(ItSIMPLE.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File selectedFile = fc.getSelectedFile(); String path = selectedFile.getPath(); if (!path.toLowerCase().endsWith(".xml")) { path += ".xml"; } //save file (xml) try { FileWriter file = new FileWriter(path); file.write(XMLUtilities.toString(solveResult)); file.close(); } catch (IOException e1) { e1.printStackTrace(); } //Save as a last open folder String folder = selectedFile.getParent(); //Element lastOpenFolderElement = itSettings.getChild("generalSettings").getChild("lastOpenFolder"); lastOpenFolderElement.setText(folder); XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument()); //Ask if the user wants to save plans individually too. boolean needToSavePlans = false; int option = JOptionPane.showOptionDialog(instance, "<html><center>Do you also want to save the plans" + "<br>in individual files?</center></html>", "Save plans", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); switch (option) { case JOptionPane.YES_OPTION: { needToSavePlans = true; } break; case JOptionPane.NO_OPTION: { needToSavePlans = false; } break; } if (needToSavePlans) { //Close Open tabs List<?> problems = null; try { XPath ppath = new JDOMXPath("project/domains/domain/problems/problem"); problems = ppath.selectNodes(solveResult); } catch (JaxenException e2) { e2.printStackTrace(); } for (int i = 0; i < problems.size(); i++) { Element problem = (Element) problems.get(i); //create a folder for each problem and put all plans inside as xml files String folderName = problem.getChildText("name"); String folderPath = selectedFile.getAbsolutePath() .replace(selectedFile.getName(), folderName); //System.out.println(folderPath); File planfolder = new File(folderPath); boolean canSavePlan = false; try { if (planfolder.mkdir()) { System.out.println("Directory '" + folderPath + "' created."); canSavePlan = true; } else { System.out.println("Directory '" + folderPath + "' was not created."); } } catch (Exception ep) { ep.printStackTrace(); } if (canSavePlan) { Element plans = problem.getChild("plans"); for (Iterator<Element> it = plans.getChildren("xmlPlan").iterator(); it .hasNext();) { Element eaplan = it.next(); Element theplanner = eaplan.getChild("planner"); //save file (xml) String planFileName = "solution" + theplanner.getChildText("name") + "-" + theplanner.getChildText("version") + "-" + Integer.toString(plans.getChildren().indexOf(eaplan)) + ".xml"; String planPath = folderPath + File.separator + planFileName; /* try { FileWriter planfile = new FileWriter(planPath); planfile.write(XMLUtilities.toString(eaplan)); planfile.close(); System.out.println("File '" + planPath + "' created."); } catch (IOException e1) { e1.printStackTrace(); } * */ if (eaplan.getChild("plan").getChildren().size() > 0) { //TODO: save the plan in PDDL too. It should be done through the XPDDL/PDDL classes String pddlplan = ToXPDDL.XMLtoXPDDLPlan(eaplan); String planFileNamePDDL = "solution" + theplanner.getChildText("name") + "-" + theplanner.getChildText("version") + "-" + Integer.toString(plans.getChildren().indexOf(eaplan)) + ".pddl"; String planPathPDDL = folderPath + File.separator + planFileNamePDDL; //String cfolderPath = selectedFile.getAbsolutePath().replace(selectedFile.getName(), ""); //String planFileNamePDDL = theplanner.getChildText("name")+"-"+theplanner.getChildText("version") + "-" + folderName+"-solution.pddl"; //String planPathPDDL = cfolderPath + File.separator + planFileNamePDDL; //if (!theplanner.getChildText("name").contains("MIPS")){ try { FileWriter planfile = new FileWriter(planPathPDDL); planfile.write(pddlplan); planfile.close(); System.out.println("File '" + planPathPDDL + "' created."); } catch (IOException e1) { e1.printStackTrace(); } } //} } } } } } } else { appendOutputPanelText(">> No report data available to save! \n"); } } }); resultsToolBar.add(planReportDataButton); JButton openPlanReportDataButton = new JButton("Open Report Data", new ImageIcon("resources/images/openreport.png")); openPlanReportDataButton.setToolTipText("<html>Open report data to file</html>"); openPlanReportDataButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { planSimStatusBar.setText("Status: Opening File..."); appendOutputPanelText(">> Opening File... \n"); //Open report data Element lastOpenFolderElement = itSettings.getChild("generalSettings") .getChild("lastOpenFolder"); JFileChooser fc = new JFileChooser(lastOpenFolderElement.getText()); fc.setDialogTitle("Open Report Data"); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setFileFilter(new XMLFileFilter()); int returnVal = fc.showOpenDialog(ItSIMPLE.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); // Get itSIMPLE itSettings from itSettings.xml org.jdom.Document resultsDoc = null; try { resultsDoc = XMLUtilities.readFromFile(file.getPath()); solveResult = resultsDoc.getRootElement(); //XMLUtilities.printXML(solveResult); if (solveResult.getName().equals("projects")) { String report = PlanAnalyzer.generatePlannersComparisonReport(solveResult); String comparisonReport = PlanAnalyzer .generateFullPlannersComparisonReport(solveResult); //Save Comparison Report file saveFile("resources/report/Report.html", comparisonReport); setPlanInfoPanelText(report); setPlanEvaluationInfoPanelText(""); appendOutputPanelText(">> Report data read! \n"); //My experiments PlanAnalyzer.myAnalysis(itPlanners.getChild("planners"), solveResult); } } catch (Exception e1) { e1.printStackTrace(); } //Save as a last open folder String folder = fc.getSelectedFile().getParent(); lastOpenFolderElement.setText(folder); XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument()); } else { planSimStatusBar.setText("Status:"); appendOutputPanelText(">> Canceled \n"); } } }); resultsToolBar.add(openPlanReportDataButton); JButton compareProjectReportDataButton = new JButton("Compare Project Data", new ImageIcon("resources/images/compare.png")); compareProjectReportDataButton.setToolTipText( "<html>Compare different project report data <br> This is commonly use to compare diferent domain models with different adjustments.<br>" + "One project data must be chosen as a reference; others will be compared to this referencial one.</html>"); compareProjectReportDataButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { final ProjectComparisonDialog dialog = new ProjectComparisonDialog(); dialog.setVisible(true); final List<String> files = dialog.getFiles(); if (files.size() > 1) { new Thread() { public void run() { appendOutputPanelText(">> Project comparison report requested. Processing... \n"); planSimStatusBar.setText("Status: Reading files ..."); appendOutputPanelText(">> Reading files ... \n"); //base project file String baseFileName = files.get(0); appendOutputPanelText(">> Reading file '" + baseFileName + "' \n"); org.jdom.Document baseProjectDoc = null; try { baseProjectDoc = XMLUtilities.readFromFile(baseFileName); } catch (Exception ec) { ec.printStackTrace(); } Element baseProject = null; if (baseProjectDoc != null) { baseProject = baseProjectDoc.getRootElement().getChild("project"); } //The comparible projects List<Element> comparableProjects = new ArrayList<Element>(); for (int i = 1; i < files.size(); i++) { String eafile = files.get(i); appendOutputPanelText(">> Reading file '" + eafile + "' \n"); org.jdom.Document eaProjectDoc = null; try { eaProjectDoc = XMLUtilities.readFromFile(eafile); } catch (Exception ec) { ec.printStackTrace(); } if (eaProjectDoc != null) { comparableProjects.add(eaProjectDoc.getRootElement().getChild("project")); } } appendOutputPanelText(">> Files read. Building report... \n"); String comparisonReport = PlanAnalyzer.generateProjectComparisonReport(baseProject, comparableProjects); saveFile("resources/report/Report.html", comparisonReport); appendOutputPanelText( ">> Project comparison report generated. Press 'View Full Report'\n"); appendOutputPanelText(" \n"); } }.start(); } } }); resultsToolBar.add(compareProjectReportDataButton); resultsPanel.add(resultsToolBar, BorderLayout.NORTH); resultsPanel.add(new JScrollPane(planInfoEditorPane), BorderLayout.CENTER); JTabbedPane planAnalysisTabbedPane = new JTabbedPane(); planAnalysisTabbedPane.addTab("Results", resultsPanel); planAnalysisTabbedPane.addTab("Variable Tracking", mainChartsPanel); planAnalysisTabbedPane.addTab("Movie Maker", getMovieMakerPanel()); planAnalysisTabbedPane.addTab("Plan Evaluation", getPlanEvaluationPanel()); planAnalysisTabbedPane.addTab("Plan Database", getPlanDatabasePanel()); planAnalysisTabbedPane.addTab("Rationale Database", getRationaleDatabasePanel()); JPanel planAnalysisPanel = new JPanel(new BorderLayout()); //planAnalysisPanel.add(chartsToolBar, BorderLayout.NORTH); planAnalysisPanel.add(planAnalysisTabbedPane, BorderLayout.CENTER); planAnalysisFramePanel.setContent(planAnalysisPanel, false); } return planAnalysisFramePanel; }
From source file:src.gui.ItSIMPLE.java
/** * This method creates the panel containing the pddl version selection component * @return /* w ww . ja va2 s . c om*/ */ private JPanel getPddlVersionSettingsPanel() { JPanel settingsPanel = new JPanel(); JRadioButton pddl21 = new JRadioButton("PDDL 2.1"); JRadioButton pddl22 = new JRadioButton("PDDL 2.2"); JRadioButton pddl30 = new JRadioButton("PDDL 3.0", true); JRadioButton pddl31 = new JRadioButton("PDDL 3.1"); pddl21.setOpaque(false); pddl21.setActionCommand(ToXPDDL.PDDL_2_1); pddl22.setOpaque(false); pddl22.setActionCommand(ToXPDDL.PDDL_2_2); pddl30.setOpaque(false); pddl30.setActionCommand(ToXPDDL.PDDL_3_0); pddl31.setOpaque(false); pddl31.setActionCommand(ToXPDDL.PDDL_3_1); pddlButtonsGroup = new ButtonGroup(); pddlButtonsGroup.add(pddl21); pddlButtonsGroup.add(pddl22); pddlButtonsGroup.add(pddl30); pddlButtonsGroup.add(pddl31); pddlButtonsGroup.setSelected(pddl21.getModel(), true); settingsPanel.setLayout(new BoxLayout(settingsPanel, BoxLayout.Y_AXIS)); settingsPanel.setOpaque(false); settingsPanel.add(pddl21); settingsPanel.add(pddl22); settingsPanel.add(pddl30); settingsPanel.add(pddl31); return settingsPanel; }
From source file:nl.tudelft.goal.SimpleIDE.FilePanel.java
/** * Helper method for {@link #handleFileRename(File, File)}. Asks the user * which of the given list of file references should be renamed. Returns a * new list of nodes that the user has selected. The given list is not * altered./* w ww .j a va 2 s . c o m*/ */ private List<FileNode> filterFiles(List<FileNode> nodes) { ArrayList<FileNode> filteredFiles = new ArrayList<FileNode>(); // show requester which files to change. // we can not dump an array of checkboxes into the showOptionDialog // because it will show them next to each oter instead of below each // other. // and because it does not show the OK and Cancel buttons. So we use // ConfirmDialog isntead JPanel choicespanel = new JPanel(); choicespanel.setLayout(new BoxLayout(choicespanel, BoxLayout.Y_AXIS)); choicespanel.add(new JLabel("There are multiple mas's using the renamed file.\n" //$NON-NLS-1$ + "Please select which ones have to be renamed")); //$NON-NLS-1$ ArrayList<JCheckBox> choices = new ArrayList<JCheckBox>(); for (FileNode n : nodes) { JCheckBox checkbox = new JCheckBox("" //$NON-NLS-1$ + ((FileNode) n.getParent()).getFilename()); choices.add(checkbox); choicespanel.add(checkbox); } int choice = JOptionPane.showConfirmDialog(this, choicespanel, "Select files to rename", //$NON-NLS-1$ JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (choice == JOptionPane.CANCEL_OPTION) { return null; } // and finally copy the requested filenames to array for (JCheckBox c : choices) { if (c.isSelected()) { for (FileNode n : nodes) { if (c.getText().equals(((FileNode) n.getParent()).getFilename())) { filteredFiles.add(n); break; } } } } return filteredFiles; }