Example usage for javax.swing JInternalFrame pack

List of usage examples for javax.swing JInternalFrame pack

Introduction

In this page you can find the example usage for javax.swing JInternalFrame pack.

Prototype

public void pack() 

Source Link

Document

Causes subcomponents of this JInternalFrame to be laid out at their preferred size.

Usage

From source file:Controlador.ControladorLecturas.java

public JInternalFrame graficoTemperatura() {
    DefaultCategoryDataset defaultCategoryDataset = new DefaultCategoryDataset();
    for (Object row : vectorTemperatura()) {
        int grados = Integer.parseInt(((Vector) row).elementAt(0).toString());
        String rowKey = "Sensor 1";
        String columnKey = ((Vector) row).elementAt(1).toString();
        defaultCategoryDataset.addValue(grados, rowKey, columnKey);
    }//from ww w  . ja  va 2s . com
    JFreeChart jFreeChart = ChartFactory.createLineChart(null, "Hora", "Grados", defaultCategoryDataset,
            PlotOrientation.VERTICAL, true, true, true);
    ChartPanel chartPanel = new ChartPanel(jFreeChart);
    JInternalFrame jInternalFrame = new JInternalFrame("Grafico de Temperatura Ambiental", true, true, true,
            true);
    jInternalFrame.add(chartPanel, BorderLayout.CENTER);
    jInternalFrame.pack();
    return jInternalFrame;
}

From source file:com.evanbelcher.DrillBook.display.DBMenuBar.java

/**
 * Changes the font size to what the user selects (between 8-30)
 */// www.  j a  v  a2 s  . co m
private void changeFontSize() {
    Integer[] nums = new Integer[23];
    for (int i = 8; i <= 30; i++) {
        nums[i - 8] = i;
    }
    try {
        int size = (int) JOptionPane.showInputDialog(this, "Choose a font size:", "Font Size",
                JOptionPane.PLAIN_MESSAGE, null, nums, Main.getState().getSettings().getFontSize());
        FontUIResource font = new FontUIResource("Dialog", Font.BOLD, size);

        Main.setUIFont(font);
        Main.getState().getSettings().setFontSize(size);
        SwingUtilities.updateComponentTreeUI(gr);

        for (JInternalFrame i : desktop.getAllFrames())
            i.pack();

    } catch (NullPointerException e) {
        e.printStackTrace();
    }
}

From source file:guineu.modules.dataanalysis.PCA.PCADataset.java

public void run() {

    setStatus(TaskStatus.PROCESSING);// w  ww  .  ja  va 2s .c o m

    logger.info("Computing projection plot");

    double[][] rawData = new double[selectedSamples.length][selectedRows.length];
    for (int rowIndex = 0; rowIndex < selectedRows.length; rowIndex++) {
        PeakListRow peakListRow = selectedRows[rowIndex];
        for (int fileIndex = 0; fileIndex < selectedSamples.length; fileIndex++) {
            String rawDataFile = selectedSamples[fileIndex];
            Object p = peakListRow.getPeak(rawDataFile);
            try {
                rawData[fileIndex][rowIndex] = (Double) p;
            } catch (Exception e) {
                // e.printStackTrace();
            }

        }
    }
    this.progress = 0.25f;

    int numComponents = xAxisPC;
    if (yAxisPC > numComponents) {
        numComponents = yAxisPC;
    }

    PCA pca = new PCA(selectedSamples.length, selectedRows.length);

    Matrix X = new Matrix(rawData, selectedSamples.length, selectedRows.length);

    String[] rowNames = new String[selectedRows.length];
    for (int j = 0; j < selectedRows.length; j++) {
        rowNames[j] = selectedRows[j].getName();
    }

    X = pca.center(X);
    X = pca.scale(X);
    pca.nipals(X, this.selectedSamples, rowNames, this.components);
    mainComponents = pca.getPCs();
    Collections.sort(mainComponents);
    if (status == TaskStatus.CANCELED) {
        return;
    }
    this.progress = 0.75f;

    for (PrincipleComponent comp : mainComponents) {
        this.totalVariation += comp.eigenValue;
    }

    if (mainComponents.size() > yAxisPC - 1) {
        component1Coords = mainComponents.get(xAxisPC - 1).eigenVector;
        component2Coords = mainComponents.get(yAxisPC - 1).eigenVector;

        Desktop desktop = GuineuCore.getDesktop();
        ProjectionPlotWindow newFrame = new ProjectionPlotWindow(this.datasetTitle, this, parameters);
        desktop.addInternalFrame(newFrame);

        if (this.showLoadings) {
            ChartPanel loadings = pca.loadingsplot(this.getXLabel(), this.getYLabel());
            JInternalFrame frame = new JInternalFrame();
            frame.setTitle("Principal Components Analysis: Loadings");
            frame.setResizable(true);
            frame.setClosable(true);
            frame.setMaximizable(true);
            frame.add(loadings, BorderLayout.CENTER);
            frame.setPreferredSize(new Dimension(700, 500));
            frame.pack();
            desktop.addInternalFrame(frame);
        }
    }
    this.progress = 1.0f;
    setStatus(TaskStatus.FINISHED);
    logger.info("Finished computing projection plot.");

}

From source file:de.codesourcery.jasm16.ide.ui.viewcontainers.Perspective.java

