Java Code Examples for javax.swing.JPanel.setBackground()

The following are Jave code examples for showing how to use setBackground() of the javax.swing.JPanel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Logisim   File: SplashScreen.java   View Source Code Vote up 7 votes
public SplashScreen() {
	JPanel imagePanel = About.getImagePanel();
	imagePanel.setBorder(null);

	progress.setStringPainted(true);

	JPanel buttonPanel = new JPanel();
	buttonPanel.add(close);
	close.addActionListener(this);
	buttonPanel.add(cancel);
	cancel.addActionListener(this);

	JPanel contents = new JPanel(new BorderLayout());
	contents.add(imagePanel, BorderLayout.NORTH);
	contents.add(progress, BorderLayout.CENTER);
	contents.add(buttonPanel, BorderLayout.SOUTH);
	contents.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));

	Color bg = imagePanel.getBackground();
	contents.setBackground(bg);
	buttonPanel.setBackground(bg);
	setBackground(bg);
	setContentPane(contents);
}
 
Example 2
Project: JavaMinicap   File: DrawImageThread.java   View Source Code Vote up 6 votes
public DrawImageThread(String serial, int port, JPanel parPanel){
	this.serial = serial;
	this.port = port;
	
	this.drawArea = new DrawCanvas();
	this.drawArea.setPreferredSize(new Dimension(MainFrame.AREA_WIDTH, MainFrame.AREA_HEIGHT));
	parPanel.setLayout(new BorderLayout());
	parPanel.add(this.drawArea, BorderLayout.CENTER);
	JPanel jpBotinfo = new JPanel();
	jpBotinfo.setLayout(new GridLayout(2,1));
	JLabel jlPort = new JLabel("pc端口号:"+new Integer(this.port).toString(), JLabel.LEFT);
	jpBotinfo.add(jlPort);
	JLabel jlSerial = new JLabel("设备号:"+this.serial, JLabel.LEFT);
	jpBotinfo.add(jlSerial);
	parPanel.add(jpBotinfo, BorderLayout.SOUTH);

	parPanel.setBackground(new Color(255,255,255));
	//启动adb连接
	this.parser = new SelfParse(this.serial, this.port);
}
 
Example 3
Project: powertext   File: MatchedBracketPopup.java   View Source Code Vote up 6 votes
MatchedBracketPopup(Window parent, RSyntaxTextArea textArea, int
		offsToRender) {

	super(parent);
	this.textArea = textArea;
	JPanel cp = new JPanel(new BorderLayout());
	cp.setBorder(BorderFactory.createCompoundBorder(
			TipUtil.getToolTipBorder(),
			BorderFactory.createEmptyBorder(2, LEFT_EMPTY_BORDER, 5, 5)));
	cp.setBackground(TipUtil.getToolTipBackground());
	setContentPane(cp);

	cp.add(new JLabel(getText(offsToRender)));

	installKeyBindings();
	listener = new Listener();
	setLocation();

}
 
Example 4
Project: xdman   File: BrowserIntDlg.java   View Source Code Vote up 6 votes
void createOthersPanel() {
	othersPanel = new JPanel(new BorderLayout(10, 10));
	othersPanel.setBackground(Color.WHITE);
	othersPanel.setBorder(new EmptyBorder(0, 20, 0, 20));
	JTextArea txt1 = new JTextArea(StringResource.getString("BI_LBL_6"));
	txt1.setBorder(new EmptyBorder(20, 20, 20, 20));
	txt1.setBackground(bgColor);
	txt1.setOpaque(false);
	txt1.setWrapStyleWord(true);
	txt1.setEditable(false);
	txt1.setLineWrap(true);
	othersPanel.add(txt1, BorderLayout.NORTH);

	JPanel biPanel = new JPanel(new GridLayout(2, 1, 20, 20));
	biPanel.setBorder(new EmptyBorder(20, 20, 20, 20));

	biPanel.add(btn1);
	biPanel.add(btn2);
	biPanel.setBackground(Color.WHITE);

	othersPanel.add(biPanel);

	othersPanel.add(autoStart, BorderLayout.SOUTH);
}
 
