本文整理了Java中javax.swing.JFrame.setBackground()
方法的一些代码示例,展示了JFrame.setBackground()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFrame.setBackground()
方法的具体详情如下:
包路径:javax.swing.JFrame
类名称:JFrame
方法名:setBackground
暂无
代码示例来源:origin: stanfordnlp/CoreNLP
private void displayTsurgeonHelp() {
if(tsurgeonHelpFrame != null) {
tsurgeonHelpFrame.setVisible(true);
} else {
tsurgeonHelpFrame = new JFrame("TSurgeon Help...");
JEditorPane helpText = new JEditorPane();
helpText.setContentType("text/html");
// StringBuffer s = new StringBuffer();
// s.append(htmlTsurgeonHelp);
helpText.setText(htmlTsurgeonHelp);
helpText.setEditable(false);
JScrollPane scroller = new JScrollPane(helpText);
helpText.setCaretPosition(0);
scroller.setPreferredSize(new Dimension(500,500));
tsurgeonHelpFrame.add(scroller);
tsurgeonHelpFrame.pack();
tsurgeonHelpFrame.setBackground(Color.WHITE);
tsurgeonHelpFrame.setVisible(true);
}
}
代码示例来源:origin: stanfordnlp/CoreNLP
private void displayHelp() {
if (helpFrame != null) {
helpFrame.setVisible(true);
} else {
helpFrame = new JFrame("Tregex Help...");
//JPanel helpPanel = new JPanel();
JEditorPane helpText = new JEditorPane();
helpText.setContentType("text/html");
// StringBuffer s = new StringBuffer();
// s.append(htmlHelp);
helpText.setText(htmlHelp);
helpText.setEditable(false);
//helpPanel.add(helpText);
JScrollPane scroller = new JScrollPane(helpText);
helpText.setCaretPosition(0);
scroller.setPreferredSize(new Dimension(500,500));
helpFrame.add(scroller);
helpFrame.pack();
helpFrame.setBackground(Color.WHITE);
helpFrame.setVisible(true);
//helpFrame.repaint();
}
}
代码示例来源:origin: stanfordnlp/CoreNLP
private void showHistory() {
if (historyFrame == null) {
historyFrame = new JFrame("Statistics History");
} else {
historyFrame.setVisible(false);
historyFrame= new JFrame("Statistics History");
}
historyFrame.setLayout(new GridLayout(1,0));
Object[][] entries = new Object[historyList.size()][3];
for(int i = 0; i < historyList.size(); i++) {
entries[i] = historyList.get(i).toArray();
}
DefaultTableModel tableModel = new TregexGUITableModel(entries, HistoryEntry.columnNamesArray());
JTable statTable = new JTable(tableModel);
DefaultTableCellRenderer dtcr = (DefaultTableCellRenderer) statTable.getDefaultRenderer(String.class);
dtcr.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
JScrollPane scroller = new JScrollPane(statTable);
historyFrame.add(scroller);
historyFrame.pack();
historyFrame.setLocationRelativeTo(TregexGUI.getInstance());
historyFrame.setBackground(Color.WHITE);
historyFrame.setVisible(true);
historyFrame.repaint();
}
代码示例来源:origin: wildfly/wildfly
public void go() throws Exception {
if(!no_channel && !use_state)
channel.connect(cluster_name);
mainFrame=new JFrame();
mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
panel=new DrawPanel(use_state);
panel.setBackground(background_color);
sub_panel=new JPanel();
mainFrame.getContentPane().add("Center", panel);
clear_button=new JButton("Clear");
clear_button.setFont(default_font);
clear_button.addActionListener(this);
leave_button=new JButton("Leave");
leave_button.setFont(default_font);
leave_button.addActionListener(this);
sub_panel.add("South", clear_button);
sub_panel.add("South", leave_button);
mainFrame.getContentPane().add("South", sub_panel);
mainFrame.setBackground(background_color);
clear_button.setForeground(Color.blue);
leave_button.setForeground(Color.blue);
mainFrame.pack();
mainFrame.setLocation(15, 25);
mainFrame.setBounds(new Rectangle(250, 250));
if(!no_channel && use_state) {
channel.connect(cluster_name, null, state_timeout);
}
mainFrame.setVisible(true);
setTitle();
}
代码示例来源:origin: wildfly/wildfly
sub_panel.add("South", leave_button);
mainFrame.getContentPane().add("South", sub_panel);
mainFrame.setBackground(background_color);
clear_button.setForeground(Color.blue);
leave_button.setForeground(Color.blue);
代码示例来源:origin: wildfly/wildfly
public void start() throws Exception {
mainFrame=new JFrame("Chat demo");
mainFrame.setPreferredSize(new Dimension(600,600));
mainFrame.setBackground(Color.white);
mainFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
代码示例来源:origin: stackoverflow.com
public class Overlay {
public static void main(String[] args) {
JFrame frame = new JFrame("Transparent Window");
frame.setUndecorated(true);
frame.setBackground(new Color(0, 0, 0, 0));
frame.setAlwaysOnTop(true);
// Without this, the window is draggable from any non transparent
// point, including points inside textboxes.
frame.getRootPane().putClientProperty("apple.awt.draggableWindowBackground", false);
frame.getContentPane().setLayout(new java.awt.BorderLayout());
frame.getContentPane().add(new JTextField("text field north"), java.awt.BorderLayout.NORTH);
frame.getContentPane().add(new JTextField("text field south"), java.awt.BorderLayout.SOUTH);
frame.setVisible(true);
frame.pack();
}
}
代码示例来源:origin: RaiMan/SikuliX2
JFrame frame = new JFrame();
frame.setUndecorated(true);
frame.setBackground(new Color(0, 0, 0, 0.1f));
代码示例来源:origin: fossasia/neurolab-desktop
window.setBackground(Color.WHITE);
window.setSize(windowWidth, windowHeight);
window.move(0, nfbServer.height + 120);
代码示例来源:origin: stackoverflow.com
JFrame p = new JFrame();
p.add(new SingleImagePanel(new SourceImage(filename)));
p.setBackground(Color.BLACK);
p.setSize(512,512);
p.setVisible(true);
代码示例来源:origin: stackoverflow.com
JLabel click=new JLabel("Click me");
click.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
JFrame jf=new JFrame("new one");
jf.setBackground(Color.BLACK);
jf.setSize(new Dimension(200,70));
jf.setVisible(true);
jf.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
});
代码示例来源:origin: stackoverflow.com
public void answer(){
int area = (int) (length * width); // <--- Move this inside answer method
JFrame answer = new JFrame();
answer.setBackground(Color.yellow);
JPanel pan2 = new JPanel();
JLabel howanswer = new JLabel("Your answer is" + area + "We got this by multiplying the length and width");
pan2.add(howanswer);
answer.add(pan2); // <--- Don't forget to add your components to the frame
answer.pack(); // <--- Resize the frame to a suitable size
answer.setVisible(true); // <--- Set the frame to visible AFTER you have added the components
}
代码示例来源:origin: stackoverflow.com
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setBackground(new Color(0f, 0f, 0f, 0.1f));
f.setUndecorated(true);
f.add(new JLabel("<html>Testing<br>1, 2, 3</html>"));
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
代码示例来源:origin: stackoverflow.com
public static void startGame(JPanel panel) {
JFrame f = new JFrame("Journey To Carzett");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setResizable(true);
f.setBackground(Color.GRAY);
f.setVisible(true);
f.setSize(750, 500);
f.getContentPane(panel);
f.pack();
f.setVisible(true);
}
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame("Testing");
frame.setUndecorated(true);
frame.setBackground(new Color(0, 0, 0, 0));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new TestPane());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
代码示例来源:origin: stackoverflow.com
public static void main(String args[]) {
JFrame window = new JFrame("l");
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // <-- Handle closing
// the window.
Color black = new Color(0, 0, 0);
window.setBackground(black);
window.setSize(new Dimension(500, 500)); // <-- set a size.
window.setVisible(true); // <-- set it visible.
JDialog start = new JDialog(window, ";;");
start.setSize(new Dimension(300, 300)); // <-- set a size.
start.setVisible(true); // <-- set it visible.
}
代码示例来源:origin: stackoverflow.com
Component c; // the component you would like to print to a BufferedImage
JFrame frame = new JFrame();
frame.setBackground(Color.WHITE);
frame.setUndecorated(true);
frame.getContentPane().add(c);
frame.pack();
BufferedImage bi = new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = bi.createGraphics();
c.print(graphics);
graphics.dispose();
frame.dispose();
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame("Testing");
frame.setLayout(new FlowLayout()); // New line of code
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setPreferredSize(new Dimension(1000, 2000)); // Modified line of code
frame.setBackground(Color.WHITE);
JPanel jp = new JPanel();
jp.setBackground(Color.BLUE);
jp.setPreferredSize(new Dimension(40, 40)); // Modified line of code
frame.add(jp);
frame.pack(); // added line of code
frame.setVisible(true);
代码示例来源:origin: Exslims/MercuryTrade
public static void createAndShowGUI() {
JFrame frame = new JFrame("@title@");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.getContentPane().add(new AdrTesting());
frame.setUndecorated(true);
frame.setBackground(AppThemeColor.FRAME);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame();
frame.add(new ImagePanel());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setUndecorated(true);
frame.pack();
frame.setBackground(new Color(0, 0, 0, 0));
frame.setVisible(true);
内容来源于网络,如有侵权,请联系作者删除!