Search in sources :

Example 26 with Container

use of java.awt.Container in project yyl_example by Relucent.

the class SocketHttp1_0Main method main.

/**
	 * 主函数
	 * @param args
	 */
public static void main(String[] args) {
    JFrame frame = new JFrame();
    Container container = frame.getContentPane();
    container.add(new Content1().getContainer());
    frame.setBounds(100, 100, 500, 400);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setTitle("NIO-TEST");
    frame.setResizable(false);
    frame.setVisible(true);
}
Also used : Container(java.awt.Container) JFrame(javax.swing.JFrame)

Example 27 with Container

use of java.awt.Container in project ACS by ACS-Community.

the class JDynAct method buildWindow.

/** Build the GUI
	 *
	 */
private void buildWindow() {
    Container rootCnt = getContentPane();
    rootCnt.setLayout(new BorderLayout());
    // The container with labels and combo boxes
    Container firstCnt = new Container();
    firstCnt.setLayout(new GridLayout(4, 2));
    firstCnt.add(new JLabel("Name"));
    nameCB = new JComboBox();
    nameCB.setEditable(true);
    nameCB.addItem("*");
    nameCB.addItem("PIPPO");
    nameCB.addItem("PLUTO");
    firstCnt.add(nameCB);
    firstCnt.add(new JLabel("IDL interface"));
    idlCB = new JComboBox();
    idlCB.addItem("*");
    idlCB.addItem("IDL:alma/acsexmplLamp/Lamp:1.0");
    idlCB.addItem("IDL:alma/MOUNT_ACS/Mount:1.0");
    idlCB.addItem("IDL:alma/demo/HelloDemo:1.0");
    idlCB.setEditable(true);
    firstCnt.add(idlCB);
    firstCnt.add(new JLabel("Implementation"));
    implCB = new JComboBox();
    implCB.addItem("*");
    implCB.addItem("acsexmplLampImpl");
    implCB.addItem("acsexmplMountImpl");
    implCB.addItem("alma.demo.HelloDemoImpl.HelloDemoHelper");
    implCB.addItem("demoImpl.HelloDemo");
    implCB.addItem("acsexmplHelloWorldClient");
    implCB.setEditable(true);
    firstCnt.add(implCB);
    firstCnt.add(new JLabel("Container"));
    containerCB = new JComboBox();
    containerCB.addItem("*");
    containerCB.addItem("bilboContainer");
    containerCB.addItem("frodoContainer");
    containerCB.addItem("aragornContainer");
    containerCB.setEditable(true);
    firstCnt.add(containerCB);
    // The container with the activate button
    Container secondCnt = new Container();
    secondCnt.setLayout(new FlowLayout());
    JButton activateB = new JButton("Activate");
    activateB.addActionListener(this);
    secondCnt.add(activateB, "Center");
    // The container with activated container
    MyTableModel tableModel = new MyTableModel();
    activatedT = new JTable(tableModel);
    activatedT.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    ListSelectionModel rowSM = activatedT.getSelectionModel();
    JScrollPane scrollP = new JScrollPane(activatedT);
    activatedT.setPreferredScrollableViewportSize(new Dimension(400, 90));
    MyCellRendererr cellR = new MyCellRendererr();
    TableColumnModel tcm = activatedT.getColumnModel();
    TableColumn tc = tcm.getColumn(2);
    tc.setCellRenderer(cellR);
    MyCellEditor cellE = new MyCellEditor(this);
    tc.setCellEditor(cellE);
    Container thirdCnt = new Container();
    thirdCnt.setLayout(new FlowLayout());
    thirdCnt.add(scrollP, "North");
    // Add the container to the main container
    rootCnt.add(firstCnt, "North");
    rootCnt.add(secondCnt, "Center");
    rootCnt.add(thirdCnt, "South");
}
Also used : JScrollPane(javax.swing.JScrollPane) FlowLayout(java.awt.FlowLayout) JComboBox(javax.swing.JComboBox) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) ListSelectionModel(javax.swing.ListSelectionModel) TableColumnModel(javax.swing.table.TableColumnModel) Dimension(java.awt.Dimension) TableColumn(javax.swing.table.TableColumn) Container(java.awt.Container) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable)