Example 5
Project: incubator-netbeans   File: NotificationCenterTopComponent.java   View Source Code Vote up 5 votes
private void init() {
        initComponents();
        detailsPanel = new JPanel(new GridLayout(1, 1));
        Color color = Utils.getTextBackground();
        detailsPanel.setBackground(new Color(color.getRed(), color.getGreen(), color.getBlue()));
        lblEmptyDetails = new JLabel(NbBundle.getMessage(NotificationCenterTopComponent.class, "LBL_EmptyDetails"), JLabel.CENTER);
        lblEmptyDetails.setFont(italicFont);
        lblEmptyDetails.setEnabled(false);

        JScrollPane scrollPane = new JScrollPane(detailsPanel);
        splitPane.setRightComponent(scrollPane);

        toolBar.setFocusable(false);
        toolBar.setFloatable(false);
        btnSearch = new JToggleButton(ImageUtilities.loadImageIcon("org/netbeans/modules/notifications/resources/find16.png", true));
        btnSearch.setToolTipText(NbBundle.getMessage(NotificationCenterTopComponent.class, "LBL_SearchToolTip"));
        btnSearch.setFocusable(false);
        btnSearch.setSelected(NotificationSettings.isSearchVisible());
        //TODO delete 2 lines then quick search API clear text correctly
//        btnSearch.setToolTipText("Disabled due to Quick Search API defects");
//        btnSearch.setEnabled(false);
        btnSearch.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                setSearchVisible(btnSearch.isSelected());
            }
        });
        toolBar.add(btnSearch);
        toolBar.add(new FiltersMenuButton(notificationManager.getActiveFilter()));

        initLeft();
        showDetails();
    }
 
Example 6
Project: openjdk-jdk10   File: TestPopupMenu.java   View Source Code Vote up 5 votes
private JPanel getContainerPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    label = new JLabel("Test Label");
    JPopupMenu popup = new JPopupMenu();
    JMenuItem menuItem1 = new JMenuItem("Item 1");
    JMenuItem menuItem2 = new JMenuItem("Item 2");
    JMenuItem menuItem3 = new JMenuItem("Item 3");
    JMenuItem menuItem4 = new JMenuItem("Item 4");
    JMenuItem menuItem5 = new JMenuItem("Item 5");
    menuItem1.setOpaque(false);
    menuItem2.setOpaque(false);
    menuItem3.setOpaque(false);
    menuItem4.setOpaque(false);
    menuItem5.setOpaque(false);
    popup.add(menuItem1);
    popup.add(menuItem2);
    popup.add(menuItem3);
    popup.add(menuItem4);
    popup.add(menuItem5);
    label.setComponentPopupMenu(popup);
    popup.setBackground(Color.CYAN);
    panel.add(label, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    panel.setBackground(Color.CYAN);
    return panel;
}
 
