当前位置: 首页>>代码示例>>Java>>正文


Java JPanel.setBackground方法代码示例

本文整理汇总了Java中javax.swing.JPanel.setBackground方法的典型用法代码示例。如果您正苦于以下问题:Java JPanel.setBackground方法的具体用法?Java JPanel.setBackground怎么用?Java JPanel.setBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JPanel的用法示例。


在下文中一共展示了JPanel.setBackground方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SplashScreen

import javax.swing.JPanel; //导入方法依赖的package包/类
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);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:25,代码来源:SplashScreen.java

示例2: DrawImageThread

import javax.swing.JPanel; //导入方法依赖的package包/类
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);
}
 
开发者ID:larryzhuo,项目名称:JavaMinicap,代码行数:21,代码来源:DrawImageThread.java

示例3: MatchedBracketPopup

import javax.swing.JPanel; //导入方法依赖的package包/类
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();

}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:20,代码来源:MatchedBracketPopup.java

示例4: createOthersPanel

import javax.swing.JPanel; //导入方法依赖的package包/类
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);
}
 
开发者ID:kmarius,项目名称:xdman,代码行数:25,代码来源:BrowserIntDlg.java

示例5: init

import javax.swing.JPanel; //导入方法依赖的package包/类
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();
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:NotificationCenterTopComponent.java

示例6: getContainerPanel

import javax.swing.JPanel; //导入方法依赖的package包/类
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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:TestPopupMenu.java

示例7: initComponents

import javax.swing.JPanel; //导入方法依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:StopwatchProfilingPoint.java

示例8: initComponents

import javax.swing.JPanel; //导入方法依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:LoadGenProfilingPoint.java

示例9: erzeugeAnzeigerPanel

import javax.swing.JPanel; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:polemonium,项目名称:SE2Project,代码行数:15,代码来源:AusleiheUI.java

示例10: create

import javax.swing.JPanel; //导入方法依赖的package包/类
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);
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:QueryBuilderInternalFrame.java

示例11: preencher

import javax.swing.JPanel; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:17,代码来源:Muligar.java

示例12: createAndShowUI

import javax.swing.JPanel; //导入方法依赖的package包/类
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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:bug8016356.java

示例13: createBrighterPanel

import javax.swing.JPanel; //导入方法依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:BrowserMenu.java

示例14: DataTableViewer

import javax.swing.JPanel; //导入方法依赖的package包/类
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);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:58,代码来源:DataTableViewer.java

示例15: ResultView

import javax.swing.JPanel; //导入方法依赖的package包/类
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));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:46,代码来源:ResultView.java


注:本文中的javax.swing.JPanel.setBackground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。