Example 28 with Container

use of java.awt.Container in project ACS by ACS-Community.

the class WindowUtils method frameResidesInDesktop.

/**
   * Utility method: makes the given mode either reside in the desktop or display a separate window.
   * @param mode the mode to make reside in the desktop
   * @param frameType indicates the type of frame, MDI or SDI
   */
public static void frameResidesInDesktop(Mode mode, int frameType) {
    Assertion.assertTrue(mode != null, "mode != null");
    try {
        ClassLoader classLoader = Mode.class.getClassLoader();
        Class modeImpl = Class.forName("org.netbeans.core.windows.ModeImpl", true, classLoader);
        Method getCurrentConstraintsMethod = modeImpl.getMethod("getCurrentConstraints", null);
        Object currentConstraints = getCurrentConstraintsMethod.invoke(mode, null);
        Method setFrameTypeMethod = modeImpl.getMethod("setFrameType", new Class[] { String.class });
        Method setVisibleMethod = modeImpl.getMethod("setVisible", new Class[] { boolean.class });
        Method isVisibleMethod = modeImpl.getMethod("isVisible", null);
        boolean wasVisible = ((Boolean) isVisibleMethod.invoke(mode, null)).booleanValue();
        if (frameType == DESKTOP_FRAME)
            currentConstraints = CONSTRAINT_WEST;
        Class windowUtils = Class.forName("org.netbeans.core.windows.util.WindowUtils", true, classLoader);
        Method findConstrainedModeMethod = windowUtils.getMethod("findConstrainedMode", new Class[] { Workspace.class, Object.class });
        Object constrainedMode = findConstrainedModeMethod.invoke(null, new Object[] { mode.getWorkspace(), currentConstraints });
        String frameTypeName = possibleFrameTypes[frameType];
        if (constrainedMode != null && frameType == DESKTOP_FRAME) {
            frameType = INTERNAL_FRAME;
            frameTypeName = possibleFrameTypes[frameType];
            currentConstraints = null;
        }
        Class windowTypeMgr = Class.forName("org.netbeans.core.windows.frames.WindowTypesManager", true, classLoader);
        Field frameFieldMode = windowTypeMgr.getField(frameTypeName);
        Method changeModeConstraintsMethod = windowUtils.getMethod("changeModeConstraints", new Class[] { modeImpl, Object.class });
        changeModeConstraintsMethod.invoke(null, new Object[] { mode, currentConstraints });
        setFrameTypeMethod.invoke(mode, new Object[] { frameFieldMode.get(windowTypeMgr) });
        if (wasVisible) {
            setVisibleMethod.invoke(mode, new Object[] { Boolean.TRUE });
            Class mainWindow = Class.forName("org.netbeans.core.windows.MainWindow", true, classLoader);
            Method getDefaultMethod = mainWindow.getMethod("getDefault", null);
            Method getContentPaneMethod = mainWindow.getMethod("getContentPane", null);
            Container cp = (Container) getContentPaneMethod.invoke(getDefaultMethod.invoke(null, null), null);
            cp.validate();
        }
    } catch (Exception e) {
        GPManager.notify(GPManager.EXCEPTION, e);
    }
}
Also used : Field(java.lang.reflect.Field) Container(java.awt.Container) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 29 with Container

use of java.awt.Container in project EnrichmentMapApp by BaderLab.

the class AddRanksDialog method createContents.

private void createContents() {
    JPanel textFieldPanel = createTextFieldPanel();
    JPanel buttonPanel = createButtonPanel();
    Container contentPane = this.getContentPane();
    GroupLayout layout = new GroupLayout(contentPane);
    contentPane.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup().addComponent(textFieldPanel).addComponent(buttonPanel));
    layout.setVerticalGroup(layout.createSequentialGroup().addComponent(textFieldPanel).addGap(0, 0, Short.MAX_VALUE).addComponent(buttonPanel));
}
Also used : JPanel(javax.swing.JPanel) Container(java.awt.Container) GroupLayout(javax.swing.GroupLayout)