Example 7
Project: incubator-netbeans   File: StopwatchProfilingPoint.java   View Source Code Vote up 5 votes
private void initComponents() {
    setLayout(new BorderLayout());

    JPanel contentsPanel = new JPanel(new BorderLayout());
    contentsPanel.setBackground(UIUtils.getProfilerResultsBackground());
    contentsPanel.setOpaque(true);
    contentsPanel.setBorder(BorderFactory.createMatteBorder(0, 15, 15, 15, UIUtils.getProfilerResultsBackground()));

    headerArea = new HTMLTextArea() {
            protected void showURL(URL url) {
                String urlString = url.toString();

                if (START_LOCATION_URLMASK.equals(urlString)) {
                    Utils.openLocation(StopwatchProfilingPoint.this.getStartLocation());
                } else if (StopwatchProfilingPoint.this.usesEndLocation()) {
                    Utils.openLocation(StopwatchProfilingPoint.this.getEndLocation());
                }
            }
        };

    JScrollPane headerAreaScrollPane = new JScrollPane(headerArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                                       JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    headerAreaScrollPane.setBorder(BorderFactory.createMatteBorder(0, 0, 15, 0, UIUtils.getProfilerResultsBackground()));
    headerAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
    contentsPanel.add(headerAreaScrollPane, BorderLayout.NORTH);

    dataArea = new HTMLTextArea();

    JScrollPane dataAreaScrollPane = new JScrollPane(dataArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    TitledBorder tb = new TitledBorder(Bundle.StopwatchProfilingPoint_DataString());
    tb.setTitleFont(Utils.getTitledBorderFont(tb).deriveFont(Font.BOLD));
    tb.setTitleColor(javax.swing.UIManager.getColor("Label.foreground")); // NOI18N
    dataAreaScrollPane.setBorder(tb);
    dataAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
    dataAreaScrollPane.setBackground(UIUtils.getProfilerResultsBackground());
    contentsPanel.add(dataAreaScrollPane, BorderLayout.CENTER);

    add(contentsPanel, BorderLayout.CENTER);
}
 
Example 8
Project: incubator-netbeans   File: LoadGenProfilingPoint.java   View Source Code Vote up 5 votes
private void initComponents() {
    setLayout(new BorderLayout());

    JPanel contentsPanel = new JPanel(new BorderLayout());
    contentsPanel.setBackground(UIUtils.getProfilerResultsBackground());
    contentsPanel.setOpaque(true);
    contentsPanel.setBorder(BorderFactory.createMatteBorder(0, 15, 15, 15, UIUtils.getProfilerResultsBackground()));

    headerArea = new HTMLTextArea() {
            protected void showURL(URL url) {
                String urlString = url.toString();

                if (START_LOCATION_URLMASK.equals(urlString)) {
                    Utils.openLocation(LoadGenProfilingPoint.this.getStartLocation());
                } else if (LoadGenProfilingPoint.this.usesEndLocation()) {
                    Utils.openLocation(LoadGenProfilingPoint.this.getEndLocation());
                }
            }
        };

    JScrollPane headerAreaScrollPane = new JScrollPane(headerArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                                       JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    headerAreaScrollPane.setBorder(BorderFactory.createMatteBorder(0, 0, 15, 0, UIUtils.getProfilerResultsBackground()));
    headerAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
    contentsPanel.add(headerAreaScrollPane, BorderLayout.NORTH);

    dataArea = new HTMLTextArea();

    JScrollPane dataAreaScrollPane = new JScrollPane(dataArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    TitledBorder tb = new TitledBorder(Bundle.LoadGenProfilingPoint_DataString());
    tb.setTitleFont(Utils.getTitledBorderFont(tb).deriveFont(Font.BOLD));
    tb.setTitleColor(javax.swing.UIManager.getColor("Label.foreground")); // NOI18N
    dataAreaScrollPane.setBorder(tb);
    dataAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
    dataAreaScrollPane.setBackground(UIUtils.getProfilerResultsBackground());
    contentsPanel.add(dataAreaScrollPane, BorderLayout.CENTER);

    add(contentsPanel, BorderLayout.CENTER);
}
 
Example 9
Project: SE2Project   File: AusleiheUI.java   View Source Code Vote up 5 votes
/**
 * Erzeugt das Anzeige-Panel, in dem die ausgewählte Medien und der
 * ausgewählte kunde angezeigt werden.
 */
private void erzeugeAnzeigerPanel()
{
    _anzeigerPanel = new JPanel();
    _ausleihePanel.add(_anzeigerPanel, BorderLayout.CENTER);
    _anzeigerPanel.setLayout(new BorderLayout());
    setNoSize(_anzeigerPanel);
    _anzeigerPanel.setBackground(UIConstants.BACKGROUND_COLOR);
    _anzeigerPanel.add(_mediendetailAnzeigerPanel, BorderLayout.CENTER);
    _anzeigerPanel.add(_kundendetailAnzeigerPanel, BorderLayout.NORTH);
}
 
Example 10
Project: SE2Project   File: VormerkUI.java   View Source Code Vote up 5 votes
/**
 * Erzeugt das Anzeige-Panel, in dem die ausgewählte Medien und der
 * ausgewählte kunde angezeigt werden.
 */
private void erzeugeAnzeigerPanel()
{
    _anzeigerPanel = new JPanel();
    _ausleihePanel.add(_anzeigerPanel, BorderLayout.CENTER);
    _anzeigerPanel.setLayout(new BorderLayout());
    setNoSize(_anzeigerPanel);
    _anzeigerPanel.setBackground(UIConstants.BACKGROUND_COLOR);
    _anzeigerPanel.add(_mediendetailAnzeigerPanel, BorderLayout.CENTER);
    _anzeigerPanel.add(_kundendetailAnzeigerPanel, BorderLayout.NORTH);
}
 
Example 11
Project: incubator-netbeans   File: QueryBuilderInternalFrame.java   View Source Code Vote up 5 votes
public void create() {
       
       JPanel mainPanel = new JPanel();
       //      mainPanel.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
       mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
       
       // Create a JTable component, with the specified TableModel behind it
       _qbTable = new QueryBuilderTable(_queryBuilderTableModel);
       _qbTable.setBackground(Color.white); 
       
       // Wrap the JTable in a JScrollPane
       JScrollPane sp = new JScrollPane(_qbTable);
       sp.getViewport().setBackground(Color.white); 
       
       // Wrap the JScrollPane in a JPanel
       mainPanel.add(sp,BorderLayout.CENTER);
       mainPanel.setBackground(Color.white); 
       
       // And add the JPanel to the content pane of the internal frame 
       getContentPane().add(mainPanel);
       getContentPane().setBackground(Color.white); 
       
       DragSource dragSource = DragSource.getDefaultDragSource();

dragSource.createDefaultDragGestureRecognizer(
    _qbTable, // component where drag originates
    DnDConstants.ACTION_MOVE, // actions
    this); // drag gesture recognizer

       _dropTarget = new DropTarget ( _qbTable, 
			       DnDConstants.ACTION_MOVE,
			       this );

       // Per JInternalFrame tutorial, it's importnat to set the size of the internal frame
       // (with pack, setSize, or setBounds) and make it visible (with setVisible or show)
       pack();
       setSize(175,120);
       setVisible(true);
   }
 
Example 12
Project: hearthstone   File: Muligar.java   View Source Code Vote up 5 votes
/**
 * preenche o painel com a lista de cards disponíveis para muligar
 */
private void preencher() {
    for (int index = 0; index < labelX.length; index++) {
        JPanel panel = new JPanel(new AbsoluteLayout());
        panel.setBackground(new Color(0, 0, 0, 0));
        JLabel label_card = new JLabel(Images.getCardIcon(Images.CARD_ORIGINAL, deck.get(index).getId()));
        labelX[index] = new JLabel();
        label_card.addMouseListener(eventoClicarNoCard(index));
        labelX[index].addMouseListener(eventoClicarNaImagemX(index));
        panel.add(labelX[index], new AbsoluteConstraints(20, 125));
        panel.add(label_card, new AbsoluteConstraints(0, 0));
        jPanelCards.add(panel);
    }
}
 
Example 13
Project: jdk8u-jdk   File: bug8016356.java   View Source Code Vote up 5 votes
private static void createAndShowUI() {
    frame = new JFrame();
    frame.setBounds(10, scrTop + 10, 300, 100);
    JPanel panel = new JPanel();
    panel.setBackground(color);
    frame.getContentPane().add(panel);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}
 
Example 14
Project: incubator-netbeans   File: BrowserMenu.java   View Source Code Vote up 5 votes
private JPanel createBrighterPanel() {
    JPanel res = new JPanel( new BorderLayout() );
    Color background = UIManager.getColor( "Nb.browser.picker.background.light" );
    if( null != background ) {
        res.setOpaque( true );
        res.setBackground( background );
    } else {
        res.setOpaque( false );
    }
    return res;
}
 
Example 15
Project: rapidminer   File: DataTableViewer.java   View Source Code Vote up 4 votes
public DataTableViewer(DataTable dataTable, LinkedHashMap<String, Class<? extends Plotter>> availablePlotters,
		boolean showPlotter, String tableMode, boolean autoResize) {
	super(new BorderLayout());

	// create empty buttonCard
	ButtonBarCardPanel bCard = new ButtonBarCardPanel();

	// Build table view
	this.dataTableViewerTable = new DataTableViewerTable(autoResize);
	this.tablePanel = new JPanel(new BorderLayout());
	JPanel infoPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
	infoPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 5));
	infoPanel.add(generalInfo);
	infoPanel.setOpaque(true);
	infoPanel.setBackground(Colors.WHITE);
	tablePanel.add(infoPanel, BorderLayout.NORTH);
	JScrollPane tableScrollPane = new ExtendedJScrollPane(dataTableViewerTable);
	tableScrollPane.setBorder(BorderFactory.createEmptyBorder(1, 10, 10, 5));
	tableScrollPane.setBackground(Colors.WHITE);
	tableScrollPane.getViewport().setBackground(Colors.WHITE);
	tablePanel.add(tableScrollPane, BorderLayout.CENTER);

	// add data table to the result view
	bCard.addCard(new ResourceCard("data_view", "result_view.data_view"), tablePanel);

	// Add plotters if desired
	if (showPlotter) {
		this.plotterSettings = new PlotterConfigurationModel(availablePlotters, dataTable);
		this.plotterPanel = new PlotterPanel(plotterSettings);
		DataTable plotData = plotterSettings.getDataTable();

		// preface to create ChartConfigationPanel:
		ExampleSet exampleSet = DataTableExampleSetAdapter.createExampleSetFromDataTable(plotData);
		Map<DatasetTransformationType, PlotConfiguration> plotConfigurationMap = PlotConfigurationHistory
				.getPlotConfigurationMap(exampleSet, plotData);
		PlotInstance plotInstance = new PlotInstance(plotConfigurationMap.get(DatasetTransformationType.ORIGINAL),
				plotData);
		this.advancedPanel = new ChartConfigurationPanel(true, plotInstance, plotData,
				plotConfigurationMap.get(DatasetTransformationType.DE_PIVOTED));

		// add Plotter to the result view
		bCard.addCard(new ResourceCard("plot_view", "result_view.plot_view"), plotterPanel);

		// add advanced Charts to the result view
		bCard.addCard(new ResourceCard("advanced_charts", "result_view.advanced_charts"), advancedPanel);
	} // end if (showPlotter)

	// check select desired view
	if (PLOT_MODE.equals(tableMode) && showPlotter) {
		bCard.selectCard("plot_view");
	} else if (ADVANCED_MODE.equals(tableMode) && showPlotter) {
		bCard.selectCard("advanced_charts");
	}

	add(bCard, BorderLayout.CENTER);
	setDataTable(dataTable);
}
 
Example 16
Project: incubator-netbeans   File: ResultView.java   View Source Code Vote up 4 votes
public ResultView() {
    setLayout(contentCards = new CardLayout());

    setName("Search Results");                                      //NOI18N
    setDisplayName(NbBundle.getMessage(ResultView.class, "TITLE_SEARCH_RESULTS"));    //NOI18N
    
    initAccessibility();

    pop = new JPopupMenu();
    pop.add(new Close());
    pop.add(new CloseAll());
    pop.add(new CloseAllButCurrent());
    popL = new PopupListener();
    closeL = new CloseListener();
    
    emptyPanel = new JPanel();
    singlePanel = new JPanel();
    singlePanel.setLayout(new BoxLayout(singlePanel, BoxLayout.PAGE_AXIS));
    emptyPanel.setOpaque(true);
    tabs = TabbedPaneFactory.createCloseButtonTabbedPane();
    tabs.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            updateLookup();
        }
    });
    tabs.setMinimumSize(new Dimension(0, 0));
    tabs.addMouseListener(popL);
    tabs.addPropertyChangeListener(closeL);
    add(emptyPanel, CARD_NAME_EMPTY);
    add(tabs, CARD_NAME_TABS);
    add(singlePanel, CARD_NAME_SINGLE);
    if (isMacLaf) {
        emptyPanel.setBackground(macBackground);
        tabs.setBackground(macBackground);
        tabs.setOpaque(true);
        setBackground(macBackground);
        setOpaque(true);
    } else {
        emptyPanel.setBackground(
                UIManager.getColor("Tree.background"));         //NOI18N
    }
    contentCards.show(this, CARD_NAME_EMPTY);
    associateLookup(Lookups.proxy(lookupProvider));
}
 