@Override
public IView addView(final IView view) {
    if (view == null) {
        throw new IllegalArgumentException("view must not be NULL");
    }/*from w  w w  .  j av  a  2 s  .  c om*/
    final JInternalFrame internalFrame = new JInternalFrame(view.getTitle(), true, true, true, true);

    internalFrame.setBackground(Color.BLACK);
    internalFrame.setForeground(Color.GREEN);

    internalFrame.getContentPane().add(view.getPanel(this));

    SizeAndLocation sizeAndLoc = applicationConfig.getViewCoordinates(getUniqueID(view));
    if (sizeAndLoc != null) {
        internalFrame.setSize(sizeAndLoc.getSize());
        internalFrame.setLocation(sizeAndLoc.getLocation());
    } else {
        internalFrame.setSize(200, 150);
        internalFrame.setLocation(0, 0);
        internalFrame.pack();
    }

    internalFrame.setVisible(true);

    final InternalFrameWithView frameAndView = new InternalFrameWithView(internalFrame, view);

    final InternalFrameListener listener = new InternalFrameAdapter() {

        @Override
        public void internalFrameClosing(InternalFrameEvent e) {
            disposeView(view);
        }
    };

    internalFrame.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE);
    internalFrame.addInternalFrameListener(listener);

    views.add(frameAndView);
    desktop.add(internalFrame);
    return view;
}

From source file:com.opendoorlogistics.studio.AppFrame.java

@Override
public void addInternalFrame(JInternalFrame frame, FramePlacement placement) {
    desktopPane.add(frame);//w w w .ja  v  a  2 s .  co  m
    frame.pack();
    frame.setVisible(true);

    // if(ScriptEditor.class.isInstance(frame)){
    // try {
    // frame.setMaximum(true);
    // } catch (PropertyVetoException e) {
    // }
    // }
    // else{

    // WindowState state = PreferencesManager.getSingleton().getWindowState(frame)
    if (placement == FramePlacement.AUTOMATIC) {
        boolean placed = false;
        if (ODLInternalFrame.class.isInstance(frame)) {
            ODLInternalFrame odlFrame = (ODLInternalFrame) frame;
            placed = odlFrame.placeInLastPosition(desktopScrollPane.getViewport().getBounds());
        }

        if (!placed) {
            LayoutUtils.placeInternalFrame(desktopPane, frame);
        }
    } else if (placement == FramePlacement.CENTRAL) {
        Dimension desktopSize = desktopPane.getSize();
        Dimension frameSize = frame.getSize();
        int x = (desktopSize.width - frameSize.width) / 2;
        int y = (desktopSize.height - frameSize.height) / 2;
        frame.setLocation(x, y);
    } else if (placement == FramePlacement.CENTRAL_RANDOMISED) {
        Dimension desktopSize = desktopPane.getSize();
        Dimension frameSize = frame.getSize();
        Dimension remaining = new Dimension(Math.max(0, desktopSize.width - frameSize.width),
                Math.max(0, desktopSize.height - frameSize.height));
        Dimension halfRemaining = new Dimension(remaining.width / 2, remaining.height / 2);
        Random random = new Random();
        int x = remaining.width / 4 + random.nextInt(halfRemaining.width);
        int y = remaining.height / 4 + random.nextInt(halfRemaining.height);
        frame.setLocation(x, y);
    }
    frame.toFront();
}

From source file:org.docx4all.ui.main.WordMLEditor.java

public void createInternalFrame(FileObject f) {
    if (f == null) {
        return;//from  w  w  w  .ja v  a 2s  . co  m
    }

    log.info(VFSUtils.getFriendlyName(f.getName().getURI()));

    JInternalFrame iframe = _iframeMap.get(f.getName().getURI());
    if (iframe != null) {
        iframe.setVisible(true);

    } else {
        iframe = new JInternalFrame(f.getName().getBaseName(), true, true, true, true);
        iframe.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        iframe.addInternalFrameListener(_internalFrameListener);
        iframe.addInternalFrameListener(_toolbarStates);
        iframe.addPropertyChangeListener(WindowMenu.getInstance());

        if (iframe.getUI() instanceof BasicInternalFrameUI) {
            BasicInternalFrameUI ui = (BasicInternalFrameUI) iframe.getUI();
            javax.swing.JComponent northPane = ui.getNorthPane();
            if (northPane == null) {
                // Happens on Mac OSX: Google for "osx java getNorthPane"
                // Fix is from it.businesslogic.ireport.gui.JMDIFrame
                javax.swing.plaf.basic.BasicInternalFrameUI aUI = new javax.swing.plaf.basic.BasicInternalFrameUI(
                        iframe);
                iframe.setUI(aUI);

                // Try again
                ui = (BasicInternalFrameUI) iframe.getUI();
                northPane = ((javax.swing.plaf.basic.BasicInternalFrameUI) ui).getNorthPane();
            }
            northPane.addMouseMotionListener(_titleBarMouseListener);
        }

        JEditorPane editorView = createEditorView(f);
        JPanel panel = FxScriptUIHelper.getInstance().createEditorPanel(editorView);

        iframe.getContentPane().add(panel);
        iframe.pack();
        _desktop.add(iframe);

        editorView.requestFocusInWindow();
        editorView.select(0, 0);

        String filePath = f.getName().getURI();
        iframe.putClientProperty(WordMLDocument.FILE_PATH_PROPERTY, filePath);
        _iframeMap.put(filePath, iframe);

        iframe.show();
    }

    try {
        iframe.setSelected(true);
        iframe.setIcon(false);
        iframe.setMaximum(true);
    } catch (PropertyVetoException exc) {
        // do nothing
    }
}