Example 30 with Container

use of java.awt.Container in project ats-framework by Axway.

the class SwingElementLocator method getContainerFixture.

/**
     * Change container by specified name or title.
     * For internal use
     * @param driver
     * @param containerProperties property with name inside
     * @return the {@link ContainerFinxture}
     */
public static ContainerFixture<?> getContainerFixture(SwingDriverInternal driver, UiElementProperties containerProperties) {
    String containerName = containerProperties.getProperty("name");
    final String containerTitle = containerProperties.getProperty("title");
    if (StringUtils.isNullOrEmpty(containerName) && StringUtils.isNullOrEmpty(containerTitle)) {
        throw new IllegalArgumentException("Illegal name/title (empty/null string) passed to search for container");
    }
    ContainerFixture<?> containerFixture = driver.getActiveContainerFixture();
    ContainerFixture<?> windowsFixture = driver.getWindowFixture();
    Robot robot = null;
    if (containerFixture != null) {
        // use the current robot instance
        robot = containerFixture.robot;
    } else {
        robot = BasicRobot.robotWithCurrentAwtHierarchy();
    }
    if (!StringUtils.isNullOrEmpty(containerName)) {
        try {
            Container cont = BasicComponentFinder.finderWithCurrentAwtHierarchy().findByName(windowsFixture.component(), containerName, Container.class);
            return new ContainerFixture<Container>(robot, cont) {
            };
        } catch (WaitTimedOutError wtoe) {
            throw new ElementNotFoundException("Unable to find container with name '" + containerName + "' under current window/dialog. If needed change current window first with swingEngineInstance.setActiveWindow()");
        }
    } else {
        try {
            Container cont = BasicComponentFinder.finderWithCurrentAwtHierarchy().find(windowsFixture.component(), new GenericTypeMatcher<Container>(Container.class, true) {

                @Override
                protected boolean isMatching(Container component) {
                    if (component instanceof Dialog) {
                        return ((Dialog) component).getTitle().equals(containerTitle);
                    } else if (component instanceof Frame) {
                        return ((Frame) component).getTitle().equals(containerTitle);
                    } else if (component instanceof JInternalFrame) {
                        return ((JInternalFrame) component).getTitle().equals(containerTitle);
                    }
                    return false;
                }
            });
            return new ContainerFixture<Container>(robot, cont) {
            };
        } catch (WaitTimedOutError wtoe) {
            throw new ElementNotFoundException("Unable to find container with title '" + containerName + "' under current window/dialog. If needed change current window first with swingEngineInstance.setActiveWindow()");
        }
    }
}
Also used : Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) ElementNotFoundException(com.axway.ats.uiengine.exceptions.ElementNotFoundException) WaitTimedOutError(org.fest.swing.exception.WaitTimedOutError) Container(java.awt.Container) Dialog(java.awt.Dialog) ContainerFixture(org.fest.swing.fixture.ContainerFixture) Robot(org.fest.swing.core.Robot) BasicRobot(org.fest.swing.core.BasicRobot) JInternalFrame(javax.swing.JInternalFrame)

Aggregations

Container (java.awt.Container)250 JPanel (javax.swing.JPanel)70 JLabel (javax.swing.JLabel)65 JButton (javax.swing.JButton)56 JScrollPane (javax.swing.JScrollPane)55 BoxLayout (javax.swing.BoxLayout)50 FlowLayout (java.awt.FlowLayout)49 Component (java.awt.Component)46 BorderLayout (java.awt.BorderLayout)44 Dimension (java.awt.Dimension)39 ActionEvent (java.awt.event.ActionEvent)38 ActionListener (java.awt.event.ActionListener)26 JComponent (javax.swing.JComponent)22 JFrame (javax.swing.JFrame)22 JmriJFrame (jmri.util.JmriJFrame)20 Border (javax.swing.border.Border)18 JTable (javax.swing.JTable)17 JTextArea (javax.swing.JTextArea)17 Frame (java.awt.Frame)16 JTextField (javax.swing.JTextField)16