Example 17
Project: Equella   File: ManagementDialog.java   View Source Code Vote up 4 votes
private void setup()
{
	bullets = new ImageIcon(ManagementDialog.class.getResource("/icons/menuitem.gif"));

	currentLaF = UIManager.getLookAndFeel();
	flatterLaF = new FlatterLookAndFeel();

	JImage header = new JImage(ManagementDialog.class.getResource("/icons/header.gif"));
	Dimension size1 = new Dimension(450, 70);
	header.setSize(size1);
	header.setMinimumSize(size1);
	header.setPreferredSize(size1);
	header.setMaximumSize(size1);

	JImage footer = new JImage(ManagementDialog.class.getResource("/icons/footer.gif"));
	Dimension size2 = new Dimension(450, 6);
	footer.setSize(size2);
	footer.setMinimumSize(size2);
	footer.setPreferredSize(size2);
	footer.setMaximumSize(size2);

	toolsPanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 5, 1, false, false));
	right = new JPanel(new GridLayout(1, 1));

	ImageIcon icon = new ImageIcon(ManagementDialog.class.getResource(EXIT_ICON));
	exitButton = new JHoverButton(CurrentLocale.get("com.tle.admin.gui.managementdialog.exit"), icon);
	setupButton(exitButton);

	JPanel south = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
	south.add(exitButton);

	JPanel left = new JPanel(new BorderLayout());
	left.add(toolsPanel, BorderLayout.CENTER);
	left.add(south, BorderLayout.SOUTH);

	final int[] rows = {TableLayout.FILL,};
	final int[] cols = {175, TableLayout.FILL,};

	JPanel centre = new JPanel(new TableLayout(rows, cols, 5, 5));
	centre.add(left, new Rectangle(0, 0, 1, 1));
	centre.add(right, new Rectangle(1, 0, 1, 1));

	JPanel all = new JPanel(new BorderLayout());
	all.setBackground(Color.white);
	all.add(header, BorderLayout.NORTH);
	all.add(centre, BorderLayout.CENTER);
	all.add(footer, BorderLayout.SOUTH);

	applyFlatterLaF(all);

	setTitle(CurrentLocale.get("com.tle.admin.gui.managementdialog.title",
		Driver.instance().getVersion().getFull(), Driver.instance().getInstitutionName()));
	setIconImage(new ImageIcon(ManagementDialog.class.getResource("/icons/windowicon.gif")).getImage());
	setContentPane(all);
	setResizable(false);
	setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
	addWindowListener(this);
	setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

	ComponentHelper.centreOnScreen(this);
}
 
Example 18
Project: JFrame   File: Source.java   View Source Code Vote up 4 votes
public void gui(){

	frame = new JFrame("Begin");
	frame.setVisible(true);
	frame.setSize(700, 500);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	
	panel = new JPanel();
	panel.setBackground(Color.GREEN);
	
	button = new JButton("Click");
	label = new JLabel("Label");
	
	
	panel.add(button);
	panel.add(label);
	
	frame.add(panel); //add panel to frame
	
}
 
Example 19
Project: xdman   File: XDMMainWindow.java   View Source Code Vote up 4 votes
private void createTabs() {
	JButton btnAllTab = new XDMButton(getString("ALL_DOWNLOADS")),
			btnIncompleteTab = new XDMButton(getString("ALL_UNFINISHED")),
			btnCompletedTab = new XDMButton(getString("ALL_FINISHED"));

	btnTabArr = new JButton[3];
	btnTabArr[0] = btnAllTab;
	btnTabArr[0].setName("ALL_DOWNLOADS");
	btnTabArr[1] = btnIncompleteTab;
	btnTabArr[1].setName("ALL_UNFINISHED");
	btnTabArr[2] = btnCompletedTab;
	btnTabArr[2].setName("ALL_FINISHED");

	for (int i = 0; i < 3; i++) {
		btnTabArr[i].setFont(StaticResource.plainFontBig);
		btnTabArr[i].setBorderPainted(false);
		btnTabArr[i].addActionListener(this);
	}

	btnAllTab.setBackground(new Color(242, 242, 242));

	btnIncompleteTab.setBackground(StaticResource.titleColor);
	btnIncompleteTab.setForeground(StaticResource.whiteColor);

	btnCompletedTab.setBackground(StaticResource.titleColor);
	btnCompletedTab.setForeground(StaticResource.whiteColor);

	JPanel pp = new JPanel(new BorderLayout());
	pp.setOpaque(false);

	JPanel p = new JPanel(new GridLayout(1, 3, 5, 0));
	p.setOpaque(false);
	Dimension d = new Dimension(350, 30);
	p.setPreferredSize(d);
	p.setMaximumSize(d);
	p.setMinimumSize(d);
	p.setBackground(Color.WHITE);
	p.add(btnAllTab);
	p.add(btnIncompleteTab);
	p.add(btnCompletedTab);
	pp.add(p, BorderLayout.EAST);

	getTitlePanel().add(pp, BorderLayout.SOUTH);
}
 
Example 20
Project: Equella   File: FileListPanel.java   View Source Code Vote up 4 votes
public Renderer()
{
	dateFormat = new SimpleDateFormat();

	icon = new IconLabel();

	filename = new JLabel(" ");
	// filename.setVerticalAlignment(SwingConstants.CENTER);

	Font f = filename.getFont();
	filename.setFont(f.deriveFont((float) (f.getSize() + 2)));

	sizeLabel = new JLabel(CurrentLocale.get("cell.size"));
	size = new JLabel();
	modifiedLabel = new JLabel(CurrentLocale.get("cell.modified"));
	modified = new JLabel();

	Dimension modPrefSize = modifiedLabel.getPreferredSize();
	final int width1 = 40;
	final int width2 = Math.max(sizeLabel.getPreferredSize().width, modPrefSize.width) + 5;
	final int height1 = filename.getPreferredSize().height;
	final int height2 = modPrefSize.height;

	MigLayout layout = new MigLayout("", "[" + width1 + "][" + width2 + "][200 - " + (width2 + width1) + "]",
		"[" + height1 + "]2[" + height2 + "]2[" + height2 + "]");

	base = new JPanel(layout);
	base.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
	base.setBackground(Color.WHITE);

	base.add(icon, "cell 0 0, spany 3");
	base.add(filename, "cell 1 0, spanx 2");
	base.add(sizeLabel, "cell 1 1");
	base.add(size, "cell 2 1");
	base.add(modifiedLabel, "cell 1 2");
	base.add(modified, "cell 2 2");
	int prefHeight = height1 + (height2 * 2) + 24; // size of the 3 rows
													// plus a little
													// padding

	base.setPreferredSize(new Dimension(MAX_CELL_WIDTH, prefHeight));
	base.setMaximumSize(new Dimension(MAX_CELL_WIDTH, prefHeight));
	base.setMinimumSize(new Dimension(MAX_CELL_WIDTH, prefHeight));

	if( CurrentLocale.isRightToLeft() )
	{
		base.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

	}
}